Guest User

Untitled

a guest
Feb 24th, 2022
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. package net.mcreator.rksmobs.world.features;
  2.  
  3. import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
  4. import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
  5. import net.minecraft.world.level.levelgen.structure.templatesystem.BlockIgnoreProcessor;
  6. import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
  7. import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
  8. import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
  9. import net.minecraft.world.level.levelgen.feature.Feature;
  10. import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
  11. import net.minecraft.world.level.levelgen.Heightmap;
  12. import net.minecraft.world.level.block.Rotation;
  13. import net.minecraft.world.level.block.Mirror;
  14. import net.minecraft.world.level.Level;
  15. import net.minecraft.resources.ResourceLocation;
  16. import net.minecraft.resources.ResourceKey;
  17. import net.minecraft.core.BlockPos;
  18.  
  19. import java.util.Set;
  20.  
  21. public class RockMonumentFeature extends Feature<NoneFeatureConfiguration> {
  22. public static final RockMonumentFeature FEATURE = (RockMonumentFeature) new RockMonumentFeature().setRegistryName("rks_mobs:rock_monument");
  23. public static final ConfiguredFeature<?, ?> CONFIGURED_FEATURE = FEATURE.configured(FeatureConfiguration.NONE);
  24. public static final Set<ResourceLocation> GENERATE_BIOMES = null;
  25. private StructureTemplate template = null;
  26.  
  27. public RockMonumentFeature() {
  28. super(NoneFeatureConfiguration.CODEC);
  29. }
  30.  
  31. @Override
  32. public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
  33. boolean dimensionCriteria = false;
  34. ResourceKey<Level> dimensionType = context.level().getLevel().dimension();
  35. if (dimensionType == Level.OVERWORLD)
  36. dimensionCriteria = true;
  37. if (!dimensionCriteria)
  38. return false;
  39. if (template == null)
  40. template = context.level().getLevel().getStructureManager().getOrCreate(new ResourceLocation("rks_mobs", "rockmonument"));
  41. if (template == null)
  42. return false;
  43. if ((context.random().nextInt(1000000) + 1) <= 10000) {
  44. boolean anyPlaced = false;
  45. int count = context.random().nextInt(1) + 1;
  46. for (int a = 0; a < count; a++) {
  47. int i = context.origin().getX() + context.random().nextInt(16);
  48. int k = context.origin().getZ() + context.random().nextInt(16);
  49. int j = context.level().getHeight(Heightmap.Types.OCEAN_FLOOR_WG, i, k);
  50. j -= 1;
  51. BlockPos spawnTo = new BlockPos(i + 0, j + 0, k + 0);
  52. if (template.placeInWorld(context.level(), spawnTo, spawnTo,
  53. new StructurePlaceSettings().setMirror(Mirror.values()[context.random().nextInt(2)])
  54. .setRotation(Rotation.values()[context.random().nextInt(3)]).setRandom(context.random())
  55. .addProcessor(BlockIgnoreProcessor.STRUCTURE_AND_AIR).setIgnoreEntities(false),
  56. context.random(), 2)) {
  57. anyPlaced = true;
  58. }
  59. }
  60. return anyPlaced;
  61. }
  62. return false;
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment