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 revisionBoth sides next revision
tutorial:fluids [2019/09/24 14:52] – how to add fluids to tags alexiytutorial:fluids [2019/09/24 15:02] – code style alexiy
Line 53: Line 53:
     // how much does the height of the fluid block decreases     // how much does the height of the fluid block decreases
     @Override     @Override
-    protected int getLevelDecreasePerBlock(ViewableWorld var1)+    protected int getLevelDecreasePerBlock(ViewableWorld world)
     {     {
         return 1;         return 1;
Line 63: Line 63:
      */      */
     @Override     @Override
-    public int getTickRate(ViewableWorld var1)+    public int getTickRate(ViewableWorld world)
     {     {
         return 5;         return 5;
Line 76: Line 76:
     // this seems to determine fluid's spread speed (higher value means faster)     // this seems to determine fluid's spread speed (higher value means faster)
     @Override     @Override
-    protected int method_15733(ViewableWorld var1)+    protected int method_15733(ViewableWorld world)
     {     {
         return 4;         return 4;
Line 83: Line 83:
     // I don't know what this does, but it's present in the water fluid     // I don't know what this does, but it's present in the water fluid
     @Override     @Override
-    protected void beforeBreakingBlock(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1) { +    protected void beforeBreakingBlock(IWorld world, BlockPos blockPos, BlockState blockState) { 
-        BlockEntity blockEntity_1 blockState_1.getBlock().hasBlockEntity() ? iWorld_1.getBlockEntity(blockPos_1) : null; +        BlockEntity blockEntity blockState.getBlock().hasBlockEntity() ? world.getBlockEntity(blockPos) : null; 
-        Block.dropStacks(blockState_1iWorld_1.getWorld(), blockPos_1blockEntity_1);+        Block.dropStacks(blockStateworld.getWorld(), blockPosblockEntity);
     }     }
  
     // also don't know what it does     // also don't know what it does
-    public boolean method_15777(FluidState fluidState_1, BlockView blockView_1, BlockPos blockPos_1, Fluid fluid_1, Direction direction_1) { +    public boolean method_15777(FluidState fluidState, BlockView blockView, BlockPos blockPos, Fluid fluid, Direction direction) { 
-        return direction_1 == Direction.DOWN;+        return direction == Direction.DOWN;
     }     }
  
Line 98: Line 98:
      */      */
     @Override     @Override
-    public abstract boolean matchesType(Fluid fluid_1);+    public abstract boolean matchesType(Fluid fluid);
  
 } }
Line 133: Line 133:
  
     @Override     @Override
-    public boolean matchesType(Fluid fluid_1)+    public boolean matchesType(Fluid fluid)
     {     {
         return false;         return false;
Line 178: Line 178:
  
         @Override         @Override
-        protected void appendProperties(StateFactory.Builder<Fluid, FluidState> stateFactory$Builder_1)+        protected void appendProperties(StateFactory.Builder<Fluid, FluidState> stateFactoryBuilder)
         {         {
-            super.appendProperties(stateFactory$Builder_1); +            super.appendProperties(stateFactoryBuilder); 
-            stateFactory$Builder_1.add(LEVEL);+            stateFactoryBuilder.add(LEVEL);
         }         }
     }     }
Line 201: Line 201:
     {     {
          
-        stillAcid = Registry.register(Registry.FLUID,new Identifier(MODID,"acid_still"),new Acid.Still()); +        stillAcid = Registry.register(Registry.FLUID, new Identifier(MODID,"acid_still"), new Acid.Still()); 
-        flowingAcid = Registry.register(Registry.FLUID,new Identifier(MODID,"acid_flowing"),new Acid.Flowing());+        flowingAcid = Registry.register(Registry.FLUID, new Identifier(MODID,"acid_flowing"), new Acid.Flowing());
                  
-        acidBucket=new BucketItem(stillAcid,new Item.Settings().maxCount(1)); +        acidBucket = new BucketItem(stillAcid, new Item.Settings().maxCount(1)); 
-        Registry.register(Registry.ITEM,new Identifier(MODID,"acid_bucket"),acidBucket);+        Registry.register(Registry.ITEM, new Identifier(MODID,"acid_bucket"), acidBucket);
     }         }    
 </code> </code>
Line 246: Line 246:
         ...         ...
                  
-        acid=new BaseFluidBlock(stillAcid,FabricBlockSettings.of(Material.WATER).dropsNothing().build()); +        acid = new BaseFluidBlock(stillAcid, FabricBlockSettings.of(Material.WATER).dropsNothing().build()); 
-        Registry.register(Registry.BLOCK,new Identifier(MODID,"acid_block"),acid);+        Registry.register(Registry.BLOCK, new Identifier(MODID, "acid_block"), acid);
     }         }    
 </code> </code>
Line 266: Line 266:
     {     {
         //don't ask me what **method_15741** does...         //don't ask me what **method_15741** does...
-        return [ModInitializer].acid.getDefaultState().with(FluidBlock.LEVEL,method_15741(fluidState));+        return [ModInitializer].acid.getDefaultState().with(FluidBlock.LEVEL, method_15741(fluidState));
     }     }
  
Line 302: Line 302:
     public void onInitializeClient()     public void onInitializeClient()
     {     {
-        Identifier stillSpriteLocation=new Identifier("block/water_still"); +        Identifier stillSpriteLocation = new Identifier("block/water_still"); 
-        Identifier dynamicSpriteLocation=new Identifier("block/water_flow");+        Identifier dynamicSpriteLocation = new Identifier("block/water_flow");
         // here I tell to use only 16x16 area of the water texture         // here I tell to use only 16x16 area of the water texture
-        FabricSprite stillAcidSprite = new FabricSprite(stillSpriteLocation,16,16);+        FabricSprite stillAcidSprite = new FabricSprite(stillSpriteLocation, 16, 16);
         // same, but 32         // same, but 32
-        FabricSprite dynamicAcidSprite=new FabricSprite(dynamicSpriteLocation,32,32);+        FabricSprite dynamicAcidSprite = new FabricSprite(dynamicSpriteLocation, 32, 32);
                  
         // adding the sprites to the block texture atlas         // adding the sprites to the block texture atlas
Line 316: Line 316:
  
         // this renderer is responsible for drawing fluids in a world         // this renderer is responsible for drawing fluids in a world
-        FluidRenderHandler acidRenderHandler=new FluidRenderHandler()+        FluidRenderHandler acidRenderHandler = new FluidRenderHandler()
         {         {
             // return the sprites: still sprite goes first into the array, flowing/dynamic goes last             // return the sprites: still sprite goes first into the array, flowing/dynamic goes last
Line 322: Line 322:
             public Sprite[] getFluidSprites(ExtendedBlockView extendedBlockView, BlockPos blockPos, FluidState fluidState)             public Sprite[] getFluidSprites(ExtendedBlockView extendedBlockView, BlockPos blockPos, FluidState fluidState)
             {             {
-                return new Sprite[]{stillAcidSprite,dynamicAcidSprite};+                return new Sprite[]{stillAcidSprite, dynamicAcidSprite};
             }             }
  
Line 335: Line 335:
         // registering the same renderer for both fluid variants is intentional         // registering the same renderer for both fluid variants is intentional
  
-        FluidRenderHandlerRegistry.INSTANCE.register([ModInitializer].stillAcid,acidRenderHandler); +        FluidRenderHandlerRegistry.INSTANCE.register([ModInitializer].stillAcid, acidRenderHandler); 
-        FluidRenderHandlerRegistry.INSTANCE.register([ModInitializer].flowingAcid,acidRenderHandler);+        FluidRenderHandlerRegistry.INSTANCE.register([ModInitializer].flowingAcid, acidRenderHandler);
 </code> </code>
  
Line 346: Line 346:
 <code java> <code java>
                  
-        LakeFeature acidFeature=Registry.register(Registry.FEATURE,new Identifier(MODID,"acid_lake"),new LakeFeature(dynamic -> new LakeFeatureConfig(acid.getDefaultState())));+        LakeFeature acidFeature = Registry.register(Registry.FEATURE, new Identifier(MODID,"acid_lake"), new LakeFeature(dynamic -> new LakeFeatureConfig(acid.getDefaultState())));
  
 </code> </code>
Line 352: Line 352:
 <code java> <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):         // 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)));+        Biomes.FOREST.addFeature(GenerationStep.Feature.LOCAL_MODIFICATIONS, Biome.configureFeature(acidFeature, new LakeFeatureConfig(acid.getDefaultState()), Decorator.WATER_LAKE, new LakeDecoratorConfig(40)));
 </code> </code>
 This is the end of the tutorial. This is the end of the tutorial.
  
tutorial/fluids.txt · Last modified: 2023/05/04 11:31 by solidblock