This commit is contained in:
gnembon committed 2021-09-24 09:29:13 -03:00
1 parent 7b9e5e6feb
commit e849cdf6c1
11 files changed
+182 -91

No files matched your search

+3 -3
View File
@@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/use # check these on https://fabricmc.net/use
# or better: https://modmuss50.me/fabric.html # or better: https://modmuss50.me/fabric.html
minecraft_version=21w37a minecraft_version=21w38a
yarn_mappings=21w37a+build.13 yarn_mappings=21w38a+build.2
loader_version=0.11.7 loader_version=0.11.7
fabric_version=0.40.3+1.18 fabric_version=0.40.4+1.18
# Mod Properties # Mod Properties
mod_version = 1.4.46 mod_version = 1.4.46
@@ -10,8 +10,8 @@ import net.minecraft.world.gen.random.ChunkRandom;
import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.feature.FeatureConfig; import net.minecraft.world.gen.feature.FeatureConfig;
public interface StructureFeatureInterface<C> public interface StructureFeatureInterface<C extends FeatureConfig>
{ {
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); boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, ChunkPos chpos, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView);
} }
@@ -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<SpawnSettings.SpawnEntry> PYRAMID_SPAWNS = Pool.of(new SpawnSettings.SpawnEntry(EntityType.HUSK, 1, 1, 1));
public static final Pool<SpawnSettings.SpawnEntry> SHULKER_SPAWNS = Pool.of(new SpawnSettings.SpawnEntry(EntityType.SHULKER, 10, 4, 4));
public static final Pool<SpawnSettings.SpawnEntry> 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)
);
}
@@ -3,6 +3,8 @@ package carpet.helpers;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import carpet.fakes.StructureFeatureInterface; import carpet.fakes.StructureFeatureInterface;
import com.mojang.datafixers.util.Pair; 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.server.world.ServerWorld;
import net.minecraft.structure.StructureManager; import net.minecraft.structure.StructureManager;
import net.minecraft.structure.StructureStart; import net.minecraft.structure.StructureStart;
@@ -12,18 +14,19 @@ import net.minecraft.structure.processor.StructureProcessorLists;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.intprovider.ConstantIntProvider;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey; import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeKeys; import net.minecraft.world.biome.BiomeKeys;
import net.minecraft.world.biome.BuiltinBiomes; 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.random.ChunkRandom;
import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.chunk.StructureConfig; 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.ConfiguredFeature;
import net.minecraft.world.gen.feature.ConfiguredFeatures;
import net.minecraft.world.gen.feature.ConfiguredStructureFeature; import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.FeatureConfig; 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.StructureFeature;
import net.minecraft.world.gen.feature.StructurePoolFeatureConfig; import net.minecraft.world.gen.feature.StructurePoolFeatureConfig;
import net.minecraft.world.gen.feature.TreeFeatureConfig; 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.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.OptionalInt;
import java.util.function.Supplier; import java.util.function.Supplier;
public class FeatureGenerator public class FeatureGenerator
@@ -161,7 +169,7 @@ public class FeatureGenerator
private static ConfiguredStructureFeature<?, ?> getDefaultFeature(StructureFeature<?> structure, ServerWorld world, BlockPos pos, boolean tryHard) 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)); var optinalBiome = world.getRegistryManager().get(Registry.BIOME_KEY).getKey(world.getBiome(pos));
if (optinalBiome.isPresent()) if (optinalBiome.isPresent())
for (var configureStructure: definedStructures.inverse().get(optinalBiome.get())) 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)); Biome biome = world.getBiome(new BlockPos(chunkPos.getStartX() + 9, 0, chunkPos.getStartZ() + 9));
ConfiguredStructureFeature<?, ?> configuredFeature = getDefaultFeature(structure, world, pos, false); ConfiguredStructureFeature<?, ?> configuredFeature = getDefaultFeature(structure, world, pos, false);
if (configuredFeature == null || configuredFeature.config == null) return null; 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 // 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. // 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 (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; if (!computeBox) return StructureStart.DEFAULT;
StructureManager manager = world.getStructureManager(); 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<C> structurestart1 = new StructureStart<>(thiss, chunkpos, 0, lv.method_38714());
StructureStart<T> structureStart3 = structure.getStructureStartFactory().create((StructureFeature<T>) configuredFeature.feature, chunkPos, 0, seed); StructureStart<T> structureStart3 = structure.getStructureStartFactory().create((StructureFeature<T>) configuredFeature.feature, chunkPos, 0, seed);
synchronized (boo) { synchronized (boo) {
structureStart3.init(world.getRegistryManager(), generator, manager, chunkPos, (T) configuredFeature.config, world, (b) -> b == biome); structureStart3.init(world.getRegistryManager(), generator, manager, chunkPos, (T) configuredFeature.config, world, (b) -> b == biome);
} }
if (!structureStart3.hasChildren()) return null; if (!structureStart3.hasChildren()) return null;
return structureStart3; return structureStart3;
} }*/
return null; 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<String, Thing> featureMap = new HashMap<String, Thing>() {{ public static final Map<String, Thing> featureMap = new HashMap<String, Thing>() {{
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("oak_bees", simpleTree( createTree(Blocks.OAK_LOG, Blocks.OAK_LEAVES, 4, 2, 0, 2).ignoreVines().decorators(List.of(new BeehiveTreeDecorator(1.00F))).build()));
put("birch_bees", simpleTree(ConfiguredFeatures.BIRCH.getConfig().setTreeDecorators(List.of(new BeehiveTreeDecorator(1.0F))))); 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_tree", simplePlop(Feature.CORAL_TREE.configure(FeatureConfig.DEFAULT)));
put("coral_claw", simplePlop(Feature.CORAL_CLAW.configure(FeatureConfig.DEFAULT))); put("coral_claw", simplePlop(Feature.CORAL_CLAW.configure(FeatureConfig.DEFAULT)));
put("coral_mushroom", simplePlop(Feature.CORAL_MUSHROOM.configure(FeatureConfig.DEFAULT))); put("coral_mushroom", simplePlop(Feature.CORAL_MUSHROOM.configure(FeatureConfig.DEFAULT)));
@@ -18,8 +18,9 @@ import java.util.Collections;
import java.util.List; import java.util.List;
@Mixin(BastionRemnantFeature.class) @Mixin(BastionRemnantFeature.class)
public abstract class BastionRemnantFeatureMixin extends JigsawFeature public abstract class BastionRemnantFeatureMixin //extends JigsawFeature
{ {
/*
private static final Pool<SpawnSettings.SpawnEntry> spawnList = Pool.of( private static final Pool<SpawnSettings.SpawnEntry> spawnList = Pool.of(
new SpawnSettings.SpawnEntry(EntityType.PIGLIN_BRUTE, 5, 1, 2), new SpawnSettings.SpawnEntry(EntityType.PIGLIN_BRUTE, 5, 1, 2),
new SpawnSettings.SpawnEntry(EntityType.PIGLIN, 10, 2, 4), new SpawnSettings.SpawnEntry(EntityType.PIGLIN, 10, 2, 4),
@@ -38,4 +39,5 @@ public abstract class BastionRemnantFeatureMixin extends JigsawFeature
return spawnList; return spawnList;
return SpawnSettings.EMPTY_ENTRY_POOL; return SpawnSettings.EMPTY_ENTRY_POOL;
} }
*/
} }
@@ -15,8 +15,9 @@ import java.util.Collections;
import java.util.List; import java.util.List;
@Mixin(DesertPyramidFeature.class) @Mixin(DesertPyramidFeature.class)
public abstract class DesertPyramidFeatureMixin extends StructureFeature<DefaultFeatureConfig> public abstract class DesertPyramidFeatureMixin
{ {
/*
private static final Pool<SpawnSettings.SpawnEntry> MONSTER_SPAWNS; private static final Pool<SpawnSettings.SpawnEntry> MONSTER_SPAWNS;
static static
@@ -39,5 +40,7 @@ public abstract class DesertPyramidFeatureMixin extends StructureFeature<Default
} }
return SpawnSettings.EMPTY_ENTRY_POOL; return SpawnSettings.EMPTY_ENTRY_POOL;
} }
*/
} }
@@ -15,8 +15,9 @@ import java.util.Collections;
import java.util.List; import java.util.List;
@Mixin(EndCityFeature.class) @Mixin(EndCityFeature.class)
public abstract class EndCityFeatureMixin extends StructureFeature<DefaultFeatureConfig> public abstract class EndCityFeatureMixin //extends StructureFeature<DefaultFeatureConfig>
{ {
/*
private static final Pool<SpawnSettings.SpawnEntry> spawnList = Pool.of(new SpawnSettings.SpawnEntry(EntityType.SHULKER, 10, 4, 4)); private static final Pool<SpawnSettings.SpawnEntry> spawnList = Pool.of(new SpawnSettings.SpawnEntry(EntityType.SHULKER, 10, 4, 4));
public EndCityFeatureMixin(Codec<DefaultFeatureConfig> codec) public EndCityFeatureMixin(Codec<DefaultFeatureConfig> codec)
@@ -31,4 +32,5 @@ public abstract class EndCityFeatureMixin extends StructureFeature<DefaultFeatur
return spawnList; return spawnList;
return SpawnSettings.EMPTY_ENTRY_POOL; return SpawnSettings.EMPTY_ENTRY_POOL;
} }
*/
} }
@@ -1,6 +1,7 @@
package carpet.mixins; package carpet.mixins;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import carpet.helpers.CustomSpawnLists;
import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.collection.Pool; import net.minecraft.util.collection.Pool;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -11,7 +12,11 @@ import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.chunk.FlatChunkGenerator; import net.minecraft.world.gen.chunk.FlatChunkGenerator;
import net.minecraft.world.gen.chunk.StructuresConfig; import net.minecraft.world.gen.chunk.StructuresConfig;
import net.minecraft.world.gen.feature.NetherFortressFeature;
import net.minecraft.world.gen.feature.OceanMonumentFeature;
import net.minecraft.world.gen.feature.PillagerOutpostFeature;
import net.minecraft.world.gen.feature.StructureFeature; import net.minecraft.world.gen.feature.StructureFeature;
import net.minecraft.world.gen.feature.SwampHutFeature;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import java.util.List; import java.util.List;
@@ -28,55 +33,61 @@ public abstract class FlatChunkGeneratorMixin extends ChunkGenerator
@Override @Override
public Pool<SpawnSettings.SpawnEntry> getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos) public Pool<SpawnSettings.SpawnEntry> getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos)
{ {
if (CarpetSettings.flatWorldStructureSpawning) if (!CarpetSettings.flatWorldStructureSpawning) return super.getEntitySpawnList(biome, accessor, group, pos);
{
if (accessor.getStructureAt(pos, true, StructureFeature.SWAMP_HUT).hasChildren())
{ //swamp hut
if (group == SpawnGroup.MONSTER)
{
return StructureFeature.SWAMP_HUT.getMonsterSpawns();
}
if (group == SpawnGroup.CREATURE) // vanila noise one
{ if (accessor.getStructureAt(pos, true, StructureFeature.SWAMP_HUT).hasChildren()) {
return StructureFeature.SWAMP_HUT.getCreatureSpawns(); 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 CustomSpawnLists.SHULKER_SPAWNS;
{
return StructureFeature.DESERT_PYRAMID.getMonsterSpawns();
}
} }
}
if (accessor.getStructureAt(pos, false, StructureFeature.MONUMENT).hasChildren()) if (CarpetSettings.piglinsSpawningInBastions)
{
if (accessor.getStructureAt(pos, true, StructureFeature.BASTION_REMNANT).hasChildren())
{ {
return StructureFeature.MONUMENT.getMonsterSpawns(); return CustomSpawnLists.BASTION_SPAWNS;
}
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 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);
} }
} }
@@ -1,6 +1,7 @@
package carpet.mixins; package carpet.mixins;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import carpet.helpers.CustomSpawnLists;
import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.collection.Pool; import net.minecraft.util.collection.Pool;
import net.minecraft.util.math.BlockPos; 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) @Inject(method = "getEntitySpawnList", at = @At("HEAD"), cancellable = true)
private void isInsidePyramid(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos, CallbackInfoReturnable<Pool<SpawnSettings.SpawnEntry>> cir) private void isInsidePyramid(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos, CallbackInfoReturnable<Pool<SpawnSettings.SpawnEntry>> 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)
if (CarpetSettings.shulkerSpawningInEndCities && SpawnGroup.MONSTER == group)
{
if (accessor.getStructureAt(pos, true, StructureFeature.END_CITY).hasChildren())
{ {
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);
}
} }
} }
} }
@@ -3,8 +3,11 @@ package carpet.mixins;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import carpet.fakes.StructureFeatureInterface; import carpet.fakes.StructureFeatureInterface;
import com.google.common.collect.ImmutableMultimap; 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.server.world.ServerWorld;
import net.minecraft.structure.StructureStart; import net.minecraft.structure.StructureStart;
import net.minecraft.util.Util;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.BlockBox; 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.DefaultFeatureConfig;
import net.minecraft.world.gen.feature.FeatureConfig; import net.minecraft.world.gen.feature.FeatureConfig;
import net.minecraft.world.gen.feature.StructureFeature; import net.minecraft.world.gen.feature.StructureFeature;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@@ -34,14 +38,16 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
{ {
@Shadow public abstract String getName(); @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 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 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<C> field_34929;
@Override @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()) if (world.isClient())
return false; return false;
@@ -52,12 +58,12 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
int j = pos.getX() >> 4; int j = pos.getX() >> 4;
int k = pos.getZ() >> 4; int k = pos.getZ() >> 4;
long chId = ChunkPos.toLong(j, k); long chId = ChunkPos.toLong(j, k);
StructureStart structurestart = forceStructureStart(world, generator, rand, chId, biome, config); StructureStart<C> structurestart = forceStructureStart(world, generator, rand, chId, biome, config);
if (structurestart == StructureStart.DEFAULT) if (structurestart == StructureStart.DEFAULT)
{ {
return false; return false;
} }
StructureFeature<?> thiss = (StructureFeature) (Object)this; StructureFeature<C> thiss = (StructureFeature<C>) (Object)this;
world.getChunk(j, k).addStructureReference(thiss, chId); world.getChunk(j, k).addStructureReference(thiss, chId);
BlockBox box = structurestart.setBoundingBoxFromChildren(); // getBB BlockBox box = structurestart.setBoundingBoxFromChildren(); // getBB
@@ -65,18 +71,11 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
if (!wireOnly) if (!wireOnly)
{ {
Registry<StructureFeature<?>> registry3 = world.getRegistryManager().get(Registry.STRUCTURE_FEATURE_KEY); Registry<StructureFeature<?>> registry3 = world.getRegistryManager().get(Registry.STRUCTURE_FEATURE_KEY);
Registry<Biome> registry = world.getRegistryManager().get(Registry.BIOME_KEY);
world.method_36972(() -> { world.method_36972(() -> {
Objects.requireNonNull(thiss); Objects.requireNonNull(thiss);
return registry3.getKey(thiss).map(Object::toString).orElseGet(thiss::toString); return registry3.getKey(thiss).map(Object::toString).orElseGet(thiss::toString);
}); });
ImmutableMultimap<ConfiguredStructureFeature<?, ?>, RegistryKey<Biome>> immutableMultimap = generator.getStructuresConfig().getConfiguredStructureFeature((StructureFeature) (Object)this); structurestart.generateStructure(world, world.getStructureAccessor(), generator, rand, box, new ChunkPos(j, k));
Predicate<Biome> 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.notifyPostProcessAt(new ChunkPos(j, k)); //structurestart.notifyPostProcessAt(new ChunkPos(j, k));
int i = Math.max(box.getBlockCountX(),box.getBlockCountZ())/16+1; int i = Math.max(box.getBlockCountX(),box.getBlockCountZ())/16+1;
@@ -108,21 +107,22 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
return true; return true;
} }
private StructureStart forceStructureStart(ServerWorld worldIn, ChunkGenerator generator, Random rand, long packedChunkPos, Biome biome, FeatureConfig config) private StructureStart<C> forceStructureStart(ServerWorld worldIn, ChunkGenerator generator, Random rand, long packedChunkPos, Biome biome, C config)
{ {
ChunkPos chunkpos = new ChunkPos(packedChunkPos); ChunkPos chunkpos = new ChunkPos(packedChunkPos);
BlockPos centerpos = chunkpos.getBlockPos(9, 0, 9); BlockPos centerpos = chunkpos.getBlockPos(9, 0, 9);
StructureStart structurestart; StructureStart<C> structurestart;
StructureFeature<C> thiss= (StructureFeature<C>)(Object)this;
Chunk ichunk = worldIn.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS, false); Chunk ichunk = worldIn.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS, false);
if (ichunk != null) 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<C>) structurestartt;
} }
} }
Biome biome_1 = biome; Biome biome_1 = biome;
@@ -130,19 +130,29 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
biome_1 = generator.getBiomeForNoiseGen(BiomeCoords.fromBlock(centerpos.getX()), biome_1 = generator.getBiomeForNoiseGen(BiomeCoords.fromBlock(centerpos.getX()),
BiomeCoords.fromBlock(centerpos.getY()), BiomeCoords.fromBlock(centerpos.getZ())); 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<C> 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<C>) 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); //long2objectmap.put(packedChunkPos, structurestart);
return structurestart; return structurestart1;
} }
@Override @Override
@@ -31,8 +31,10 @@ import net.minecraft.world.biome.SpawnSettings;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.StructureAccessor; import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.feature.NetherFortressFeature;
import net.minecraft.world.gen.feature.StructureFeature; import net.minecraft.world.gen.feature.StructureFeature;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -424,8 +426,8 @@ public class SpawnReporter
} }
// yeeted from SpawnHelper - temporary fix // yeeted from SpawnHelper - temporary fix
private static List<SpawnSettings.SpawnEntry> method_29950(ServerWorld serverWorld, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, SpawnGroup spawnGroup, BlockPos blockPos, /*@Nullable*/ Biome biome) { private static List<SpawnSettings.SpawnEntry> getSpawnEntries(ServerWorld world, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, SpawnGroup spawnGroup, BlockPos pos, @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(); 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<BaseText> report(BlockPos pos, ServerWorld worldIn) public static List<BaseText> report(BlockPos pos, ServerWorld worldIn)
@@ -441,7 +443,7 @@ public class SpawnReporter
for (SpawnGroup enumcreaturetype : SpawnGroup.values()) for (SpawnGroup enumcreaturetype : SpawnGroup.values())
{ {
String type_code = String.format("%s", enumcreaturetype).substring(0, 3); String type_code = String.format("%s", enumcreaturetype).substring(0, 3);
List<SpawnSettings.SpawnEntry> lst = method_29950(worldIn, worldIn.getStructureAccessor(), worldIn.getChunkManager().getChunkGenerator(), enumcreaturetype, pos, worldIn.getBiome(pos) );// ((ChunkGenerator)worldIn.getChunkManager().getChunkGenerator()).getEntitySpawnList(, worldIn.getStructureAccessor(), enumcreaturetype, pos); List<SpawnSettings.SpawnEntry> 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()) if (lst != null && !lst.isEmpty())
{ {
for (SpawnSettings.SpawnEntry spawnEntry : lst) for (SpawnSettings.SpawnEntry spawnEntry : lst)