Changes

3,816 bytes added ,  23:22, 28 August 2023
m
Line 6: Line 6:  
* Modifying a biome's client effects, such as water color
 
* Modifying a biome's client effects, such as water color
   −
= Biome Modifier Types =
+
<big>'''NOTE:'''</big> Forge provides several [[#Builtin_Biome_Modifier_Types|builtin biome modifier types]], so some basic use cases such as adding features or mob spawns to biomes can be done without registering additional serializers. If you are looking to add a mob or feature to a biome, scroll down to the [[#Builtin_Biome_Modifier_Types|Builtin Biome Modifier Types]] section and use one of those pre-existing Biome Modifiers from Forge instead. No custom Biome Modifier implementation needed.
    +
Creating and using biome modifiers involves up to three steps:
 +
 +
# Creating a [[#Biome_Modifier_Type|biome modifier type]], which defines how to modify a biome.
 +
# Registering a [[#Biome_Modifier_Serializers|biome modifier codec]], which defines how to parse a json into your biome modifier type.
 +
# Creating [[#Biome_Modifier_JSONs|biome modifier JSONs]] to define individual biome modifier instances; each json file provides a glob of data to your serializer to produce an instance of a biome modifier type. These can be [[#Datageneration|datagenerated]] if desired.
 +
 +
 +
=Biome Modifier Types=
 
To define a new type of biome modifier, begin by implementing a new class that extends <code>BiomeModifier</code>. BiomeModifiers can usually be implemented as records, to reduce boilerplate.
 
To define a new type of biome modifier, begin by implementing a new class that extends <code>BiomeModifier</code>. BiomeModifiers can usually be implemented as records, to reduce boilerplate.
   Line 37: Line 45:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
Typically we also want to restrict biome modifiers to only apply to certain biomes. We can do that by accepting a HolderSet<Biome> in our constructor:
+
Typically we also want to restrict biome modifiers to only apply to certain biomes. We can do that by accepting a HolderSet<biome> in our constructor:
    
<syntaxhighlight lang="java">
 
<syntaxhighlight lang="java">
Line 51: Line 59:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
We can also accept Holders or HolderSets for other [[Registration#Data_Driven_Entries|datapack registry elements]], such as PlacedFeatures, which allows our BiomeModifier to refer to those elements, which can then be defined in their own JSON files.
+
We can also accept [[Holders]] or [[HolderSets|HolderSets]] for other [[Registration#Data_Driven_Entries|datapack registry elements]], such as PlacedFeatures, which allows our BiomeModifier to refer to those elements, which can then be defined in their own JSON files.
    
<syntaxhighlight lang="java">
 
<syntaxhighlight lang="java">
Line 127: Line 135:  
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
= Datageneration =
 +
 +
Biome Modifier jsons can be [[Datageneration|datagenerated via GatherDataEvent]]. As biome modifiers are datapack registry objects, this can be done by using JsonCodecProvider#forDatapackRegistry as the data provider. Refer to [[Datageneration/Datapack_Registries]] for additional information on datagenerating datapack registry elements.
    
= Builtin Biome Modifier Types =
 
= Builtin Biome Modifier Types =
 +
 +
Forge provides the following builtin biome modifier types:
    
== None ==
 
== None ==
   −
Forge provides a no-op biome modifier type, whose jsons have the following format:
+
A no-op biome modifier type, whose jsons have the following format:
    
<syntaxhighlight lang="json">
 
<syntaxhighlight lang="json">
Line 141: Line 155:     
This allows pack devs or server operators to disable mods' biome modifiers by overriding their biome modifier jsons with the above.
 
This allows pack devs or server operators to disable mods' biome modifiers by overriding their biome modifier jsons with the above.
 +
 +
== Add Features ==
 +
 +
This biome modifier type adds placed features to biomes.
 +
 +
<syntaxhighlight lang="json">
 +
{
 +
  "type": "forge:add_features", // required
 +
  "biomes": "#namespace:your_biome_tag", // accepts a biome id, [list of biome ids], or #namespace:biome_tag
 +
  "features": "namespace:your_feature", // accepts a placed feature id, [list of placed feature ids], or #namespace:feature_tag
 +
  "step": "underground_ores" // accepts a Decoration enum name
 +
}
 +
</syntaxhighlight>
 +
 +
Decoration steps in order of generation are:
 +
* raw_generation
 +
* lakes
 +
* local_modifications
 +
* underground_structures
 +
* surface_structures
 +
* underground_ores
 +
* underground_decoration
 +
* fluid_springs
 +
* vegetal_decoration
 +
* top_layer_modification
 +
 +
== Remove Features ==
 +
 +
This biome modifier type removes features from biomes.
 +
 +
<syntaxhighlight lang="json">
 +
{
 +
  "type": "forge:remove_features", // required
 +
  "biomes": "#namespace:your_biome_tag", // accepts a biome id, [list of biome ids], or #namespace:biome_tag
 +
  "features": "namespace:your_feature", // accepts a placed feature id, [list of placed feature ids], or #namespace:feature_tag
 +
  "steps": "underground_ores" // optional field specifying a Decoration or list of Decorations to remove features from, defaults to all if not specified
 +
}
 +
</syntaxhighlight>
 +
 +
== Add Spawns ==
 +
 +
This biome modifier type adds mob spawns to biomes.
 +
 +
<syntaxhighlight lang="json">
 +
{
 +
  "type": "forge:add_spawns", // Required
 +
  "biomes": "#namespace:biome_tag", // Accepts a biome id, [list of biome ids], or #namespace:biome_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
 +
  }
 +
}
 +
</syntaxhighlight>
 +
 +
== Remove Spawns ==
 +
 +
This biome modifier type removes mob spawns from biomes.
 +
 +
<syntaxhighlight lang="json">
 +
{
 +
  "type": "forge:remove_spawns", // Required
 +
  "biomes": "#namespace:biome_tag", // Accepts a biome id, [list of biome ids], or #namespace:biome_tag
 +
  "entity_types": "#namespace:entitytype_tag" // Accepts an entity type, list, or tag of entitytypes whose spawns are to be removed from the biomes
 +
}
 +
</syntaxhighlight>
    
= Best Practices =
 
= Best Practices =
    
* Avoid using biome modifiers to add vanilla placed features to biomes, as this may cause a feature cycle violation (the game will crash if two biomes have the same two features in their feature lists but in different orders). Placed features can be referenced in biome jsons or added via biome modifiers, but should not be used in both.
 
* Avoid using biome modifiers to add vanilla placed features to biomes, as this may cause a feature cycle violation (the game will crash if two biomes have the same two features in their feature lists but in different orders). Placed features can be referenced in biome jsons or added via biome modifiers, but should not be used in both.
 +
* Avoid adding the same placed feature with more than one biome modifier, as this can cause feature cycle violations.
1

edit