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 15:17] – more code style alexiytutorial:fluids [2019/11/04 17:04] – [Rendering setup] Everything must be inside the event alexiy
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(Mod.stillAcid, acidRenderHandler); 
-        FluidRenderHandlerRegistry.INSTANCE.register(Mod.flowingAcid, acidRenderHandler); 
 </code> </code>
  
tutorial/fluids.txt · Last modified: 2023/05/04 11:31 by solidblock