tutorial:fluids
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:fluids [2019/09/24 15:02] – code style alexiy | tutorial: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 | + | return |
} | } | ||
| | ||
Line 266: | Line 266: | ||
{ | { | ||
// | // | ||
- | return | + | return |
} | } | ||
Line 272: | Line 272: | ||
public Fluid getFlowing() | public Fluid getFlowing() | ||
{ | { | ||
- | return | + | return |
} | } | ||
Line 278: | Line 278: | ||
public Fluid getStill() | public Fluid getStill() | ||
{ | { | ||
- | return | + | return |
} | } | ||
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(" | ||
- | Identifier dynamicSpriteLocation = new Identifier(" | ||
- | // here I tell to use only 16x16 area of the water texture | ||
- | FabricSprite stillAcidSprite = new FabricSprite(stillSpriteLocation, | ||
- | // same, but 32 | ||
- | FabricSprite dynamicAcidSprite = new FabricSprite(dynamicSpriteLocation, | ||
| | ||
// adding the sprites to the block texture atlas | // adding the sprites to the block texture atlas | ||
ClientSpriteRegistryCallback.event(SpriteAtlasTexture.BLOCK_ATLAS_TEX).register((spriteAtlasTexture, | ClientSpriteRegistryCallback.event(SpriteAtlasTexture.BLOCK_ATLAS_TEX).register((spriteAtlasTexture, | ||
+ | | ||
+ | Identifier stillSpriteLocation = new Identifier(" | ||
+ | Identifier dynamicSpriteLocation = new Identifier(" | ||
+ | // here I tell to use only 16x16 area of the water texture | ||
+ | FabricSprite stillAcidSprite = new FabricSprite(stillSpriteLocation, | ||
+ | // same, but 32 | ||
+ | FabricSprite dynamicAcidSprite = new FabricSprite(dynamicSpriteLocation, | ||
+ | | ||
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/ | + | |
- | @Override | + | |
- | public Sprite[] getFluidSprites(ExtendedBlockView extendedBlockView, | + | |
{ | { | ||
- | return new Sprite[]{stillAcidSprite, | + | |
- | } | + | @Override |
+ | public Sprite[] getFluidSprites(ExtendedBlockView extendedBlockView, | ||
+ | { | ||
+ | | ||
+ | } | ||
- | | + | |
- | @Override | + | @Override |
- | public int getFluidColor(ExtendedBlockView view, BlockPos pos, FluidState state) | + | public int getFluidColor(ExtendedBlockView view, BlockPos pos, FluidState state) |
- | { | + | { |
- | return 0x4cc248; | + | return 0x4cc248; |
- | } | + | } |
- | }; | + | }; |
- | | + | |
+ | |||
+ | FluidRenderHandlerRegistry.INSTANCE.register(Mod.stillAcid, | ||
+ | FluidRenderHandlerRegistry.INSTANCE.register(Mod.flowingAcid, | ||
+ | }); | ||
- | FluidRenderHandlerRegistry.INSTANCE.register([ModInitializer].stillAcid, | ||
- | FluidRenderHandlerRegistry.INSTANCE.register([ModInitializer].flowingAcid, | ||
</ | </ | ||
tutorial/fluids.txt · Last modified: 2023/05/04 11:31 by solidblock