aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/render/IRenderedBlock.java
blob: 6d2ba999d519d88d652bc5a42e5bb774361d9b68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package gregtech.common.render;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;

public interface IRenderedBlock {
    /** @return the Textures to be rendered */
    @SideOnly(Side.CLIENT)
    ITexture[] getTexture(Block aBlock, byte aSide, int aRenderPass, boolean[] aShouldSideBeRendered);

    @SideOnly(Side.CLIENT)
    ITexture[] getTexture(Block aBlock, byte aSide, boolean isActive, int aRenderPass);

    /** gets the Amount of Render Passes for this TileEntity or similar Handler. Only gets called once per Rendering. */
    @SideOnly(Side.CLIENT)
    int getRenderPasses(Block aBlock);

    /** if this uses said Render Pass or if it can be skipped entirely. */
    @SideOnly(Side.CLIENT)
    boolean usesRenderPass(int aRenderPass);

    /** sets the Block Size rendered; return false for letting it select the normal Block Bounds. */
    @SideOnly(Side.CLIENT)
    boolean setBlockBounds(Block aBlock, int aRenderPass);

    /** returning true stops all the other Rendering from happening. */
    @SideOnly(Side.CLIENT)
    default boolean renderItem(Block aBlock, RenderBlocks aRenderer) { return false; }

    /** returning true stops all the other Rendering from happening. */
    @SideOnly(Side.CLIENT)
    default boolean renderBlock(Block aBlock, RenderBlocks aRenderer, IBlockAccess aWorld, int aX, int aY, int aZ) { return false; }

    /** if this Block lets the TileEntity or a similar Handler do all the Inventory Render work. */
    @SideOnly(Side.CLIENT)
    IRenderedBlock passRenderingToObject(ItemStack aStack);

    /** if this Block lets the TileEntity or a similar Handler do all the World Render work. */
    @SideOnly(Side.CLIENT)
    IRenderedBlock passRenderingToObject(IBlockAccess aWorld, int aX, int aY, int aZ);

    class ErrorRenderer implements IRenderedBlockSideCheck, IRenderedBlock {
        public static final ErrorRenderer INSTANCE = new ErrorRenderer();
        public ITexture[] mErrorTexture = Textures.BlockIcons.ERROR_RENDERING;
        @Override public ITexture[] getTexture(Block aBlock, byte aSide, int aRenderPass, boolean[] aShouldSideBeRendered) {return mErrorTexture;}
        @Override public ITexture[] getTexture(Block aBlock, byte aSide, boolean isActive, int aRenderPass) {return mErrorTexture;}
        @Override public int getRenderPasses(Block aBlock) {return 1;}
        @Override public boolean usesRenderPass(int aRenderPass) {return true;}
        @Override public boolean setBlockBounds(Block aBlock, int aRenderPass) {aBlock.setBlockBounds(-0.25F, -0.25F, -0.25F, 1.25F, 1.25F, 1.25F); return true;}
        @Override public boolean renderFullBlockSide(Block aBlock, RenderBlocks aRenderer, byte aSide) {return true;}
        @Override public IRenderedBlock passRenderingToObject(ItemStack aStack) {return this;}
        @Override public IRenderedBlock passRenderingToObject(IBlockAccess aWorld, int aX, int aY, int aZ) {return this;}

        @Override
        public boolean renderBlock(Block aBlock, RenderBlocks aRenderer, IBlockAccess aWorld, int aX, int aY, int aZ) {
            aBlock.setBlockBounds(-0.25F, -0.25F, -0.25F, 1.25F, 1.25F, 1.25F);
            GT_Renderer_Block.renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, mErrorTexture, false);
            GT_Renderer_Block.renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, mErrorTexture, false);
            GT_Renderer_Block.renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, mErrorTexture, false);
            GT_Renderer_Block.renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, mErrorTexture, false);
            GT_Renderer_Block.renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, mErrorTexture, false);
            GT_Renderer_Block.renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, mErrorTexture, false);
            return true;
        }
    }
}