1.18.2-pre
This commit is contained in:
1 parent
702022bce0
commit
c01ad9ce9d
20 files changed
+303
-422
No files matched your search
@@ -1,16 +0,0 @@
|
||||
package carpet.helpers;
|
||||
|
||||
import net.minecraft.util.random.WeightedRandomList;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
|
||||
public class CustomSpawnLists
|
||||
{
|
||||
public static final WeightedRandomList<MobSpawnSettings.SpawnerData> PYRAMID_SPAWNS = WeightedRandomList.create(new MobSpawnSettings.SpawnerData(EntityType.HUSK, 1, 1, 1));
|
||||
public static final WeightedRandomList<MobSpawnSettings.SpawnerData> SHULKER_SPAWNS = WeightedRandomList.create(new MobSpawnSettings.SpawnerData(EntityType.SHULKER, 10, 4, 4));
|
||||
public static final WeightedRandomList<MobSpawnSettings.SpawnerData> BASTION_SPAWNS = WeightedRandomList.create(
|
||||
new MobSpawnSettings.SpawnerData(EntityType.PIGLIN_BRUTE, 5, 1, 2),
|
||||
new MobSpawnSettings.SpawnerData(EntityType.PIGLIN, 10, 2, 4),
|
||||
new MobSpawnSettings.SpawnerData(EntityType.HOGLIN, 2, 1, 2)
|
||||
);
|
||||
}
|
||||
@@ -2,64 +2,52 @@ package carpet.helpers;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.ChunkGeneratorInterface;
|
||||
import carpet.fakes.PlacedFeatureInterface;
|
||||
import carpet.fakes.StructureFeatureInterface;
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.QuartPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.worldgen.ProcessorLists;
|
||||
import net.minecraft.data.worldgen.StructureFeatures;
|
||||
import net.minecraft.data.worldgen.placement.PlacementUtils;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.tags.BiomeTags;
|
||||
import net.minecraft.util.valueproviders.ConstantInt;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.StructureSettings;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||
//import net.minecraft.world.level.levelgen.feature.configurations.StructureFeatureConfiguration;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.JigsawConfiguration;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.SimpleRandomFeatureConfiguration;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration;
|
||||
import net.minecraft.world.level.levelgen.feature.featuresize.TwoLayersFeatureSize;
|
||||
import net.minecraft.world.level.levelgen.feature.foliageplacers.BlobFoliagePlacer;
|
||||
import net.minecraft.world.level.levelgen.feature.foliageplacers.FancyFoliagePlacer;
|
||||
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement;
|
||||
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
|
||||
import net.minecraft.world.level.levelgen.feature.treedecorators.BeehiveDecorator;
|
||||
import net.minecraft.world.level.levelgen.feature.trunkplacers.FancyTrunkPlacer;
|
||||
import net.minecraft.world.level.levelgen.feature.trunkplacers.StraightTrunkPlacer;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureCheckResult;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.placement.ConcentricRingsStructurePlacement;
|
||||
import net.minecraft.world.level.levelgen.structure.placement.StructurePlacement;
|
||||
|
||||
public class FeatureGenerator
|
||||
@@ -76,10 +64,7 @@ public class FeatureGenerator
|
||||
ConfiguredStructureFeature<?, ?> structureFeature = world.registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY).get(id);
|
||||
if (structureFeature != null)
|
||||
{
|
||||
return ((StructureFeatureInterface)structureFeature.feature).plopAnywhere(
|
||||
world, pos, world.getChunkSource().getGenerator(),
|
||||
false, world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).get(Biomes.PLAINS), structureFeature.config);
|
||||
|
||||
return plopAnywhere( structureFeature, world, pos, world.getChunkSource().getGenerator(), false);
|
||||
}
|
||||
|
||||
ConfiguredFeature<?, ?> configuredFeature = world.registryAccess().registryOrThrow(Registry.CONFIGURED_FEATURE_REGISTRY).get(id);
|
||||
@@ -98,12 +83,9 @@ public class FeatureGenerator
|
||||
StructureFeature<?> structure = Registry.STRUCTURE_FEATURE.get(id);
|
||||
if (structure != null)
|
||||
{
|
||||
ConfiguredStructureFeature<?,?> configuredStandard = getDefaultFeature(structure, world, pos, true);
|
||||
ConfiguredStructureFeature<?,?> configuredStandard = getDefaultFeature(structure, world, pos);
|
||||
if (configuredStandard != null)
|
||||
return ((StructureFeatureInterface)configuredStandard.feature).plopAnywhere(
|
||||
world, pos, world.getChunkSource().getGenerator(),
|
||||
false, world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).get(Biomes.PLAINS), configuredStandard.config);
|
||||
|
||||
return plopAnywhere(configuredStandard, world, pos, world.getChunkSource().getGenerator(), false);
|
||||
}
|
||||
Feature<?> feature = Registry.FEATURE.get(id);
|
||||
if (feature != null)
|
||||
@@ -132,14 +114,12 @@ public class FeatureGenerator
|
||||
if (configuredStructureFeature != null) return configuredStructureFeature;
|
||||
StructureFeature<?> structureFeature = Registry.STRUCTURE_FEATURE.get(id);
|
||||
if (structureFeature == null) return null;
|
||||
return getDefaultFeature(structureFeature, world, pos, true);
|
||||
return getDefaultFeature(structureFeature, world, pos);
|
||||
}
|
||||
|
||||
synchronized public static Boolean plopGrid(ConfiguredStructureFeature<?, ?> structureFeature, ServerLevel world, BlockPos pos)
|
||||
{
|
||||
return ((StructureFeatureInterface)structureFeature.feature).plopAnywhere(
|
||||
world, pos, world.getChunkSource().getGenerator(),
|
||||
true, world.getServer().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).get(net.minecraft.world.level.biome.Biomes.PLAINS), structureFeature.config);
|
||||
return plopAnywhere( structureFeature, world, pos, world.getChunkSource().getGenerator(), true);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
@@ -167,24 +147,19 @@ public class FeatureGenerator
|
||||
return simplePlop(new ConfiguredFeature<>(feature, config));
|
||||
}
|
||||
|
||||
private static Thing simplePlop(Holder<PlacedFeature> hpf)
|
||||
{
|
||||
return simplePlop(hpf.value().feature().value());
|
||||
}
|
||||
|
||||
private static Thing simpleTree(TreeConfiguration config)
|
||||
{
|
||||
//config.ignoreFluidCheck();
|
||||
return simplePlop(new ConfiguredFeature(Feature.TREE, config));
|
||||
}
|
||||
|
||||
private static Thing spawnCustomStructure(StructureFeature structure, FeatureConfiguration conf, ResourceKey<Biome> biome)
|
||||
private static Thing spawnCustomStructure(ConfiguredStructureFeature<?,?> structure)
|
||||
{
|
||||
return setupCustomStructure(structure, conf, biome, false);
|
||||
return setupCustomStructure(structure,false);
|
||||
}
|
||||
private static Thing setupCustomStructure(StructureFeature structure, FeatureConfiguration conf, ResourceKey<Biome> biome, boolean wireOnly)
|
||||
private static Thing setupCustomStructure(ConfiguredStructureFeature<?,?> structure, boolean wireOnly)
|
||||
{
|
||||
return (w, p) -> ((StructureFeatureInterface)structure).plopAnywhere(w, p, w.getChunkSource().getGenerator(), wireOnly, w.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).get(biome), conf);
|
||||
return (w, p) -> plopAnywhere(structure, w, p, w.getChunkSource().getGenerator(), wireOnly);
|
||||
}
|
||||
|
||||
public static Boolean spawn(String name, ServerLevel world, BlockPos pos)
|
||||
@@ -194,21 +169,19 @@ public class FeatureGenerator
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ConfiguredStructureFeature<?, ?> getDefaultFeature(StructureFeature<?> structure, ServerLevel world, BlockPos pos, boolean tryHard)
|
||||
private static ConfiguredStructureFeature<?, ?> getDefaultFeature(StructureFeature<?> structure, ServerLevel world, BlockPos pos)
|
||||
{
|
||||
var definedStructures = world.getChunkSource().getGenerator().getAllConfigurationsFor(structure);
|
||||
Holder<Biome> existingBiome = world.getBiome(pos);
|
||||
// would be nice to have a way to grab structures of this type for position
|
||||
|
||||
for (final Holder.Reference<ConfiguredStructureFeature<?, ?>> featureConfig : definedStructures) {
|
||||
final HolderSet<Biome> biomeAllowedForStructure = featureConfig.value().biomes();
|
||||
if (biomeAllowedForStructure.contains(existingBiome)) {
|
||||
return featureConfig.value();
|
||||
}
|
||||
Holder<Biome> existingBiome = world.getBiome(pos);
|
||||
ConfiguredStructureFeature<?, ?> result = null;
|
||||
for (var confstr : world.registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY).entrySet().stream().
|
||||
filter(cS -> cS.getValue().feature == structure).map(Map.Entry::getValue).toList())
|
||||
{
|
||||
result = confstr;
|
||||
if (confstr.biomes.contains(existingBiome)) return result;
|
||||
}
|
||||
if (!tryHard) return null;
|
||||
return world.registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY).entrySet().stream().
|
||||
filter(cS -> cS.getValue().feature == structure).
|
||||
findFirst().map(Map.Entry::getValue).orElse(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static ConfiguredFeature<?, ?> getDefaultFeature(Feature<?> feature, ServerLevel world, BlockPos pos, boolean tryHard)
|
||||
@@ -226,70 +199,35 @@ public class FeatureGenerator
|
||||
findFirst().map(Map.Entry::getValue).orElse(null);
|
||||
}
|
||||
|
||||
public static <T extends FeatureConfiguration> StructureStart shouldStructureStartAt(ServerLevel world, BlockPos pos, StructureFeature<T> structure, boolean computeBox)
|
||||
public static <T extends FeatureConfiguration> StructureStart shouldStructureStartAt(ServerLevel world, BlockPos pos, ConfiguredStructureFeature<T, ?> structure, boolean computeBox)
|
||||
{
|
||||
//if (structure == StructureFeature.STRONGHOLD)
|
||||
// return shouldStrongholdStartAt(world, pos, computeBox);
|
||||
long seed = world.getSeed();
|
||||
ChunkGenerator generator = world.getChunkSource().getGenerator();
|
||||
StructureSettings settings = generator.getSettings();
|
||||
StructurePlacement structureConfig = settings.getConfig(structure);
|
||||
|
||||
if (structureConfig instanceof ConcentricRingsStructurePlacement rings)
|
||||
{
|
||||
return shouldStrongholdStartAt(generator, rings, world, pos, computeBox);
|
||||
}
|
||||
|
||||
if (structureConfig == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ChunkGeneratorInterface cgi = (ChunkGeneratorInterface) generator;
|
||||
List<StructurePlacement> structureConfig = cgi.getPlacementsForFeatureCM(structure);
|
||||
ChunkPos chunkPos = new ChunkPos(pos);
|
||||
boolean couldPlace = structureConfig.stream().anyMatch(p -> p.isFeatureChunk(generator, chunkPos.x, chunkPos.z));
|
||||
if (!couldPlace) return null;
|
||||
|
||||
StructureFeatureManager structureManager = world.structureFeatureManager();
|
||||
StructureCheckResult isThere = structureManager.checkStructurePresence(chunkPos, structure, false);
|
||||
if (isThere == StructureCheckResult.START_NOT_PRESENT)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final HolderSet<Biome> structureBiomes = structure.biomes();
|
||||
|
||||
if (!structureConfig.isFeatureChunk(generator, chunkPos.x, chunkPos.z)) {
|
||||
return null;
|
||||
};
|
||||
for (final Holder.Reference<ConfiguredStructureFeature<?, ?>> featureConfig : generator.getAllConfigurationsFor(structure)) {
|
||||
final HolderSet<Biome> biomeAllowedForStructure = featureConfig.value().biomes();
|
||||
if (!computeBox) {
|
||||
if (biomeAllowedForStructure.contains(world.getBiome(pos))) {
|
||||
return StructureStart.INVALID_START;
|
||||
}
|
||||
}
|
||||
else {
|
||||
final StructureStart<?> filledStructure = featureConfig.value().generate(
|
||||
world.registryAccess(), generator, generator.getBiomeSource(), world.getStructureManager(),
|
||||
seed, chunkPos, 0, world, biomeAllowedForStructure::contains);
|
||||
if (filledStructure != null && filledStructure.isValid()) {
|
||||
return filledStructure;
|
||||
}
|
||||
if (!computeBox) {
|
||||
Holder<Biome> genBiome = generator.getNoiseBiome(QuartPos.fromBlock(pos.getX()), QuartPos.fromBlock(pos.getY()), QuartPos.fromBlock(pos.getZ()));
|
||||
if (structureBiomes.contains(genBiome) && structure.feature.canGenerate(
|
||||
world.registryAccess(), generator, generator.getBiomeSource(), world.getStructureManager(),
|
||||
seed, chunkPos, structure.config, world, structureBiomes::contains
|
||||
))
|
||||
{
|
||||
return StructureStart.INVALID_START;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static StructureStart<?> shouldStrongholdStartAt(ChunkGenerator generator, ConcentricRingsStructurePlacement rings, ServerLevel world, BlockPos pos, boolean computeBox)
|
||||
{
|
||||
final List<ChunkPos> positions = generator.getRingPositionsFor(rings);
|
||||
if (world.dimension() != Level.OVERWORLD || !positions.contains(new ChunkPos(pos))) return null;
|
||||
if (!computeBox) return StructureStart.INVALID_START;
|
||||
StructureSettings settings = generator.getSettings();
|
||||
StructurePlacement structureConfig = settings.getConfig(StructureFeature.STRONGHOLD);
|
||||
if (structureConfig != null) {
|
||||
final List<Holder.Reference<ConfiguredStructureFeature<?, ?>>> configurations = generator.getAllConfigurationsFor(StructureFeature.STRONGHOLD);
|
||||
final Set<Holder<Biome>> allowedBiomes = configurations.stream().flatMap(s -> s.value().biomes().stream()).distinct().collect(Collectors.toSet());
|
||||
StructureStart<?> filledStructure = StructureFeature.STRONGHOLD.generate(world.registryAccess(), generator, generator.getBiomeSource(),
|
||||
world.getStructureManager(), world.getSeed(), new ChunkPos(pos), 0, NoneFeatureConfiguration.INSTANCE, world, allowedBiomes::contains
|
||||
);
|
||||
if (filledStructure != null && filledStructure.isValid())
|
||||
else {
|
||||
final StructureStart filledStructure = structure.generate(
|
||||
world.registryAccess(), generator, generator.getBiomeSource(), world.getStructureManager(),
|
||||
seed, chunkPos, 0, world, structureBiomes::contains);
|
||||
if (filledStructure != null && filledStructure.isValid()) {
|
||||
return filledStructure;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -298,13 +236,12 @@ public class FeatureGenerator
|
||||
return new TreeConfiguration.TreeConfigurationBuilder(BlockStateProvider.simple(block), new StraightTrunkPlacer(i, j, k), BlockStateProvider.simple(block2), new BlobFoliagePlacer(ConstantInt.of(l), ConstantInt.of(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<>() {{
|
||||
|
||||
put("oak_bees", simpleTree( createTree(Blocks.OAK_LOG, Blocks.OAK_LEAVES, 4, 2, 0, 2).ignoreVines().decorators(List.of(new BeehiveDecorator(1.00F))).build()));
|
||||
put("fancy_oak_bees", simpleTree( (new TreeConfiguration.TreeConfigurationBuilder(BlockStateProvider.simple(Blocks.OAK_LOG), new FancyTrunkPlacer(3, 11, 0), BlockStateProvider.simple(Blocks.OAK_LEAVES), new FancyFoliagePlacer(ConstantInt.of(2), ConstantInt.of(4), 4), new TwoLayersFeatureSize(0, 0, 0, OptionalInt.of(4)))).ignoreVines().decorators(List.of(new BeehiveDecorator(1.00F))).build()));
|
||||
put("birch_bees", simpleTree( createTree(Blocks.BIRCH_LOG, Blocks.BIRCH_LEAVES, 5, 2, 0, 2).ignoreVines().decorators(List.of(new BeehiveDecorator(1.00F))).build()));
|
||||
|
||||
//put("coral_tree", simplePlop(Feature.CORAL_TREE.configured(FeatureConfiguration.NONE)));
|
||||
put("coral_tree", simplePlop(Feature.CORAL_TREE, FeatureConfiguration.NONE));
|
||||
|
||||
put("coral_claw", simplePlop(Feature.CORAL_CLAW, FeatureConfiguration.NONE));
|
||||
@@ -314,8 +251,7 @@ public class FeatureGenerator
|
||||
PlacementUtils.inlinePlaced(Feature.CORAL_CLAW, FeatureConfiguration.NONE),
|
||||
PlacementUtils.inlinePlaced(Feature.CORAL_MUSHROOM, FeatureConfiguration.NONE)
|
||||
))));
|
||||
put("bastion_remnant_units", spawnCustomStructure(
|
||||
StructureFeature.BASTION_REMNANT,
|
||||
put("bastion_remnant_units", spawnCustomStructure(StructureFeature.BASTION_REMNANT.configured(
|
||||
new JigsawConfiguration(Holder.direct(new StructureTemplatePool(
|
||||
new ResourceLocation("bastion/starts"),
|
||||
new ResourceLocation("empty"),
|
||||
@@ -324,10 +260,9 @@ public class FeatureGenerator
|
||||
),
|
||||
StructureTemplatePool.Projection.RIGID
|
||||
)), 6),
|
||||
Biomes.NETHER_WASTES
|
||||
BiomeTags.HAS_BASTION_REMNANT)
|
||||
));
|
||||
put("bastion_remnant_hoglin_stable", spawnCustomStructure(
|
||||
StructureFeature.BASTION_REMNANT,
|
||||
put("bastion_remnant_hoglin_stable", spawnCustomStructure(StructureFeature.BASTION_REMNANT.configured(
|
||||
new JigsawConfiguration(Holder.direct(new StructureTemplatePool(
|
||||
new ResourceLocation("bastion/starts"),
|
||||
new ResourceLocation("empty"),
|
||||
@@ -336,10 +271,9 @@ public class FeatureGenerator
|
||||
),
|
||||
StructureTemplatePool.Projection.RIGID
|
||||
)), 6),
|
||||
Biomes.NETHER_WASTES
|
||||
BiomeTags.HAS_BASTION_REMNANT)
|
||||
));
|
||||
put("bastion_remnant_treasure", spawnCustomStructure(
|
||||
StructureFeature.BASTION_REMNANT,
|
||||
put("bastion_remnant_treasure", spawnCustomStructure(StructureFeature.BASTION_REMNANT.configured(
|
||||
new JigsawConfiguration(Holder.direct(new StructureTemplatePool(
|
||||
new ResourceLocation("bastion/starts"),
|
||||
new ResourceLocation("empty"),
|
||||
@@ -348,10 +282,9 @@ public class FeatureGenerator
|
||||
),
|
||||
StructureTemplatePool.Projection.RIGID
|
||||
)), 6),
|
||||
Biomes.NETHER_WASTES
|
||||
BiomeTags.HAS_BASTION_REMNANT)
|
||||
));
|
||||
put("bastion_remnant_bridge", spawnCustomStructure(
|
||||
StructureFeature.BASTION_REMNANT,
|
||||
put("bastion_remnant_bridge", spawnCustomStructure(StructureFeature.BASTION_REMNANT.configured(
|
||||
new JigsawConfiguration(Holder.direct(new StructureTemplatePool(
|
||||
new ResourceLocation("bastion/starts"),
|
||||
new ResourceLocation("empty"),
|
||||
@@ -360,8 +293,66 @@ public class FeatureGenerator
|
||||
),
|
||||
StructureTemplatePool.Projection.RIGID
|
||||
)), 6),
|
||||
Biomes.NETHER_WASTES
|
||||
BiomeTags.HAS_BASTION_REMNANT)
|
||||
));
|
||||
}};
|
||||
|
||||
|
||||
public static boolean plopAnywhere(ConfiguredStructureFeature<?, ?> structure, ServerLevel world, BlockPos pos, ChunkGenerator generator, boolean wireOnly)
|
||||
{
|
||||
if (world.isClientSide())
|
||||
return false;
|
||||
CarpetSettings.skipGenerationChecks.set(true);
|
||||
try
|
||||
{
|
||||
StructureStart start = structure.generate(world.registryAccess(), generator, generator.getBiomeSource(), world.getStructureManager(), world.getSeed(), new ChunkPos(pos), 0, world, b -> true );
|
||||
if (start == StructureStart.INVALID_START)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Random rand = new Random(world.getRandom().nextInt());
|
||||
int j = pos.getX() >> 4;
|
||||
int k = pos.getZ() >> 4;
|
||||
long chId = ChunkPos.asLong(j, k);
|
||||
|
||||
world.getChunk(j, k).addReferenceForFeature(structure, chId);
|
||||
|
||||
BoundingBox box = start.getBoundingBox();
|
||||
|
||||
if (!wireOnly)
|
||||
{
|
||||
Registry<ConfiguredStructureFeature<?, ?>> registry3 = world.registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY);
|
||||
world.setCurrentlyGenerating(() -> {
|
||||
Objects.requireNonNull(structure);
|
||||
return registry3.getResourceKey(structure).map(Object::toString).orElseGet(structure::toString);
|
||||
});
|
||||
start.placeInChunk(world, world.structureFeatureManager(), generator, rand, box, new ChunkPos(j, k));
|
||||
}
|
||||
//structurestart.notifyPostProcessAt(new ChunkPos(j, k));
|
||||
int i = Math.max(box.getXSpan(),box.getZSpan())/16+1;
|
||||
|
||||
//int i = getRadius();
|
||||
for (int k1 = j - i; k1 <= j + i; ++k1)
|
||||
{
|
||||
for (int l1 = k - i; l1 <= k + i; ++l1)
|
||||
{
|
||||
if (k1 == j && l1 == k) continue;
|
||||
if (box.intersects(k1<<4, l1<<4, (k1<<4) + 15, (l1<<4) + 15))
|
||||
{
|
||||
world.getChunk(k1, l1).addReferenceForFeature(structure, chId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception booboo)
|
||||
{
|
||||
CarpetSettings.LOG.error("Unknown Exception while plopping structure: "+booboo, booboo);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
CarpetSettings.skipGenerationChecks.set(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user