Changes

42 bytes added ,  23:22, 28 August 2023
m
Line 5: Line 5:  
* Modifying the climate of a biome
 
* Modifying the climate of a biome
 
* Modifying a biome's client effects, such as water color
 
* Modifying a biome's client effects, such as water color
 +
 +
<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 and using biome modifiers involves up to three steps:
Line 12: Line 14:  
# 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.
 
# 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.
   −
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.
  −
  −
= Biome Modifier Types =
      +
=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 45: 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 59: 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 133: 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 175: 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 200: 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 219: 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 239: 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