Advertisement
Guest User

NecromodStructures

a guest
Feb 5th, 2023
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.80 KB | None | 0 0
  1. public class NecromodStructures {
  2.  
  3.     public static final DeferredRegister<Structure<?>> DEFERRED_REGISTRY_STRUCTURE = DeferredRegister.create(ForgeRegistries.STRUCTURE_FEATURES, Necromod.MODID);
  4.     public static IStructurePieceType Secret_Room_Piece;
  5.  
  6.     public static final RegistryObject<Structure<NoFeatureConfig>> SECRET_ROOM = DEFERRED_REGISTRY_STRUCTURE.register("secret_room", () -> (new SecretRoomStructure(NoFeatureConfig.CODEC)));
  7.    
  8.     public static void setupStructures()
  9.     {
  10.         setupMapSpacingAndLand(
  11.                 SECRET_ROOM.get(), /* The instance of the structure */
  12.                 new StructureSeparationSettings(200 /* average distance apart in chunks between spawn attempts */,
  13.                         100 /* minimum distance apart in chunks between spawn attempts. MUST BE LESS THAN ABOVE VALUE*/,
  14.                         1234567890 /* this modifies the seed of the structure so no two structures always spawn over each-other. Make this large and unique. */),
  15.                 true);
  16.  
  17.     }
  18.  
  19.     public static <F extends Structure<?>> void setupMapSpacingAndLand(F structure, StructureSeparationSettings structureSeparationSettings, boolean transformSurroundingLand)
  20.     {
  21.  
  22.         Structure.STRUCTURES_REGISTRY.put(structure.getRegistryName().toString(), structure);
  23.  
  24.         if(transformSurroundingLand){
  25.             Structure.NOISE_AFFECTING_FEATURES =
  26.                     ImmutableList.<Structure<?>>builder()
  27.                             .addAll(Structure.NOISE_AFFECTING_FEATURES)
  28.                             .add(structure)
  29.                             .build();
  30.         }
  31.  
  32.  
  33.         DimensionStructuresSettings.DEFAULTS =
  34.                 ImmutableMap.<Structure<?>, StructureSeparationSettings>builder()
  35.                         .putAll(DimensionStructuresSettings.DEFAULTS)
  36.                         .put(structure, structureSeparationSettings)
  37.                         .build();
  38.  
  39.         WorldGenRegistries.NOISE_GENERATOR_SETTINGS.entrySet().forEach(settings -> {
  40.             Map<Structure<?>, StructureSeparationSettings> structureMap = settings.getValue().structureSettings().structureConfig();
  41.  
  42.             if(structureMap instanceof ImmutableMap){
  43.                 Map<Structure<?>, StructureSeparationSettings> tempMap = new HashMap<>(structureMap);
  44.                 tempMap.put(structure, structureSeparationSettings);
  45.                 settings.getValue().structureSettings().structureConfig = tempMap;
  46.             }
  47.             else{
  48.                 structureMap.put(structure, structureSeparationSettings);
  49.             }
  50.         });
  51.     }
  52.    
  53.     public static void registerStructurePieces()
  54.     {
  55.         Secret_Room_Piece = Registry.register(Registry.STRUCTURE_PIECE, new ResourceLocation(Necromod.MODID, "secret_room_template"), SecretRoomPiece.Piece::new);
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement