1.4.87 for 22w44a
This commit is contained in:
1 parent
c51f59c799
commit
4be362e58b
20 files changed
+236
-185
No files matched your search
@@ -11,13 +11,16 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.QuartPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.data.worldgen.Pools;
|
||||
import net.minecraft.data.worldgen.ProcessorLists;
|
||||
import net.minecraft.data.worldgen.placement.PlacementUtils;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@@ -56,15 +59,16 @@ import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.placement.StructurePlacement;
|
||||
import net.minecraft.world.level.levelgen.structure.structures.JigsawStructure;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList;
|
||||
|
||||
public class FeatureGenerator
|
||||
{
|
||||
synchronized public static Boolean plop(String featureName, ServerLevel world, BlockPos pos)
|
||||
{
|
||||
Thing custom = featureMap.get(featureName);
|
||||
Function<ServerLevel, Thing> custom = featureMap.get(featureName);
|
||||
if (custom != null)
|
||||
{
|
||||
return custom.plop(world, pos);
|
||||
return custom.apply(world).plop(world, pos);
|
||||
}
|
||||
ResourceLocation id = new ResourceLocation(featureName);
|
||||
Structure structure = world.registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY).get(id);
|
||||
@@ -206,7 +210,7 @@ public class FeatureGenerator
|
||||
ChunkGeneratorInterface cgi = (ChunkGeneratorInterface) generator;
|
||||
List<StructurePlacement> structureConfig = cgi.getPlacementsForFeatureCM(world, structure);
|
||||
ChunkPos chunkPos = new ChunkPos(pos);
|
||||
boolean couldPlace = structureConfig.stream().anyMatch(p -> p.isStructureChunk(generator, seed, world.getSeed(), chunkPos.x, chunkPos.z));
|
||||
boolean couldPlace = structureConfig.stream().anyMatch(p -> p.isStructureChunk(world.getChunkSource().getGeneratorState(), chunkPos.x, chunkPos.z));
|
||||
if (!couldPlace) return null;
|
||||
|
||||
final HolderSet<Biome> structureBiomes = structure.biomes();
|
||||
@@ -236,101 +240,138 @@ 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<>() {{
|
||||
public static final Map<String, Function<ServerLevel, 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("oak_bees", l -> 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", l -> 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", l -> 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, FeatureConfiguration.NONE));
|
||||
put("coral_tree", l -> simplePlop(Feature.CORAL_TREE, FeatureConfiguration.NONE));
|
||||
|
||||
put("coral_claw", simplePlop(Feature.CORAL_CLAW, FeatureConfiguration.NONE));
|
||||
put("coral_mushroom", simplePlop(Feature.CORAL_MUSHROOM, FeatureConfiguration.NONE));
|
||||
put("coral", simplePlop(Feature.SIMPLE_RANDOM_SELECTOR, new SimpleRandomFeatureConfiguration(HolderSet.direct(
|
||||
put("coral_claw", l -> simplePlop(Feature.CORAL_CLAW, FeatureConfiguration.NONE));
|
||||
put("coral_mushroom", l -> simplePlop(Feature.CORAL_MUSHROOM, FeatureConfiguration.NONE));
|
||||
put("coral", l -> simplePlop(Feature.SIMPLE_RANDOM_SELECTOR, new SimpleRandomFeatureConfiguration(HolderSet.direct(
|
||||
PlacementUtils.inlinePlaced(Feature.CORAL_TREE, FeatureConfiguration.NONE),
|
||||
PlacementUtils.inlinePlaced(Feature.CORAL_CLAW, FeatureConfiguration.NONE),
|
||||
PlacementUtils.inlinePlaced(Feature.CORAL_MUSHROOM, FeatureConfiguration.NONE)
|
||||
))));
|
||||
put("bastion_remnant_units", spawnCustomStructure(
|
||||
new JigsawStructure( new Structure.StructureSettings(
|
||||
BuiltinRegistries.BIOME.getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
TerrainAdjustment.NONE
|
||||
),
|
||||
Holder.direct(new StructureTemplatePool(
|
||||
new ResourceLocation("bastion/starts"),
|
||||
new ResourceLocation("empty"),
|
||||
ImmutableList.of(
|
||||
Pair.of(StructurePoolElement.single("bastion/units/air_base", ProcessorLists.BASTION_GENERIC_DEGRADATION), 1)
|
||||
),
|
||||
StructureTemplatePool.Projection.RIGID
|
||||
)),
|
||||
6,
|
||||
ConstantHeight.of(VerticalAnchor.absolute(33)),
|
||||
false
|
||||
)
|
||||
));
|
||||
put("bastion_remnant_hoglin_stable", spawnCustomStructure(
|
||||
new JigsawStructure( new Structure.StructureSettings(
|
||||
BuiltinRegistries.BIOME.getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
TerrainAdjustment.NONE
|
||||
),
|
||||
Holder.direct(new StructureTemplatePool(
|
||||
new ResourceLocation("bastion/starts"),
|
||||
new ResourceLocation("empty"),
|
||||
ImmutableList.of(
|
||||
Pair.of(StructurePoolElement.single("bastion/hoglin_stable/air_base", ProcessorLists.BASTION_GENERIC_DEGRADATION), 1)
|
||||
),
|
||||
StructureTemplatePool.Projection.RIGID
|
||||
)),
|
||||
6,
|
||||
ConstantHeight.of(VerticalAnchor.absolute(33)),
|
||||
false
|
||||
)
|
||||
));
|
||||
put("bastion_remnant_treasure", spawnCustomStructure(
|
||||
new JigsawStructure( new Structure.StructureSettings(
|
||||
BuiltinRegistries.BIOME.getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
TerrainAdjustment.NONE
|
||||
),
|
||||
Holder.direct(new StructureTemplatePool(
|
||||
new ResourceLocation("bastion/starts"),
|
||||
new ResourceLocation("empty"),
|
||||
ImmutableList.of(
|
||||
Pair.of(StructurePoolElement.single("bastion/treasure/big_air_full", ProcessorLists.BASTION_GENERIC_DEGRADATION), 1)
|
||||
),
|
||||
StructureTemplatePool.Projection.RIGID
|
||||
)),
|
||||
6,
|
||||
ConstantHeight.of(VerticalAnchor.absolute(33)),
|
||||
false
|
||||
)
|
||||
));
|
||||
put("bastion_remnant_bridge", spawnCustomStructure(
|
||||
new JigsawStructure( new Structure.StructureSettings(
|
||||
BuiltinRegistries.BIOME.getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
TerrainAdjustment.NONE
|
||||
),
|
||||
Holder.direct(new StructureTemplatePool(
|
||||
new ResourceLocation("bastion/starts"),
|
||||
new ResourceLocation("empty"),
|
||||
ImmutableList.of(
|
||||
Pair.of(StructurePoolElement.single("bastion/bridge/starting_pieces/entrance_base", ProcessorLists.BASTION_GENERIC_DEGRADATION), 1)
|
||||
),
|
||||
StructureTemplatePool.Projection.RIGID
|
||||
)),
|
||||
6,
|
||||
ConstantHeight.of(VerticalAnchor.absolute(33)),
|
||||
false
|
||||
)
|
||||
));
|
||||
put("bastion_remnant_units", l -> {
|
||||
RegistryAccess regs = l.registryAccess();
|
||||
|
||||
final HolderGetter<StructureProcessorList> processorLists = regs.lookupOrThrow(Registry.PROCESSOR_LIST_REGISTRY);
|
||||
final Holder<StructureProcessorList> bastionGenericDegradation = processorLists.getOrThrow(ProcessorLists.BASTION_GENERIC_DEGRADATION);
|
||||
|
||||
final HolderGetter<StructureTemplatePool> pools = regs.lookupOrThrow(Registry.TEMPLATE_POOL_REGISTRY);
|
||||
final Holder<StructureTemplatePool> empty = pools.getOrThrow(Pools.EMPTY);
|
||||
|
||||
|
||||
return spawnCustomStructure(
|
||||
new JigsawStructure(new Structure.StructureSettings(
|
||||
l.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
TerrainAdjustment.NONE
|
||||
),
|
||||
Holder.direct(new StructureTemplatePool(
|
||||
empty,
|
||||
ImmutableList.of(
|
||||
Pair.of(StructurePoolElement.single("bastion/units/air_base", bastionGenericDegradation), 1)
|
||||
),
|
||||
StructureTemplatePool.Projection.RIGID
|
||||
)),
|
||||
6,
|
||||
ConstantHeight.of(VerticalAnchor.absolute(33)),
|
||||
false
|
||||
)
|
||||
);
|
||||
});
|
||||
put("bastion_remnant_hoglin_stable", l -> {
|
||||
RegistryAccess regs = l.registryAccess();
|
||||
|
||||
final HolderGetter<StructureProcessorList> processorLists = regs.lookupOrThrow(Registry.PROCESSOR_LIST_REGISTRY);
|
||||
final Holder<StructureProcessorList> bastionGenericDegradation = processorLists.getOrThrow(ProcessorLists.BASTION_GENERIC_DEGRADATION);
|
||||
|
||||
final HolderGetter<StructureTemplatePool> pools = regs.lookupOrThrow(Registry.TEMPLATE_POOL_REGISTRY);
|
||||
final Holder<StructureTemplatePool> empty = pools.getOrThrow(Pools.EMPTY);
|
||||
|
||||
return spawnCustomStructure(
|
||||
new JigsawStructure(new Structure.StructureSettings(
|
||||
l.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
TerrainAdjustment.NONE
|
||||
),
|
||||
Holder.direct(new StructureTemplatePool(
|
||||
empty,
|
||||
ImmutableList.of(
|
||||
Pair.of(StructurePoolElement.single("bastion/hoglin_stable/air_base", bastionGenericDegradation), 1)
|
||||
),
|
||||
StructureTemplatePool.Projection.RIGID
|
||||
)),
|
||||
6,
|
||||
ConstantHeight.of(VerticalAnchor.absolute(33)),
|
||||
false
|
||||
)
|
||||
);
|
||||
});
|
||||
put("bastion_remnant_treasure", l -> {
|
||||
RegistryAccess regs = l.registryAccess();
|
||||
|
||||
final HolderGetter<StructureProcessorList> processorLists = regs.lookupOrThrow(Registry.PROCESSOR_LIST_REGISTRY);
|
||||
final Holder<StructureProcessorList> bastionGenericDegradation = processorLists.getOrThrow(ProcessorLists.BASTION_GENERIC_DEGRADATION);
|
||||
|
||||
final HolderGetter<StructureTemplatePool> pools = regs.lookupOrThrow(Registry.TEMPLATE_POOL_REGISTRY);
|
||||
final Holder<StructureTemplatePool> empty = pools.getOrThrow(Pools.EMPTY);
|
||||
|
||||
return spawnCustomStructure(
|
||||
new JigsawStructure(new Structure.StructureSettings(
|
||||
l.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
TerrainAdjustment.NONE
|
||||
),
|
||||
Holder.direct(new StructureTemplatePool(
|
||||
empty,
|
||||
ImmutableList.of(
|
||||
Pair.of(StructurePoolElement.single("bastion/treasure/big_air_full", bastionGenericDegradation), 1)
|
||||
),
|
||||
StructureTemplatePool.Projection.RIGID
|
||||
)),
|
||||
6,
|
||||
ConstantHeight.of(VerticalAnchor.absolute(33)),
|
||||
false
|
||||
)
|
||||
);
|
||||
});
|
||||
put("bastion_remnant_bridge", l -> {
|
||||
RegistryAccess regs = l.registryAccess();
|
||||
|
||||
final HolderGetter<StructureProcessorList> processorLists = regs.lookupOrThrow(Registry.PROCESSOR_LIST_REGISTRY);
|
||||
final Holder<StructureProcessorList> bastionGenericDegradation = processorLists.getOrThrow(ProcessorLists.BASTION_GENERIC_DEGRADATION);
|
||||
|
||||
final HolderGetter<StructureTemplatePool> pools = regs.lookupOrThrow(Registry.TEMPLATE_POOL_REGISTRY);
|
||||
final Holder<StructureTemplatePool> empty = pools.getOrThrow(Pools.EMPTY);
|
||||
|
||||
return spawnCustomStructure(
|
||||
new JigsawStructure(new Structure.StructureSettings(
|
||||
l.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
TerrainAdjustment.NONE
|
||||
),
|
||||
Holder.direct(new StructureTemplatePool(
|
||||
empty,
|
||||
ImmutableList.of(
|
||||
Pair.of(StructurePoolElement.single("bastion/bridge/starting_pieces/entrance_base", bastionGenericDegradation), 1)
|
||||
),
|
||||
StructureTemplatePool.Projection.RIGID
|
||||
)),
|
||||
6,
|
||||
ConstantHeight.of(VerticalAnchor.absolute(33)),
|
||||
false
|
||||
)
|
||||
);
|
||||
});
|
||||
}};
|
||||
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ public class OptimizedExplosion
|
||||
EXPLOSION_OUTCOME.onExplosion((ServerLevel) world, eAccess.getSource(), e::getIndirectSourceEntity, eAccess.getX(), eAccess.getY(), eAccess.getZ(), eAccess.getRadius(), eAccess.isFire(), e.getToBlow(), entityList, eAccess.getBlockInteraction());
|
||||
}
|
||||
|
||||
boolean damagesTerrain = eAccess.getBlockInteraction() != Explosion.BlockInteraction.NONE;
|
||||
boolean damagesTerrain = eAccess.getBlockInteraction() != Explosion.BlockInteraction.KEEP;
|
||||
|
||||
// explosionSound incremented till disabling the explosion particles and sound
|
||||
if (explosionSound < 100 || explosionSound % 100 == 0)
|
||||
|
||||
@@ -16,30 +16,30 @@ public class ParticleDisplay
|
||||
{
|
||||
private static Map<String, ParticleOptions> particleCache = new HashMap<>();
|
||||
|
||||
private static ParticleOptions parseParticle(String name)
|
||||
private static ParticleOptions parseParticle(String name, ServerLevel level) // [SCARY SHIT] persistent caches over server reloads
|
||||
{
|
||||
try
|
||||
{
|
||||
return ParticleArgument.readParticle(new StringReader(name), HolderLookup.forRegistry(Registry.PARTICLE_TYPE));
|
||||
return ParticleArgument.readParticle(new StringReader(name), level.holderLookup(Registry.PARTICLE_TYPE_REGISTRY));
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
throw new RuntimeException("No such particle: "+name);
|
||||
}
|
||||
}
|
||||
public static ParticleOptions getEffect(String name)
|
||||
public static ParticleOptions getEffect(String name, ServerLevel level)
|
||||
{
|
||||
if (name == null) return null;
|
||||
ParticleOptions res = particleCache.get(name);
|
||||
if (res != null) return res;
|
||||
particleCache.put(name, parseParticle(name));
|
||||
particleCache.put(name, parseParticle(name, level));
|
||||
return particleCache.get(name);
|
||||
}
|
||||
|
||||
public static void drawParticleLine(ServerPlayer player, Vec3 from, Vec3 to, String main, String accent, int count, double spread)
|
||||
{
|
||||
ParticleOptions accentParticle = getEffect(accent);
|
||||
ParticleOptions mainParticle = getEffect(main);
|
||||
ParticleOptions accentParticle = getEffect(accent, player.getLevel());
|
||||
ParticleOptions mainParticle = getEffect(main, player.getLevel());
|
||||
|
||||
if (accentParticle != null) ((ServerLevel)player.level).sendParticles(
|
||||
player,
|
||||
|
||||
Reference in new issue
Block a user