21w38a
This commit is contained in:
1 parent
7b9e5e6feb
commit
e849cdf6c1
11 files changed
+182
-91
No files matched your search
@@ -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<SpawnSettings.SpawnEntry> 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;
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -15,8 +15,9 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(DesertPyramidFeature.class)
|
||||
public abstract class DesertPyramidFeatureMixin extends StructureFeature<DefaultFeatureConfig>
|
||||
public abstract class DesertPyramidFeatureMixin
|
||||
{
|
||||
/*
|
||||
private static final Pool<SpawnSettings.SpawnEntry> MONSTER_SPAWNS;
|
||||
|
||||
static
|
||||
@@ -39,5 +40,7 @@ public abstract class DesertPyramidFeatureMixin extends StructureFeature<Default
|
||||
}
|
||||
return SpawnSettings.EMPTY_ENTRY_POOL;
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -15,8 +15,9 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@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));
|
||||
|
||||
public EndCityFeatureMixin(Codec<DefaultFeatureConfig> codec)
|
||||
@@ -31,4 +32,5 @@ public abstract class EndCityFeatureMixin extends StructureFeature<DefaultFeatur
|
||||
return spawnList;
|
||||
return SpawnSettings.EMPTY_ENTRY_POOL;
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -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;
|
||||
@@ -11,7 +12,11 @@ import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.FlatChunkGenerator;
|
||||
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.SwampHutFeature;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import java.util.List;
|
||||
@@ -28,55 +33,61 @@ public abstract class FlatChunkGeneratorMixin extends ChunkGenerator
|
||||
@Override
|
||||
public Pool<SpawnSettings.SpawnEntry> 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);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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<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 && 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<C extends FeatureConfig> 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<C> 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<C extends FeatureConfig> 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<C> structurestart = forceStructureStart(world, generator, rand, chId, biome, config);
|
||||
if (structurestart == StructureStart.DEFAULT)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
StructureFeature<?> thiss = (StructureFeature) (Object)this;
|
||||
StructureFeature<C> thiss = (StructureFeature<C>) (Object)this;
|
||||
world.getChunk(j, k).addStructureReference(thiss, chId);
|
||||
|
||||
BlockBox box = structurestart.setBoundingBoxFromChildren(); // getBB
|
||||
@@ -65,18 +71,11 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
if (!wireOnly)
|
||||
{
|
||||
Registry<StructureFeature<?>> registry3 = world.getRegistryManager().get(Registry.STRUCTURE_FEATURE_KEY);
|
||||
Registry<Biome> registry = world.getRegistryManager().get(Registry.BIOME_KEY);
|
||||
world.method_36972(() -> {
|
||||
Objects.requireNonNull(thiss);
|
||||
return registry3.getKey(thiss).map(Object::toString).orElseGet(thiss::toString);
|
||||
});
|
||||
ImmutableMultimap<ConfiguredStructureFeature<?, ?>, RegistryKey<Biome>> immutableMultimap = generator.getStructuresConfig().getConfiguredStructureFeature((StructureFeature) (Object)this);
|
||||
|
||||
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.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<C extends FeatureConfig> implements
|
||||
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);
|
||||
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);
|
||||
|
||||
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;
|
||||
@@ -130,19 +130,29 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> 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<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);
|
||||
return structurestart;
|
||||
return structurestart1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user