User Tools

Site Tools


tutorial:fluids

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tutorial:fluids [2019/09/24 11:28] – client side operations (rendering) alexiytutorial:fluids [2019/09/24 14:52] – how to add fluids to tags alexiy
Line 100: Line 100:
     public abstract boolean matchesType(Fluid fluid_1);     public abstract boolean matchesType(Fluid fluid_1);
  
-    /** 
-     * Required for entities to behave in this fluid like in water 
-     */ 
-    @Override 
-    public boolean matches(Tag<Fluid> tag_1) 
-    { 
-        return tag_1 == FluidTags.WATER; 
-    } 
 } }
 </code> </code>
Line 215: Line 207:
         Registry.register(Registry.ITEM,new Identifier(MODID,"acid_bucket"),acidBucket);         Registry.register(Registry.ITEM,new Identifier(MODID,"acid_bucket"),acidBucket);
     }         }    
 +</code>
 +
 +To make the custom fluid behave like water or lava, you must add it to a corresponding fluid tag: make a file "data/minecraft/tags/fluids/water.json" and write identifiers of your fluids in there:
 +<code json>
 +{
 +  "replace": false,
 +  "values": [
 +    "modid:acid_still",
 +    "modid:acid_flowing"
 +  ]
 +}
 </code> </code>
  
Line 337: Line 340:
  
 Then what's left to do is to create necessary Json files and textures, but you should know how to do that at this point. Then what's left to do is to create necessary Json files and textures, but you should know how to do that at this point.
 +
 +===== Generation in a world =====
 +
 +To make acid lakes generate in the world, you can use **net.minecraft.world.gen.feature.LakeFeature**, which you create in the ModInitializer:
 +<code java>
 +        
 +        LakeFeature acidFeature=Registry.register(Registry.FEATURE,new Identifier(MODID,"acid_lake"),new LakeFeature(dynamic -> new LakeFeatureConfig(acid.getDefaultState())));
 +
 +</code>
 +Then put it into desired biomes to generate:
 +<code java>
 +        // I tell it to generate like water lakes, with a rarity of 40 (the higher is the number, the lesser is the generation chance):
 +        Biomes.FOREST.addFeature(GenerationStep.Feature.LOCAL_MODIFICATIONS, Biome.configureFeature(acidFeature,new LakeFeatureConfig(acid.getDefaultState()), Decorator.WATER_LAKE,new LakeDecoratorConfig(40)));
 +</code>
 +This is the end of the tutorial.
 +
tutorial/fluids.txt · Last modified: 2023/05/04 11:31 by solidblock