20w21a ohboi

This commit is contained in:
gnembon committed 2020-05-21 02:59:17 -03:00
1 parent 838211edba
commit bec5259216
40 files changed
+445 -347

No files matched your search

@@ -0,0 +1,23 @@
package carpet.mixins;
import carpet.fakes.BiomeInterface;
import net.minecraft.class_5312;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.StructureFeature;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.Map;
@Mixin(Biome.class)
public class Biome_scarpetMixin implements BiomeInterface
{
@Shadow @Final private Map<StructureFeature<?>, class_5312<?, ?>> structureFeatures;
@Override
public class_5312<?, ?> getConfiguredFeature(StructureFeature<?> arg)
{
return structureFeatures.get(arg);
}
}
@@ -13,6 +13,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ChunkGenerator.class)
public abstract class ChunkGeneratorMixin
{
// this might not be needed anymore
/*
@Inject(method = "hasStructure", at = @At("HEAD"), cancellable = true)
private void skipGenerationBiomeChecks(Biome biome_1, StructureFeature<? extends FeatureConfig> structureFeature_1, CallbackInfoReturnable<Boolean> cir)
{
@@ -22,4 +24,6 @@ public abstract class ChunkGeneratorMixin
cir.cancel();
}
}
*/
}
@@ -44,11 +44,11 @@ public abstract class CoralBlockMixin implements Fertilizable
CoralFeature coral;
int variant = random.nextInt(3);
if (variant == 0)
coral = new CoralClawFeature(DefaultFeatureConfig::deserialize);
coral = new CoralClawFeature(DefaultFeatureConfig.field_24893);
else if (variant == 1)
coral = new CoralTreeFeature(DefaultFeatureConfig::deserialize);
coral = new CoralTreeFeature(DefaultFeatureConfig.field_24893);
else
coral = new CoralMushroomFeature(DefaultFeatureConfig::deserialize);
coral = new CoralMushroomFeature(DefaultFeatureConfig.field_24893);
MaterialColor color = blockUnder.getTopMaterialColor(worldIn, pos);
BlockState proper_block = blockUnder;
@@ -2,20 +2,22 @@ package carpet.mixins;
import carpet.CarpetSettings;
import com.google.common.collect.Lists;
import com.mojang.datafixers.Dynamic;
//import com.mojang.datafixers.Dynamic;
import com.mojang.serialization.Codec;
import net.minecraft.entity.EntityType;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.AbstractTempleFeature;
//import net.minecraft.world.gen.feature.AbstractTempleFeature;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import net.minecraft.world.gen.feature.DesertPyramidFeature;
import net.minecraft.world.gen.feature.StructureFeature;
import org.spongepowered.asm.mixin.Mixin;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
//import java.util.function.Function;
@Mixin(DesertPyramidFeature.class)
public abstract class DesertPyramidFeatureMixin extends AbstractTempleFeature<DefaultFeatureConfig>
public abstract class DesertPyramidFeatureMixin extends StructureFeature<DefaultFeatureConfig>
{
private static final List<Biome.SpawnEntry> MONSTER_SPAWNS;
@@ -23,12 +25,13 @@ public abstract class DesertPyramidFeatureMixin extends AbstractTempleFeature<De
{
MONSTER_SPAWNS = Lists.newArrayList(new Biome.SpawnEntry(EntityType.HUSK, 1, 1, 1));
}
public DesertPyramidFeatureMixin(Function<Dynamic<?>, ? extends DefaultFeatureConfig> function_1)
public DesertPyramidFeatureMixin(Codec<DefaultFeatureConfig> codec)
{
super(function_1);
super(codec);
}
@Override
public List<Biome.SpawnEntry> getMonsterSpawns()
{
@@ -2,7 +2,8 @@ package carpet.mixins;
import carpet.CarpetSettings;
import com.google.common.collect.Lists;
import com.mojang.datafixers.Dynamic;
//import com.mojang.datafixers.Dynamic;
import com.mojang.serialization.Codec;
import net.minecraft.entity.EntityType;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
@@ -12,16 +13,16 @@ import org.spongepowered.asm.mixin.Mixin;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
//import java.util.function.Function;
@Mixin(EndCityFeature.class)
public abstract class EndCityFeatureMixin extends StructureFeature<DefaultFeatureConfig>
{
private static final List<Biome.SpawnEntry> spawnList = Lists.newArrayList(new Biome.SpawnEntry(EntityType.SHULKER, 10, 4, 4));
public EndCityFeatureMixin(Function<Dynamic<?>, ? extends DefaultFeatureConfig> function_1)
public EndCityFeatureMixin(Codec<DefaultFeatureConfig> codec)
{
super(function_1);
super(codec);
}
@Override
@@ -1,6 +1,7 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.class_5321;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
@@ -21,7 +22,7 @@ public abstract class Entity_portalSuffocationMixin
value = "INVOKE",
target = "Lnet/minecraft/entity/Entity;getLastNetherPortalDirection()Lnet/minecraft/util/math/Direction;"
))
private void registerEntityDimensionChange(DimensionType newDimension, CallbackInfoReturnable<Entity> cir)
private void registerEntityDimensionChange(class_5321<DimensionType> newDimension, CallbackInfoReturnable<Entity> cir)
{
if (CarpetSettings.portalSuffocationFix)
{
@@ -43,7 +44,7 @@ public abstract class Entity_portalSuffocationMixin
}
@Inject(method = "changeDimension", at = @At("RETURN"))
private void removeEntity(DimensionType dimensionType_1, CallbackInfoReturnable<Entity> cir)
private void removeEntity(class_5321<DimensionType> newDimension, CallbackInfoReturnable<Entity> cir)
{
CarpetSettings.currentTelepotingEntityBox = null;
CarpetSettings.fixedPosition = null;
@@ -1,18 +1,20 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.block.Blocks;
//import net.minecraft.block.Blocks;
import net.minecraft.class_5311;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldAccess;
//import net.minecraft.world.WorldAccess;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.chunk.ChunkGeneratorConfig;
//import net.minecraft.world.gen.chunk.ChunkGeneratorConfig;
import net.minecraft.world.gen.chunk.FlatChunkGenerator;
import net.minecraft.world.gen.chunk.FlatChunkGeneratorConfig;
import net.minecraft.world.gen.feature.Feature;
//import net.minecraft.world.gen.chunk.FlatChunkGeneratorConfig;
//import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.StructureFeature;
import org.spongepowered.asm.mixin.Mixin;
import java.util.List;
@@ -20,63 +22,64 @@ import java.util.List;
@Mixin(FlatChunkGenerator.class)
public abstract class FlatChunkGeneratorMixin extends ChunkGenerator
{
public FlatChunkGeneratorMixin(BiomeSource biomeSource, ChunkGeneratorConfig chunkGeneratorConfig)
public FlatChunkGeneratorMixin(BiomeSource biomeSource, class_5311 arg)
{
super(biomeSource, chunkGeneratorConfig);
super(biomeSource, arg);
}
@Override
public List<Biome.SpawnEntry> getEntitySpawnList(Biome biome, StructureAccessor structureAccessor, SpawnGroup category, BlockPos blockPos)
public List<Biome.SpawnEntry> getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos)
{
if (CarpetSettings.flatWorldStructureSpawning)
{
if (Feature.SWAMP_HUT.isApproximatelyInsideStructure(structureAccessor, blockPos))
{
if (category == SpawnGroup.MONSTER)
if (accessor.method_28388(pos, true, StructureFeature.field_24851).hasChildren())
{ //swamp hut
if (group == SpawnGroup.MONSTER)
{
return Feature.SWAMP_HUT.getMonsterSpawns();
return StructureFeature.field_24851.getMonsterSpawns();
}
if (category == SpawnGroup.CREATURE)
if (group == SpawnGroup.CREATURE)
{
return Feature.SWAMP_HUT.getCreatureSpawns();
return StructureFeature.field_24851.getCreatureSpawns();
}
}
else if (category == SpawnGroup.MONSTER)
if (group == SpawnGroup.MONSTER)
{
if (Feature.PILLAGER_OUTPOST.isApproximatelyInsideStructure(structureAccessor, blockPos))
if (accessor.method_28388(pos, false, StructureFeature.PILLAGER_OUTPOST).hasChildren())
{
return Feature.PILLAGER_OUTPOST.getMonsterSpawns();
return StructureFeature.PILLAGER_OUTPOST.getMonsterSpawns();
}
if (CarpetSettings.huskSpawningInTemples)
{
if (Feature.DESERT_PYRAMID.isApproximatelyInsideStructure(structureAccessor, blockPos))
if (accessor.method_28388(pos, true, StructureFeature.DESERT_PYRAMID).hasChildren())
{
return Feature.DESERT_PYRAMID.getMonsterSpawns();
return StructureFeature.DESERT_PYRAMID.getMonsterSpawns();
}
}
if (Feature.OCEAN_MONUMENT.isApproximatelyInsideStructure(structureAccessor, blockPos))
if (accessor.method_28388(pos, false, StructureFeature.MONUMENT).hasChildren())
{
return Feature.OCEAN_MONUMENT.getMonsterSpawns();
return StructureFeature.MONUMENT.getMonsterSpawns();
}
if (Feature.NETHER_BRIDGE.isInsideStructure(structureAccessor, blockPos))
if (accessor.method_28388(pos, true, StructureFeature.FORTRESS).hasChildren())
{
return Feature.NETHER_BRIDGE.getMonsterSpawns();
return StructureFeature.FORTRESS.getMonsterSpawns();
}
if (CarpetSettings.shulkerSpawningInEndCities)
{
if (Feature.END_CITY.isInsideStructure(structureAccessor, blockPos))
if (accessor.method_28388(pos, true, StructureFeature.END_CITY).hasChildren())
{
return Feature.END_CITY.getMonsterSpawns();
return StructureFeature.END_CITY.getMonsterSpawns();
}
}
}
}
return super.getEntitySpawnList(biome, structureAccessor, category, blockPos);
return super.getEntitySpawnList(biome, accessor, group, pos);
}
}
@@ -1,23 +1,23 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.class_5284;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.chunk.FloatingIslandsChunkGenerator;
import net.minecraft.world.gen.chunk.SurfaceChunkGenerator;
import net.minecraft.world.gen.feature.Feature;
import org.spongepowered.asm.mixin.Mixin;
//import carpet.CarpetSettings;
//import net.minecraft.class_5284;
//import net.minecraft.entity.SpawnGroup;
//import net.minecraft.util.math.BlockPos;
//import net.minecraft.world.biome.Biome;
//import net.minecraft.world.biome.source.BiomeSource;
//import net.minecraft.world.gen.StructureAccessor;
//import net.minecraft.world.gen.chunk.FloatingIslandsChunkGenerator;
//import net.minecraft.world.gen.chunk.SurfaceChunkGenerator;
//import net.minecraft.world.gen.feature.Feature;
//import org.spongepowered.asm.mixin.Mixin;
//
//import java.util.List;
import java.util.List;
@Mixin(FloatingIslandsChunkGenerator.class)
public abstract class FloatingIslandsChunkGeneratorMixin extends SurfaceChunkGenerator<class_5284> //FloatingIslandsChunkGeneratorConfig
//@Mixin(FloatingIslandsChunkGenerator.class)
public abstract class FloatingIslandsChunkGeneratorMixin //extends SurfaceChunkGenerator<class_5284> //FloatingIslandsChunkGeneratorConfig
{
public FloatingIslandsChunkGeneratorMixin(BiomeSource biomeSource, long l, class_5284 arg, int i, int j, int k, boolean bl)
/*public FloatingIslandsChunkGeneratorMixin(BiomeSource biomeSource, long l, class_5284 arg, int i, int j, int k, boolean bl)
{
super(biomeSource, l, arg, i, j, k, bl);
}
@@ -33,5 +33,5 @@ public abstract class FloatingIslandsChunkGeneratorMixin extends SurfaceChunkGen
}
}
return super.getEntitySpawnList(biome, structureAccessor, category, pos);
}
}*/
}
@@ -6,6 +6,7 @@ import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.StructureFeature;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@@ -17,6 +18,6 @@ public class HuskEntityMixin
private static boolean isSkylightOrTempleVisible(WorldAccess WorldAccess, BlockPos blockPos_1)
{
return WorldAccess.isSkyVisible(blockPos_1) ||
(CarpetSettings.huskSpawningInTemples && Feature.DESERT_PYRAMID.isApproximatelyInsideStructure(((ServerWorld)WorldAccess).getStructureAccessor(), blockPos_1));
(CarpetSettings.huskSpawningInTemples && (((ServerWorld)WorldAccess).getStructureAccessor().method_28388(blockPos_1, false, StructureFeature.DESERT_PYRAMID).hasChildren()));
}
}
@@ -1,27 +1,27 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.chunk.OverworldChunkGenerator;
import net.minecraft.world.gen.chunk.OverworldChunkGeneratorConfig;
import net.minecraft.world.gen.chunk.SurfaceChunkGenerator;
import net.minecraft.world.gen.feature.Feature;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
//import carpet.CarpetSettings;
//import net.minecraft.entity.SpawnGroup;
//import net.minecraft.util.math.BlockPos;
//import net.minecraft.world.WorldAccess;
//import net.minecraft.world.biome.Biome;
//import net.minecraft.world.biome.source.BiomeSource;
//import net.minecraft.world.gen.StructureAccessor;
//import net.minecraft.world.gen.chunk.OverworldChunkGenerator;
//import net.minecraft.world.gen.chunk.OverworldChunkGeneratorConfig;
//import net.minecraft.world.gen.chunk.SurfaceChunkGenerator;
//import net.minecraft.world.gen.feature.Feature;
//import org.spongepowered.asm.mixin.Mixin;
//import org.spongepowered.asm.mixin.injection.At;
//import org.spongepowered.asm.mixin.injection.Inject;
//import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
@Mixin(OverworldChunkGenerator.class)
public abstract class OverworldChunkGeneratorMixin extends SurfaceChunkGenerator<OverworldChunkGeneratorConfig>
//@Mixin(OverworldChunkGenerator.class)
public abstract class OverworldChunkGeneratorMixin //extends SurfaceChunkGenerator<OverworldChunkGeneratorConfig>
{
public OverworldChunkGeneratorMixin(BiomeSource biomeSource, long seed, OverworldChunkGeneratorConfig arg, int i, int j, int k, boolean bl)
/*public OverworldChunkGeneratorMixin(BiomeSource biomeSource, long seed, OverworldChunkGeneratorConfig arg, int i, int j, int k, boolean bl)
{
super(biomeSource, seed, arg, i, j, k, bl);
}
@@ -38,5 +38,5 @@ public abstract class OverworldChunkGeneratorMixin extends SurfaceChunkGenerator
cir.setReturnValue(Feature.DESERT_PYRAMID.getMonsterSpawns());
}
}
}
}*/
}
@@ -4,6 +4,7 @@ import carpet.fakes.ServerChunkManagerInterface;
import carpet.utils.SpawnReporter;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.class_5217;
import net.minecraft.class_5321;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.server.world.ChunkTicketManager;
import net.minecraft.server.world.ServerChunkManager;
@@ -47,7 +48,7 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
private int setupTracking(ChunkTicketManager chunkTicketManager)
{
int j = chunkTicketManager.getSpawningChunkCount();
DimensionType dim = this.world.method_27983(); // getDimensionType;
class_5321<DimensionType> dim = this.world.method_27983(); // getDimensionType;
//((WorldInterface)world).getPrecookedMobs().clear(); not needed because mobs are compared with predefined BBs
SpawnReporter.chunkCounts.put(dim, j);
@@ -77,7 +78,7 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
{
for (SpawnGroup cat: SpawnGroup.values())
{
DimensionType dim = world.method_27983(); // getDimensionType;
class_5321<DimensionType> dim = world.method_27983(); // getDimensionType;
Pair key = Pair.of(dim, cat);
int spawnTries = SpawnReporter.spawn_tries.get(cat);
if (!SpawnReporter.local_spawns.containsKey(cat))
@@ -3,6 +3,7 @@ package carpet.mixins;
import carpet.fakes.EntityInterface;
import carpet.script.EntityEventsGroup;
import com.mojang.authlib.GameProfile;
import net.minecraft.class_5321;
import net.minecraft.entity.Entity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
@@ -88,23 +89,23 @@ public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity
}
private Vec3d previousLocation;
private DimensionType previousDimension;
private class_5321<DimensionType> previousDimension;
@Inject(method = "changeDimension", at = @At("HEAD"))
private void logPreviousCoordinates(DimensionType newDimension, CallbackInfoReturnable<Entity> cir)
private void logPreviousCoordinates(class_5321<DimensionType> newDimension, CallbackInfoReturnable<Entity> cir)
{
previousLocation = getPos();
previousDimension = dimension;
previousDimension = world.method_27983(); //dimension type
}
@Inject(method = "changeDimension", at = @At("RETURN"))
private void atChangeDimension(DimensionType newDimension, CallbackInfoReturnable<Entity> cir)
private void atChangeDimension(class_5321<DimensionType> newDimension, CallbackInfoReturnable<Entity> cir)
{
if (PLAYER_CHANGES_DIMENSION.isNeeded())
{
ServerPlayerEntity player = (ServerPlayerEntity) (Object)this;
Vec3d to = null;
if (!notInAnyWorld || previousDimension != DimensionType.THE_END || newDimension != DimensionType.OVERWORLD)
if (!notInAnyWorld || previousDimension != DimensionType.field_24755 || newDimension != DimensionType.field_24753) // end ow
{
to = getPos();
}
@@ -27,6 +27,8 @@ public abstract class ServerWorld_tickMixin extends World
@Shadow protected abstract void processSyncedBlockEvents();
//@Shadow protected abstract void sendBlockActions();
@Shadow protected abstract void method_29203();
protected ServerWorld_tickMixin(class_5269 arg, DimensionType dimensionType, Supplier<Profiler> supplier, boolean bl, boolean bl2, long l)
{
super(arg, dimensionType, supplier, bl, bl2, l);
@@ -138,11 +140,11 @@ public abstract class ServerWorld_tickMixin extends World
@Redirect(method = "tick", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/world/ServerWorld;tickTime()V"
target = "Lnet/minecraft/server/world/ServerWorld;method_29203()V" //tickTime() // right before chunk source
))
private void tickTimeConditionally(ServerWorld serverWorld)
{
if (TickSpeed.process_entities) this.tickTime();
if (TickSpeed.process_entities) this.method_29203();
}
@Redirect(method = "tick", at = @At(
@@ -165,14 +167,14 @@ public abstract class ServerWorld_tickMixin extends World
if (TickSpeed.process_entities) raidManager.tick();
}
@Redirect(method = "tick", at = @At(
/*@Redirect(method = "tick", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/WanderingTraderManager;tick()V"
))
private void tickConditionally(WanderingTraderManager wanderingTraderManager)
{
if (TickSpeed.process_entities) wanderingTraderManager.tick();
}
}*/
@Redirect(method = "tick", at = @At(
value = "INVOKE",
@@ -6,6 +6,7 @@ import carpet.utils.SpawnReporter;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FenceGateBlock;
import net.minecraft.class_5321;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.EntityData;
@@ -162,7 +163,7 @@ public class SpawnHelperMixin
if (SpawnReporter.track_spawns > 0L && SpawnReporter.local_spawns != null)
{
SpawnReporter.registerSpawn(
world.method_27983(), // getDimensionType //dimension.getType(), // getDimensionType
//world.method_27983(), // getDimensionType //dimension.getType(), // getDimensionType
(MobEntity) entity_1,
entity_1.getType().getSpawnGroup(),
entity_1.getBlockPos());
@@ -280,7 +281,7 @@ public class SpawnHelperMixin
SpawnGroup entityCategory = var6[var8];
if ((spawnAnimals || !entityCategory.isPeaceful()) && (spawnMonsters || entityCategory.isPeaceful()) && (shouldSpawnAnimals || !entityCategory.isAnimal()) )
{
DimensionType dim = world.method_27983(); // getDimensionType;
class_5321<DimensionType> dim = world.method_27983(); // getDimensionType;
int newCap = (int) ((double)entityCategory.getCapacity()*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4))));
int int_2 = SpawnReporter.chunkCounts.get(dim); // eligible chunks for spawning
int int_3 = newCap * int_2 / CHUNK_AREA; //current spawning limits
@@ -7,13 +7,14 @@ import net.minecraft.structure.StructureStart;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.BlockBox;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.gen.ChunkRandom;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.chunk.ChunkGeneratorConfig;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import net.minecraft.world.gen.feature.FeatureConfig;
import net.minecraft.world.gen.feature.StructureFeature;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -21,31 +22,33 @@ import org.spongepowered.asm.mixin.Shadow;
import java.util.Random;
@Mixin(StructureFeature.class)
public abstract class StructureFeatureMixin implements StructureFeatureInterface
public abstract class StructureFeatureMixin<C extends FeatureConfig> implements StructureFeatureInterface<C>
{
//problem is that is seems that now chunks deal with its portion of the strucuture
//on its own.
@Shadow public abstract int getRadius();
//@Shadow public abstract int getRadius();
@Shadow public abstract String getName();
@Shadow public abstract StructureFeature.StructureStartFactory getStructureStartFactory();
@Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, C featureConfig);
@Override
public boolean plopAnywhere(ServerWorld world, BlockPos pos)
{
return plopAnywhere(world, pos, world.getChunkManager().getChunkGenerator(), false);
return plopAnywhere(world, pos, world.getChunkManager().getChunkGenerator(), false, null, null);
}
@Override
public boolean gridAnywhere(ServerWorld world, BlockPos pos)
{
return plopAnywhere(world, pos, world.getChunkManager().getChunkGenerator(), true);
return plopAnywhere(world, pos, world.getChunkManager().getChunkGenerator(), true, null, null);
}
@Override
public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly)
public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly, Biome biome, FeatureConfig config)
{
if (world.isClient())
return false;
@@ -56,7 +59,7 @@ public abstract class StructureFeatureMixin implements StructureFeatureInterface
int j = pos.getX() >> 4;
int k = pos.getZ() >> 4;
long chId = ChunkPos.toLong(j, k);
StructureStart structurestart = forceStructureStart(world, generator, rand, chId);
StructureStart structurestart = forceStructureStart(world, generator, rand, chId, biome, config);
if (structurestart == StructureStart.DEFAULT)
{
return false;
@@ -68,18 +71,19 @@ public abstract class StructureFeatureMixin implements StructureFeatureInterface
BlockBox box = structurestart.getBoundingBox();
if (!wireOnly)
{
structurestart.generateStructure(world, world.getStructureAccessor(), generator, rand,
new BlockBox(
structurestart.generateStructure(world, world.getStructureAccessor(), generator, rand,box,
/*new BlockBox(
pos.getX() - this.getRadius() * 16,
pos.getZ() - this.getRadius() * 16,
pos.getX() + (this.getRadius() + 1) * 16,
pos.getZ() + (1 + this.getRadius()) * 16),
pos.getZ() + (1 + this.getRadius()) * 16),*/
new ChunkPos(j, k)
);
}
//structurestart.notifyPostProcessAt(new ChunkPos(j, k));
int i = Math.max(box.getBlockCountX(),box.getBlockCountZ())/16+1; //size
int i = getRadius();
//int i = getRadius();
for (int k1 = j - i; k1 <= j + i; ++k1)
{
for (int l1 = k - i; l1 <= k + i; ++l1)
@@ -108,7 +112,7 @@ public abstract class StructureFeatureMixin implements StructureFeatureInterface
return true;
}
private StructureStart forceStructureStart(ServerWorld worldIn, ChunkGenerator generator, Random rand, long packedChunkPos)
private StructureStart forceStructureStart(ServerWorld worldIn, ChunkGenerator generator, Random rand, long packedChunkPos, Biome biome, FeatureConfig config)
{
ChunkPos chunkpos = new ChunkPos(packedChunkPos);
StructureStart structurestart;
@@ -124,9 +128,14 @@ public abstract class StructureFeatureMixin implements StructureFeatureInterface
return structurestart;
}
}
Biome biome_1 = generator.getBiomeSource().getBiomeForNoiseGen((chunkpos.getStartX() + 9) >> 2, 0, (chunkpos.getStartZ() + 9) >> 2 );
Biome biome_1 = biome;
if (biome == null)
biome_1 = generator.getBiomeSource().getBiomeForNoiseGen((chunkpos.getStartX() + 9) >> 2, 0, (chunkpos.getStartZ() + 9) >> 2 );
StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos.x, chunkpos.z, BlockBox.empty(),0,worldIn.getSeed());
structurestart1.init(generator, worldIn.getStructureManager() , chunkpos.x, chunkpos.z, biome_1);
if (config == null)
config = new DefaultFeatureConfig();
structurestart1.init(generator, worldIn.getStructureManager() , chunkpos.x, chunkpos.z, biome_1, config);
structurestart = structurestart1.hasChildren() ? structurestart1 : StructureStart.DEFAULT;
if (structurestart.hasChildren())
@@ -137,4 +146,10 @@ public abstract class StructureFeatureMixin implements StructureFeatureInterface
//long2objectmap.put(packedChunkPos, structurestart);
return structurestart;
}
@Override
public boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, C featureConfig)
{
return shouldStartAt(chunkGenerator, biomeSource, l, chunkRandom, i, j, biome, chunkPos, featureConfig);
}
}
@@ -0,0 +1,48 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.class_5311;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.chunk.SurfaceChunkGenerator;
//import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.StructureFeature;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
@Mixin(SurfaceChunkGenerator.class)
public abstract class SurfaceChunkGenerator_husksSpawnMixin extends ChunkGenerator
{
public SurfaceChunkGenerator_husksSpawnMixin(BiomeSource biomeSource, class_5311 arg)
{
super(biomeSource, arg);
}
@Inject(method = "getEntitySpawnList", at = @At("HEAD"), cancellable = true)
private void isInsidePyramid(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos, CallbackInfoReturnable<List<Biome.SpawnEntry>> cir)
{
if (CarpetSettings.huskSpawningInTemples && group == SpawnGroup.MONSTER)
{
if (accessor.method_28388(pos, true, StructureFeature.DESERT_PYRAMID).hasChildren())
{
cir.setReturnValue(StructureFeature.DESERT_PYRAMID.getMonsterSpawns());
}
}
if (CarpetSettings.shulkerSpawningInEndCities && SpawnGroup.MONSTER == group)
{
if (accessor.method_28388(pos, true, StructureFeature.END_CITY).hasChildren())
{
cir.setReturnValue(StructureFeature.END_CITY.getMonsterSpawns());
}
}
}
}
@@ -120,7 +120,7 @@ public abstract class VillagerEntity_aiMixin extends AbstractTraderEntity
if (itemStack_1.getItem() == Items.EMERALD)
{
GlobalPos bedPos = this.brain.getOptionalMemory(MemoryModuleType.HOME).orElse(null);
if (bedPos == null || bedPos.getDimension() != dimension)
if (bedPos == null || bedPos.getDimension() != world.method_27983()) // get DImension
{
sayNo();
((ServerWorld) getEntityWorld()).spawnParticles(ParticleTypes.BARRIER, getX(), getY() + getStandingEyeHeight() + 1, getZ(), 1, 0.1, 0.1, 0.1, 0.0);
@@ -3,7 +3,7 @@ package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.class_5294;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.world.dimension.Dimension;
//import net.minecraft.world.dimension.Dimension;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;