Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.mcreator.rksmobs.world.features;
- import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
- import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
- import net.minecraft.world.level.levelgen.structure.templatesystem.BlockIgnoreProcessor;
- import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
- import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
- import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
- import net.minecraft.world.level.levelgen.feature.Feature;
- import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
- import net.minecraft.world.level.levelgen.Heightmap;
- import net.minecraft.world.level.block.Rotation;
- import net.minecraft.world.level.block.Mirror;
- import net.minecraft.world.level.Level;
- import net.minecraft.resources.ResourceLocation;
- import net.minecraft.resources.ResourceKey;
- import net.minecraft.core.BlockPos;
- import java.util.Set;
- public class RockMonumentFeature extends Feature<NoneFeatureConfiguration> {
- public static final RockMonumentFeature FEATURE = (RockMonumentFeature) new RockMonumentFeature().setRegistryName("rks_mobs:rock_monument");
- public static final ConfiguredFeature<?, ?> CONFIGURED_FEATURE = FEATURE.configured(FeatureConfiguration.NONE);
- public static final Set<ResourceLocation> GENERATE_BIOMES = null;
- private StructureTemplate template = null;
- public RockMonumentFeature() {
- super(NoneFeatureConfiguration.CODEC);
- }
- @Override
- public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
- boolean dimensionCriteria = false;
- ResourceKey<Level> dimensionType = context.level().getLevel().dimension();
- if (dimensionType == Level.OVERWORLD)
- dimensionCriteria = true;
- if (!dimensionCriteria)
- return false;
- if (template == null)
- template = context.level().getLevel().getStructureManager().getOrCreate(new ResourceLocation("rks_mobs", "rockmonument"));
- if (template == null)
- return false;
- if ((context.random().nextInt(1000000) + 1) <= 10000) {
- boolean anyPlaced = false;
- int count = context.random().nextInt(1) + 1;
- for (int a = 0; a < count; a++) {
- int i = context.origin().getX() + context.random().nextInt(16);
- int k = context.origin().getZ() + context.random().nextInt(16);
- int j = context.level().getHeight(Heightmap.Types.OCEAN_FLOOR_WG, i, k);
- j -= 1;
- BlockPos spawnTo = new BlockPos(i + 0, j + 0, k + 0);
- if (template.placeInWorld(context.level(), spawnTo, spawnTo,
- new StructurePlaceSettings().setMirror(Mirror.values()[context.random().nextInt(2)])
- .setRotation(Rotation.values()[context.random().nextInt(3)]).setRandom(context.random())
- .addProcessor(BlockIgnoreProcessor.STRUCTURE_AND_AIR).setIgnoreEntities(false),
- context.random(), 2)) {
- anyPlaced = true;
- }
- }
- return anyPlaced;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment