Record Class StructureModifiers.AddSpawnsStructureModifier
java.lang.Object
java.lang.Record
net.neoforged.neoforge.common.world.StructureModifiers.AddSpawnsStructureModifier
- Record Components:
structures
- Structures to add mob spawns to.spawners
- List of SpawnerDatas specifying EntityType, weight, and pack size.
- All Implemented Interfaces:
StructureModifier
- Enclosing class:
StructureModifiers
public static record StructureModifiers.AddSpawnsStructureModifier(HolderSet<Structure> structures, List<MobSpawnSettings.SpawnerData> spawners)
extends Record
implements StructureModifier
Stock structure modifier that adds a mob spawn override to a structure. If a structure has mob spawn overrides, random mob spawning will use the structure's spawns instead of the local biome's spawns. Has the following json format:
{ "type": "neoforge:add_spawns", // Required "structures": "#namespace:structure_tag", // Accepts a structure id, [list of structure ids], or #namespace:structure_tag "spawners": { "type": "namespace:entity_type", // Type of mob to spawn "weight": 100, // int, spawn weighting "minCount": 1, // int, minimum pack size "maxCount": 4, // int, maximum pack size } }
Optionally accepts a list of spawner objects instead of a single spawner:
{ "type": "neoforge:add_spawns", // Required "structure": "#namespace:structure_tag", // Accepts a structure id, [list of structure ids], or #namespace:structure_tag "spawners": [ { "type": "namespace:entity_type", // Type of mob to spawn "weight": 100, // int, spawn weighting "minCount": 1, // int, minimum pack size "maxCount": 4, // int, maximum pack size }, { // additional spawner object } ] }
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.neoforged.neoforge.common.world.StructureModifier
StructureModifier.Phase
-
Field Summary
Modifier and TypeFieldDescriptionprivate final List
<MobSpawnSettings.SpawnerData> The field for thespawners
record component.The field for thestructures
record component.Fields inherited from interface net.neoforged.neoforge.common.world.StructureModifier
DIRECT_CODEC, LIST_CODEC, REFERENCE_CODEC
-
Constructor Summary
ConstructorDescriptionAddSpawnsStructureModifier
(HolderSet<Structure> structures, List<MobSpawnSettings.SpawnerData> spawners) Creates an instance of aAddSpawnsStructureModifier
record class. -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.MapCodec
<? extends StructureModifier> codec()
final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.void
modify
(Holder<Structure> structure, StructureModifier.Phase phase, ModifiableStructureInfo.StructureInfo.Builder builder) Modifies the information via the provided structure builder.singleSpawn
(HolderSet<Structure> structures, MobSpawnSettings.SpawnerData spawner) Convenience method for using a singleMobSpawnSettings.SpawnerData
.spawners()
Returns the value of thespawners
record component.Returns the value of thestructures
record component.final String
toString()
Returns a string representation of this record class.
-
Field Details
-
structures
The field for thestructures
record component. -
spawners
The field for thespawners
record component.
-
-
Constructor Details
-
AddSpawnsStructureModifier
public AddSpawnsStructureModifier(HolderSet<Structure> structures, List<MobSpawnSettings.SpawnerData> spawners) Creates an instance of aAddSpawnsStructureModifier
record class.- Parameters:
structures
- the value for thestructures
record componentspawners
- the value for thespawners
record component
-
-
Method Details
-
singleSpawn
public static StructureModifiers.AddSpawnsStructureModifier singleSpawn(HolderSet<Structure> structures, MobSpawnSettings.SpawnerData spawner) Convenience method for using a singleMobSpawnSettings.SpawnerData
.- Parameters:
structures
- Structures to add mob spawns to.spawner
- SpawnerData specifying EntityTYpe, weight, and pack size.- Returns:
- AddSpawnsStructureModifier that adds a single spawn entry to the specified biomes.
-
modify
public void modify(Holder<Structure> structure, StructureModifier.Phase phase, ModifiableStructureInfo.StructureInfo.Builder builder) Description copied from interface:StructureModifier
Modifies the information via the provided structure builder. Allows mob spawns and world-gen features to be added or removed, and climate and client effects to be modified.- Specified by:
modify
in interfaceStructureModifier
- Parameters:
structure
- the named structure being modified (with original data readable).phase
- structure modification phase. Structure modifiers apply in each phase in order of the enum constants.builder
- mutable structure info builder. Apply changes to this.
-
codec
- Specified by:
codec
in interfaceStructureModifier
- Returns:
- the codec which serializes and deserializes this structure modifier
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
structures
Returns the value of thestructures
record component.- Returns:
- the value of the
structures
record component
-
spawners
Returns the value of thespawners
record component.- Returns:
- the value of the
spawners
record component
-