Changes

829 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 125: Line 133:  
   "biomes": "#minecraft:is_badlands",
 
   "biomes": "#minecraft:is_badlands",
 
   "feature": "yourmod:some_feature"
 
   "feature": "yourmod:some_feature"
}
  −
</syntaxhighlight>
  −
  −
== Side Note on HolderSets ==
  −
  −
HolderSets are a vanilla feature that, when defined in JSON, can be specified as a single id, list of ids, or tag. Our example above uses a holderset of biomes, so all three of these are valid biome fields:
  −
  −
<syntaxhighlight lang="json">
  −
{
  −
  "biomes": "forest",
  −
  "biomes": ["forest", "birch_forest"],
  −
  "biomes": "#is_forest"
   
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 167: Line 163:  
{
 
{
 
   "type": "forge:add_features", // required
 
   "type": "forge:add_features", // required
   "biomes": "#namespace:your_biome_tag" // accepts a biome id, [list of biome ids], or #namespace:biome_tag
+
   "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
 
   "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
 
   "step": "underground_ores" // accepts a Decoration enum name
Line 192: Line 188:  
{
 
{
 
   "type": "forge:remove_features", // required
 
   "type": "forge:remove_features", // required
   "biomes": "#namespace:your_biome_tag" // accepts a biome id, [list of biome ids], or #namespace:biome_tag
+
   "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
 
   "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
 
   "steps": "underground_ores" // optional field specifying a Decoration or list of Decorations to remove features from, defaults to all if not specified
Line 211: Line 207:  
     "weight": 100, // int, spawn weighting
 
     "weight": 100, // int, spawn weighting
 
     "minCount": 1, // int, minimum pack size
 
     "minCount": 1, // int, minimum pack size
     "maxCount": 4, // int, maximum pack size
+
     "maxCount": 4 // int, maximum pack size
 
   }
 
   }
 
}
 
}
Line 222: Line 218:  
<syntaxhighlight lang="json">
 
<syntaxhighlight lang="json">
 
{
 
{
   "type": "forge:add_spawn", // Required
+
   "type": "forge:remove_spawns", // Required
 
   "biomes": "#namespace:biome_tag", // Accepts a biome id, [list of biome ids], or #namespace:biome_tag
 
   "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
 
   "entity_types": "#namespace:entitytype_tag" // Accepts an entity type, list, or tag of entitytypes whose spawns are to be removed from the biomes
Line 231: Line 227:     
* 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