diff --git a/gradle.properties b/gradle.properties index c736d2b7..a30e851f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=21w37a - yarn_mappings=21w37a+build.13 + minecraft_version=21w38a + yarn_mappings=21w38a+build.2 loader_version=0.11.7 - fabric_version=0.40.3+1.18 + fabric_version=0.40.4+1.18 # Mod Properties mod_version = 1.4.46 diff --git a/src/main/java/carpet/fakes/StructureFeatureInterface.java b/src/main/java/carpet/fakes/StructureFeatureInterface.java index db05ac1f..ed8eefd2 100644 --- a/src/main/java/carpet/fakes/StructureFeatureInterface.java +++ b/src/main/java/carpet/fakes/StructureFeatureInterface.java @@ -10,8 +10,8 @@ import net.minecraft.world.gen.random.ChunkRandom; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.FeatureConfig; -public interface StructureFeatureInterface +public interface StructureFeatureInterface { - boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly,Biome biome, FeatureConfig config); + boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly,Biome biome, C config); boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, ChunkPos chpos, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView); } diff --git a/src/main/java/carpet/helpers/CustomSpawnLists.java b/src/main/java/carpet/helpers/CustomSpawnLists.java new file mode 100644 index 00000000..083ea7a2 --- /dev/null +++ b/src/main/java/carpet/helpers/CustomSpawnLists.java @@ -0,0 +1,16 @@ +package carpet.helpers; + +import net.minecraft.entity.EntityType; +import net.minecraft.util.collection.Pool; +import net.minecraft.world.biome.SpawnSettings; + +public class CustomSpawnLists +{ + public static final Pool PYRAMID_SPAWNS = Pool.of(new SpawnSettings.SpawnEntry(EntityType.HUSK, 1, 1, 1)); + public static final Pool SHULKER_SPAWNS = Pool.of(new SpawnSettings.SpawnEntry(EntityType.SHULKER, 10, 4, 4)); + public static final Pool BASTION_SPAWNS = Pool.of( + new SpawnSettings.SpawnEntry(EntityType.PIGLIN_BRUTE, 5, 1, 2), + new SpawnSettings.SpawnEntry(EntityType.PIGLIN, 10, 2, 4), + new SpawnSettings.SpawnEntry(EntityType.HOGLIN, 2, 1, 2) + ); +} diff --git a/src/main/java/carpet/helpers/FeatureGenerator.java b/src/main/java/carpet/helpers/FeatureGenerator.java index 79b834b8..2cac3e79 100644 --- a/src/main/java/carpet/helpers/FeatureGenerator.java +++ b/src/main/java/carpet/helpers/FeatureGenerator.java @@ -3,6 +3,8 @@ package carpet.helpers; import carpet.CarpetSettings; import carpet.fakes.StructureFeatureInterface; import com.mojang.datafixers.util.Pair; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; import net.minecraft.server.world.ServerWorld; import net.minecraft.structure.StructureManager; import net.minecraft.structure.StructureStart; @@ -12,18 +14,19 @@ import net.minecraft.structure.processor.StructureProcessorLists; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.math.intprovider.ConstantIntProvider; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeKeys; import net.minecraft.world.biome.BuiltinBiomes; -import net.minecraft.world.biome.source.BiomeAccess; +import net.minecraft.world.gen.feature.size.TwoLayersFeatureSize; +import net.minecraft.world.gen.foliage.BlobFoliagePlacer; +import net.minecraft.world.gen.foliage.LargeOakFoliagePlacer; import net.minecraft.world.gen.random.ChunkRandom; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.StructureConfig; -import net.minecraft.world.gen.treedecorator.BeehiveTreeDecorator; import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.ConfiguredFeatures; import net.minecraft.world.gen.feature.ConfiguredStructureFeature; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.FeatureConfig; @@ -31,10 +34,15 @@ import net.minecraft.world.gen.feature.SimpleRandomFeatureConfig; import net.minecraft.world.gen.feature.StructureFeature; import net.minecraft.world.gen.feature.StructurePoolFeatureConfig; import net.minecraft.world.gen.feature.TreeFeatureConfig; +import net.minecraft.world.gen.stateprovider.BlockStateProvider; +import net.minecraft.world.gen.treedecorator.BeehiveTreeDecorator; +import net.minecraft.world.gen.trunk.LargeOakTrunkPlacer; +import net.minecraft.world.gen.trunk.StraightTrunkPlacer; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.OptionalInt; import java.util.function.Supplier; public class FeatureGenerator @@ -161,7 +169,7 @@ public class FeatureGenerator private static ConfiguredStructureFeature getDefaultFeature(StructureFeature structure, ServerWorld world, BlockPos pos, boolean tryHard) { - var definedStructures = world.getServer().getSaveProperties().getGeneratorOptions().getChunkGenerator().getStructuresConfig().getConfiguredStructureFeature(structure); + var definedStructures = world.getChunkManager().getChunkGenerator().getStructuresConfig().getConfiguredStructureFeature(structure); var optinalBiome = world.getRegistryManager().get(Registry.BIOME_KEY).getKey(world.getBiome(pos)); if (optinalBiome.isPresent()) for (var configureStructure: definedStructures.inverse().get(optinalBiome.get())) @@ -199,27 +207,51 @@ public class FeatureGenerator Biome biome = world.getBiome(new BlockPos(chunkPos.getStartX() + 9, 0, chunkPos.getStartZ() + 9)); ConfiguredStructureFeature configuredFeature = getDefaultFeature(structure, world, pos, false); if (configuredFeature == null || configuredFeature.config == null) return null; - ChunkPos chunkPos2 = structure.getStartChunk(params, seed, chunkRandom, chunkPos.x, chunkPos.z); //find some chunk I guess + var definedStructures = generator.getStructuresConfig().getConfiguredStructureFeature(structure); + var biomeConfig = definedStructures.get(configuredFeature); + var biomeRegistry = world.getRegistryManager().get(Registry.BIOME_KEY); + StructureConfig structureConfig = generator.getStructuresConfig().getForType(StructureFeature.STRONGHOLD); + synchronized (boo) + { + StructureStart start = configuredFeature.tryPlaceStart(world.getRegistryManager(), generator, generator.getBiomeSource(), + world.getStructureManager(), world.getSeed(), chunkPos, 0, structureConfig, world, (b) -> biomeRegistry.getKey(b).filter(biomeConfig::contains).isPresent()); + if (start != null && start.hasChildren()) + return start; + } + + /*ChunkPos chunkPos2 = structure.getStartChunk(params, seed, chunkRandom, chunkPos.x, chunkPos.z); //find some chunk I guess // using here world for heightview, rather than chunk since we - unlike vanilla, want to avoid creating any chunks even on the // structure starts level - lets see where would that take us. if (chunkPos.x == chunkPos2.x && chunkPos.z == chunkPos2.z && ((StructureFeatureInterface)structure).shouldStartPublicAt(generator, generator.getBiomeSource(), seed, chunkRandom, chunkPos, chunkPos, configuredFeature.config, world)) // should start at { if (!computeBox) return StructureStart.DEFAULT; StructureManager manager = world.getStructureManager(); + class_6626 lv = new class_6626(); + field_34929.generatePieces(lv, config, new class_6622.class_6623(worldIn.getRegistryManager(), generator, worldIn.getStructureManager(), chunkpos, b -> true, worldIn, Util.make(new ChunkRandom(), (chunkRandomx) -> { + chunkRandomx.setCarverSeed(worldIn.getSeed(), chunkpos.x, chunkpos.z); + }), worldIn.getSeed())); + StructureStart structurestart1 = new StructureStart<>(thiss, chunkpos, 0, lv.method_38714()); + StructureStart structureStart3 = structure.getStructureStartFactory().create((StructureFeature) configuredFeature.feature, chunkPos, 0, seed); synchronized (boo) { structureStart3.init(world.getRegistryManager(), generator, manager, chunkPos, (T) configuredFeature.config, world, (b) -> b == biome); } if (!structureStart3.hasChildren()) return null; return structureStart3; - } + }*/ return null; } + private static TreeFeatureConfig.Builder createTree(Block block, Block block2, int i, int j, int k, int l) { + return new TreeFeatureConfig.Builder(BlockStateProvider.of(block), new StraightTrunkPlacer(i, j, k), BlockStateProvider.of(block2), new BlobFoliagePlacer(ConstantIntProvider.create(l), ConstantIntProvider.create(0), 3), new TwoLayersFeatureSize(1, 0, 1)); + } + public static final Map featureMap = new HashMap() {{ - put("oak_bees", simpleTree(ConfiguredFeatures.OAK.getConfig().setTreeDecorators(List.of(new BeehiveTreeDecorator(1.0F))))); - put("fancy_oak_bees", simpleTree(ConfiguredFeatures.FANCY_OAK.getConfig().setTreeDecorators(List.of(new BeehiveTreeDecorator(1.0F))))); - put("birch_bees", simpleTree(ConfiguredFeatures.BIRCH.getConfig().setTreeDecorators(List.of(new BeehiveTreeDecorator(1.0F))))); + + put("oak_bees", simpleTree( createTree(Blocks.OAK_LOG, Blocks.OAK_LEAVES, 4, 2, 0, 2).ignoreVines().decorators(List.of(new BeehiveTreeDecorator(1.00F))).build())); + put("fancy_oak_bees", simpleTree( (new TreeFeatureConfig.Builder(BlockStateProvider.of(Blocks.OAK_LOG), new LargeOakTrunkPlacer(3, 11, 0), BlockStateProvider.of(Blocks.OAK_LEAVES), new LargeOakFoliagePlacer(ConstantIntProvider.create(2), ConstantIntProvider.create(4), 4), new TwoLayersFeatureSize(0, 0, 0, OptionalInt.of(4)))).ignoreVines().decorators(List.of(new BeehiveTreeDecorator(1.00F))).build())); + put("birch_bees", simpleTree( createTree(Blocks.BIRCH_LOG, Blocks.BIRCH_LEAVES, 5, 2, 0, 2).ignoreVines().decorators(List.of(new BeehiveTreeDecorator(1.00F))).build())); + put("coral_tree", simplePlop(Feature.CORAL_TREE.configure(FeatureConfig.DEFAULT))); put("coral_claw", simplePlop(Feature.CORAL_CLAW.configure(FeatureConfig.DEFAULT))); put("coral_mushroom", simplePlop(Feature.CORAL_MUSHROOM.configure(FeatureConfig.DEFAULT))); diff --git a/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java b/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java index 0633874c..32ef1331 100644 --- a/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java +++ b/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java @@ -18,8 +18,9 @@ import java.util.Collections; import java.util.List; @Mixin(BastionRemnantFeature.class) -public abstract class BastionRemnantFeatureMixin extends JigsawFeature +public abstract class BastionRemnantFeatureMixin //extends JigsawFeature { + /* private static final Pool spawnList = Pool.of( new SpawnSettings.SpawnEntry(EntityType.PIGLIN_BRUTE, 5, 1, 2), new SpawnSettings.SpawnEntry(EntityType.PIGLIN, 10, 2, 4), @@ -38,4 +39,5 @@ public abstract class BastionRemnantFeatureMixin extends JigsawFeature return spawnList; return SpawnSettings.EMPTY_ENTRY_POOL; } + */ } diff --git a/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java b/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java index ff46ca42..be213bfb 100644 --- a/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java +++ b/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java @@ -15,8 +15,9 @@ import java.util.Collections; import java.util.List; @Mixin(DesertPyramidFeature.class) -public abstract class DesertPyramidFeatureMixin extends StructureFeature +public abstract class DesertPyramidFeatureMixin { + /* private static final Pool MONSTER_SPAWNS; static @@ -39,5 +40,7 @@ public abstract class DesertPyramidFeatureMixin extends StructureFeature +public abstract class EndCityFeatureMixin //extends StructureFeature { + /* private static final Pool spawnList = Pool.of(new SpawnSettings.SpawnEntry(EntityType.SHULKER, 10, 4, 4)); public EndCityFeatureMixin(Codec codec) @@ -31,4 +32,5 @@ public abstract class EndCityFeatureMixin extends StructureFeature getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos) { - if (CarpetSettings.flatWorldStructureSpawning) - { - if (accessor.getStructureAt(pos, true, StructureFeature.SWAMP_HUT).hasChildren()) - { //swamp hut - if (group == SpawnGroup.MONSTER) - { - return StructureFeature.SWAMP_HUT.getMonsterSpawns(); - } + if (!CarpetSettings.flatWorldStructureSpawning) return super.getEntitySpawnList(biome, accessor, group, pos); - if (group == SpawnGroup.CREATURE) - { - return StructureFeature.SWAMP_HUT.getCreatureSpawns(); - } + // vanila noise one + if (accessor.getStructureAt(pos, true, StructureFeature.SWAMP_HUT).hasChildren()) { + if (group == SpawnGroup.MONSTER) { + return SwampHutFeature.MONSTER_SPAWNS; } - if (group == SpawnGroup.MONSTER) + if (group == SpawnGroup.CREATURE) { + return SwampHutFeature.CREATURE_SPAWNS; + } + } + + if (group == SpawnGroup.MONSTER) { + if (accessor.getStructureAt(pos, false, StructureFeature.PILLAGER_OUTPOST).hasChildren()) { + return PillagerOutpostFeature.MONSTER_SPAWNS; + } + + if (accessor.getStructureAt(pos, false, StructureFeature.MONUMENT).hasChildren()) { + return OceanMonumentFeature.MONSTER_SPAWNS; + } + + if (accessor.getStructureAt(pos, true, StructureFeature.FORTRESS).hasChildren()) { + return NetherFortressFeature.MONSTER_SPAWNS; + } + } + + + // carpet spawns + if (group == SpawnGroup.MONSTER) + { + if (CarpetSettings.huskSpawningInTemples) { - if (accessor.getStructureAt(pos, false, StructureFeature.PILLAGER_OUTPOST).hasChildren()) + if (accessor.getStructureAt(pos, true, StructureFeature.DESERT_PYRAMID).hasChildren()) { - return StructureFeature.PILLAGER_OUTPOST.getMonsterSpawns(); + return CustomSpawnLists.PYRAMID_SPAWNS; } - - if (CarpetSettings.huskSpawningInTemples) + } + if (CarpetSettings.shulkerSpawningInEndCities) + { + if (accessor.getStructureAt(pos, true, StructureFeature.END_CITY).hasChildren()) { - if (accessor.getStructureAt(pos, true, StructureFeature.DESERT_PYRAMID).hasChildren()) - { - return StructureFeature.DESERT_PYRAMID.getMonsterSpawns(); - } + return CustomSpawnLists.SHULKER_SPAWNS; } - - if (accessor.getStructureAt(pos, false, StructureFeature.MONUMENT).hasChildren()) + } + if (CarpetSettings.piglinsSpawningInBastions) + { + if (accessor.getStructureAt(pos, true, StructureFeature.BASTION_REMNANT).hasChildren()) { - return StructureFeature.MONUMENT.getMonsterSpawns(); - } - - if (accessor.getStructureAt(pos, true, StructureFeature.FORTRESS).hasChildren()) - { - return StructureFeature.FORTRESS.getMonsterSpawns(); - } - - if (CarpetSettings.shulkerSpawningInEndCities) - { - if (accessor.getStructureAt(pos, true, StructureFeature.END_CITY).hasChildren()) - { - return StructureFeature.END_CITY.getMonsterSpawns(); - } + return CustomSpawnLists.BASTION_SPAWNS; } } } - return super.getEntitySpawnList(biome, accessor, group, pos); + return (group == SpawnGroup.UNDERGROUND_WATER_CREATURE || group == SpawnGroup.AXOLOTLS) && accessor.getStructureAt(pos, false, StructureFeature.MONUMENT).hasChildren() ? SpawnSettings.EMPTY_ENTRY_POOL : super.getEntitySpawnList(biome, accessor, group, pos); + + } } diff --git a/src/main/java/carpet/mixins/NoiseChunkGenerator_husksSpawnMixin.java b/src/main/java/carpet/mixins/NoiseChunkGenerator_husksSpawnMixin.java index 8f563592..773c48d3 100644 --- a/src/main/java/carpet/mixins/NoiseChunkGenerator_husksSpawnMixin.java +++ b/src/main/java/carpet/mixins/NoiseChunkGenerator_husksSpawnMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; +import carpet.helpers.CustomSpawnLists; import net.minecraft.entity.SpawnGroup; import net.minecraft.util.collection.Pool; import net.minecraft.util.math.BlockPos; @@ -32,18 +33,30 @@ public abstract class NoiseChunkGenerator_husksSpawnMixin extends ChunkGenerator @Inject(method = "getEntitySpawnList", at = @At("HEAD"), cancellable = true) private void isInsidePyramid(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos, CallbackInfoReturnable> cir) { - if (CarpetSettings.huskSpawningInTemples && group == SpawnGroup.MONSTER) + if (group == SpawnGroup.MONSTER) { - if (accessor.getStructureAt(pos, true, StructureFeature.DESERT_PYRAMID).hasChildren()) + if (CarpetSettings.huskSpawningInTemples) { - cir.setReturnValue(StructureFeature.DESERT_PYRAMID.getMonsterSpawns()); + if (accessor.getStructureAt(pos, true, StructureFeature.DESERT_PYRAMID).hasChildren()) + { + cir.setReturnValue(CustomSpawnLists.PYRAMID_SPAWNS); + return; + } } - } - if (CarpetSettings.shulkerSpawningInEndCities && SpawnGroup.MONSTER == group) - { - if (accessor.getStructureAt(pos, true, StructureFeature.END_CITY).hasChildren()) + if (CarpetSettings.shulkerSpawningInEndCities) { - cir.setReturnValue(StructureFeature.END_CITY.getMonsterSpawns()); + if (accessor.getStructureAt(pos, true, StructureFeature.END_CITY).hasChildren()) + { + cir.setReturnValue(CustomSpawnLists.SHULKER_SPAWNS); + return; + } + } + if (CarpetSettings.piglinsSpawningInBastions) + { + if (accessor.getStructureAt(pos, true, StructureFeature.BASTION_REMNANT).hasChildren()) + { + cir.setReturnValue(CustomSpawnLists.BASTION_SPAWNS); + } } } } diff --git a/src/main/java/carpet/mixins/StructureFeatureMixin.java b/src/main/java/carpet/mixins/StructureFeatureMixin.java index 638b884e..65c9aa2c 100644 --- a/src/main/java/carpet/mixins/StructureFeatureMixin.java +++ b/src/main/java/carpet/mixins/StructureFeatureMixin.java @@ -3,8 +3,11 @@ package carpet.mixins; import carpet.CarpetSettings; import carpet.fakes.StructureFeatureInterface; import com.google.common.collect.ImmutableMultimap; +import net.minecraft.class_6622; +import net.minecraft.class_6626; import net.minecraft.server.world.ServerWorld; import net.minecraft.structure.StructureStart; +import net.minecraft.util.Util; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.BlockBox; @@ -22,6 +25,7 @@ import net.minecraft.world.gen.feature.ConfiguredStructureFeature; 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.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -34,14 +38,16 @@ public abstract class StructureFeatureMixin implements { @Shadow public abstract String getName(); - @Shadow public abstract StructureFeature.StructureStartFactory getStructureStartFactory(); + //@Shadow public abstract StructureFeature.StructureStartFactory getStructureStartFactory(); //@Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, ChunkPos chunkPos, Biome biome, ChunkPos chunkPos2, C featureConfig, HeightLimitView heightLimitView); @Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, ChunkPos pos, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView); + @Shadow @Final private class_6622 field_34929; + @Override - public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly, Biome biome, FeatureConfig config) + public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly, Biome biome, C config) { if (world.isClient()) return false; @@ -52,12 +58,12 @@ public abstract class StructureFeatureMixin implements int j = pos.getX() >> 4; int k = pos.getZ() >> 4; long chId = ChunkPos.toLong(j, k); - StructureStart structurestart = forceStructureStart(world, generator, rand, chId, biome, config); + StructureStart structurestart = forceStructureStart(world, generator, rand, chId, biome, config); if (structurestart == StructureStart.DEFAULT) { return false; } - StructureFeature thiss = (StructureFeature) (Object)this; + StructureFeature thiss = (StructureFeature) (Object)this; world.getChunk(j, k).addStructureReference(thiss, chId); BlockBox box = structurestart.setBoundingBoxFromChildren(); // getBB @@ -65,18 +71,11 @@ public abstract class StructureFeatureMixin implements if (!wireOnly) { Registry> registry3 = world.getRegistryManager().get(Registry.STRUCTURE_FEATURE_KEY); - Registry registry = world.getRegistryManager().get(Registry.BIOME_KEY); world.method_36972(() -> { Objects.requireNonNull(thiss); return registry3.getKey(thiss).map(Object::toString).orElseGet(thiss::toString); }); - ImmutableMultimap, RegistryKey> immutableMultimap = generator.getStructuresConfig().getConfiguredStructureFeature((StructureFeature) (Object)this); - - Predicate predicate = (b) -> { - Objects.requireNonNull(immutableMultimap); - return registry.getKey(b).filter(immutableMultimap::containsValue).isPresent(); - }; - structurestart.generateStructure(world, world.getStructureAccessor(), generator, rand, predicate, box, new ChunkPos(j, k)); + structurestart.generateStructure(world, world.getStructureAccessor(), generator, rand, box, new ChunkPos(j, k)); } //structurestart.notifyPostProcessAt(new ChunkPos(j, k)); int i = Math.max(box.getBlockCountX(),box.getBlockCountZ())/16+1; @@ -108,21 +107,22 @@ public abstract class StructureFeatureMixin implements return true; } - private StructureStart forceStructureStart(ServerWorld worldIn, ChunkGenerator generator, Random rand, long packedChunkPos, Biome biome, FeatureConfig config) + private StructureStart forceStructureStart(ServerWorld worldIn, ChunkGenerator generator, Random rand, long packedChunkPos, Biome biome, C config) { ChunkPos chunkpos = new ChunkPos(packedChunkPos); BlockPos centerpos = chunkpos.getBlockPos(9, 0, 9); - StructureStart structurestart; + StructureStart structurestart; + StructureFeature thiss= (StructureFeature)(Object)this; Chunk ichunk = worldIn.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS, false); if (ichunk != null) { - structurestart = ichunk.getStructureStart((StructureFeature)(Object)this); + StructureStart structurestartt = ichunk.getStructureStart(thiss); - if (structurestart != null && structurestart != StructureStart.DEFAULT) + if (structurestartt != null && structurestartt != StructureStart.DEFAULT) { - return structurestart; + return (StructureStart) structurestartt; } } Biome biome_1 = biome; @@ -130,19 +130,29 @@ public abstract class StructureFeatureMixin implements biome_1 = generator.getBiomeForNoiseGen(BiomeCoords.fromBlock(centerpos.getX()), BiomeCoords.fromBlock(centerpos.getY()), BiomeCoords.fromBlock(centerpos.getZ())); - StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos,0,worldIn.getSeed()); - if (config == null) - config = new DefaultFeatureConfig(); - structurestart1.init(worldIn.getRegistryManager(), generator, worldIn.getStructureManager() , chunkpos, config, ichunk, b -> true); - structurestart = structurestart1.hasChildren() ? structurestart1 : StructureStart.DEFAULT; - if (structurestart.hasChildren()) + //if (config == null) + // config = (C) new DefaultFeatureConfig(); + + class_6626 lv = new class_6626(); + field_34929.generatePieces(lv, config, new class_6622.class_6623(worldIn.getRegistryManager(), generator, worldIn.getStructureManager(), chunkpos, b -> true, worldIn, Util.make(new ChunkRandom(), (chunkRandomx) -> { + chunkRandomx.setCarverSeed(worldIn.getSeed(), chunkpos.x, chunkpos.z); + }), worldIn.getSeed())); + StructureStart structurestart1 = new StructureStart<>(thiss, chunkpos, 0, lv.method_38714()); + + + //StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos,0,worldIn.getSeed()); + + //structurestart1.init(worldIn.getRegistryManager(), generator, worldIn.getStructureManager() , chunkpos, config, ichunk, b -> true); + //structurestart = structurestart1.hasChildren() ? structurestart1 : (StructureStart) StructureStart.DEFAULT; + + if (structurestart1.hasChildren()) { - worldIn.getChunk(chunkpos.x, chunkpos.z).setStructureStart((StructureFeature)(Object)this, structurestart); + worldIn.getChunk(chunkpos.x, chunkpos.z).setStructureStart(thiss, structurestart1); } //long2objectmap.put(packedChunkPos, structurestart); - return structurestart; + return structurestart1; } @Override diff --git a/src/main/java/carpet/utils/SpawnReporter.java b/src/main/java/carpet/utils/SpawnReporter.java index 9178781a..9bcb36f5 100644 --- a/src/main/java/carpet/utils/SpawnReporter.java +++ b/src/main/java/carpet/utils/SpawnReporter.java @@ -31,8 +31,10 @@ import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.gen.StructureAccessor; import net.minecraft.world.gen.chunk.ChunkGenerator; +import net.minecraft.world.gen.feature.NetherFortressFeature; import net.minecraft.world.gen.feature.StructureFeature; import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Arrays; @@ -424,8 +426,8 @@ public class SpawnReporter } // yeeted from SpawnHelper - temporary fix - private static List method_29950(ServerWorld serverWorld, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, SpawnGroup spawnGroup, BlockPos blockPos, /*@Nullable*/ Biome biome) { - return spawnGroup == SpawnGroup.MONSTER && serverWorld.getBlockState(blockPos.down()).getBlock() == Blocks.NETHER_BRICKS && structureAccessor.getStructureAt(blockPos, false, StructureFeature.FORTRESS).hasChildren() ? StructureFeature.FORTRESS.getMonsterSpawns().getEntries() : chunkGenerator.getEntitySpawnList(biome != null ? biome : serverWorld.getBiome(blockPos), structureAccessor, spawnGroup, blockPos).getEntries(); + private static List getSpawnEntries(ServerWorld world, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, SpawnGroup spawnGroup, BlockPos pos, @Nullable Biome biome) { + return SpawnHelper.shouldUseNetherFortressSpawns(pos, world, spawnGroup, structureAccessor) ? NetherFortressFeature.MONSTER_SPAWNS.getEntries() : chunkGenerator.getEntitySpawnList(biome != null ? biome : world.getBiome(pos), structureAccessor, spawnGroup, pos).getEntries(); } public static List report(BlockPos pos, ServerWorld worldIn) @@ -441,7 +443,7 @@ public class SpawnReporter for (SpawnGroup enumcreaturetype : SpawnGroup.values()) { String type_code = String.format("%s", enumcreaturetype).substring(0, 3); - List lst = method_29950(worldIn, worldIn.getStructureAccessor(), worldIn.getChunkManager().getChunkGenerator(), enumcreaturetype, pos, worldIn.getBiome(pos) );// ((ChunkGenerator)worldIn.getChunkManager().getChunkGenerator()).getEntitySpawnList(, worldIn.getStructureAccessor(), enumcreaturetype, pos); + List lst = getSpawnEntries(worldIn, worldIn.getStructureAccessor(), worldIn.getChunkManager().getChunkGenerator(), enumcreaturetype, pos, worldIn.getBiome(pos) );// ((ChunkGenerator)worldIn.getChunkManager().getChunkGenerator()).getEntitySpawnList(, worldIn.getStructureAccessor(), enumcreaturetype, pos); if (lst != null && !lst.isEmpty()) { for (SpawnSettings.SpawnEntry spawnEntry : lst)