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 15:02] – code style alexiytutorial:fluids [2019/11/04 17:04] – [Rendering setup] Everything must be inside the event alexiy
Line 259: Line 259:
     public Item getBucketItem()     public Item getBucketItem()
     {     {
-        return [ModInitializer].acidBucket;+        return Mod.acidBucket;
     }     }
          
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 Mod.acid.getDefaultState().with(FluidBlock.LEVEL, method_15741(fluidState));
     }     }
  
Line 272: Line 272:
     public Fluid getFlowing()     public Fluid getFlowing()
     {     {
-        return [ModInitializer].flowingAcid;+        return Mod.flowingAcid;
     }     }
  
Line 278: Line 278:
     public Fluid getStill()     public Fluid getStill()
     {     {
-        return [ModInitializer].stillAcid;+        return Mod.stillAcid;
     }     }
  
Line 284: Line 284:
     public boolean matchesType(Fluid fluid_1)     public boolean matchesType(Fluid fluid_1)
     {     {
-        return fluid_1==[ModInitializer].flowingAcid || fluid_1==[ModInitializer].stillAcid;+        return fluid_1==Mod.flowingAcid || fluid_1==Mod.stillAcid;
     }     }
          
Line 302: Line 302:
     public void onInitializeClient()     public void onInitializeClient()
     {     {
-        Identifier stillSpriteLocation = new Identifier("block/water_still"); 
-        Identifier dynamicSpriteLocation = new Identifier("block/water_flow"); 
-        // here I tell to use only 16x16 area of the water texture 
-        FabricSprite stillAcidSprite = new FabricSprite(stillSpriteLocation, 16, 16); 
-        // same, but 32 
-        FabricSprite dynamicAcidSprite = new FabricSprite(dynamicSpriteLocation, 32, 32); 
                  
         // adding the sprites to the block texture atlas         // adding the sprites to the block texture atlas
         ClientSpriteRegistryCallback.event(SpriteAtlasTexture.BLOCK_ATLAS_TEX).register((spriteAtlasTexture, registry) -> {         ClientSpriteRegistryCallback.event(SpriteAtlasTexture.BLOCK_ATLAS_TEX).register((spriteAtlasTexture, registry) -> {
 +        
 +            Identifier stillSpriteLocation = new Identifier("block/water_still");
 +            Identifier dynamicSpriteLocation = new Identifier("block/water_flow");
 +            // here I tell to use only 16x16 area of the water texture
 +            FabricSprite stillAcidSprite = new FabricSprite(stillSpriteLocation, 16, 16);
 +            // same, but 32
 +            FabricSprite dynamicAcidSprite = new FabricSprite(dynamicSpriteLocation, 32, 32);
 +        
             registry.register(stillAcidSprite);             registry.register(stillAcidSprite);
             registry.register(dynamicAcidSprite);             registry.register(dynamicAcidSprite);
-        }); +             
- +             
-        // 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 +
-            @Override +
-            public Sprite[] getFluidSprites(ExtendedBlockView extendedBlockView, BlockPos blockPos, FluidState fluidState)+
             {             {
-                return new Sprite[]{stillAcidSprite, dynamicAcidSprite}; +                // return the sprites: still sprite goes first into the array, flowing/dynamic goes last 
-            }+                @Override 
 +                public Sprite[] getFluidSprites(ExtendedBlockView extendedBlockView, BlockPos blockPos, FluidState fluidState) 
 +                { 
 +                    return new Sprite[] {stillAcidSprite, dynamicAcidSprite}; 
 +                }
  
-            // apply light green color +                // apply light green color 
-            @Override +                @Override 
-            public int getFluidColor(ExtendedBlockView view, BlockPos pos, FluidState state) +                public int getFluidColor(ExtendedBlockView view, BlockPos pos, FluidState state) 
-            +                
-                return 0x4cc248; +                    return 0x4cc248; 
-            +                
-        };+            };
  
-        // registering the same renderer for both fluid variants is intentional+            // registering the same renderer for both fluid variants is intentional 
 + 
 +            FluidRenderHandlerRegistry.INSTANCE.register(Mod.stillAcid, acidRenderHandler); 
 +            FluidRenderHandlerRegistry.INSTANCE.register(Mod.flowingAcid, acidRenderHandler); 
 +        });
  
-        FluidRenderHandlerRegistry.INSTANCE.register([ModInitializer].stillAcid, acidRenderHandler); 
-        FluidRenderHandlerRegistry.INSTANCE.register([ModInitializer].flowingAcid, acidRenderHandler); 
 </code> </code>
  
tutorial/fluids.txt · Last modified: 2023/05/04 11:31 by solidblock