Search in sources :

Example 1 with TileEntityGlassShieldBase

use of club.nsdn.nyasamarailway.tileblock.signal.TileEntityGlassShieldBase in project NyaSamaRailway by NSDN.

the class PlatformRenderer method renderWorldBlock.

public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
    this.blockMetadata = world.getBlockMetadata(x, y, z);
    this.topIcon = world.getBlock(x, y, z).getIcon(1, 0);
    if ((this.blockMetadata & 0x3) == 2) {
        this.xOffset = -1;
    } else if ((this.blockMetadata & 0x3) == 0) {
        this.xOffset = 1;
    } else {
        this.xOffset = 0;
    }
    if ((this.blockMetadata & 0x3) == 3) {
        this.zOffset = -1;
    } else if ((this.blockMetadata & 0x3) == 1) {
        this.zOffset = 1;
    } else {
        this.zOffset = 0;
    }
    if (Minecraft.getMinecraft().theWorld.getBlock(x, y - 1, z).equals(block)) {
        this.yOffset = -1;
    } else {
        this.yOffset = 0;
    }
    this.attachedBlock = world.getBlock(x + this.xOffset, y + this.yOffset, z + this.zOffset);
    this.attachedBlockMetadata = world.getBlockMetadata(x + this.xOffset, y + this.yOffset, z + this.zOffset);
    if (this.attachedBlock.equals(Blocks.air)) {
        this.attachedBlock = block;
    }
    this.sidesIcon = this.attachedBlock.getIcon(2, this.attachedBlockMetadata);
    Tessellator.instance.addTranslation(x + 0.5F, y - (this.blockMetadata & 0x4) / 8.0F, z + 0.5F);
    Tessellator.instance.setColorOpaque(255, 255, 255);
    Tessellator.instance.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
    RendererHelper.renderWithIconAndRotation(topModel, (this.blockMetadata & 0x3) * 90.0F, this.topIcon, Tessellator.instance);
    if (world.getTileEntity(x, y + 1, z) instanceof TileEntityGlassShieldBase) {
        IIcon pimpTexture = Blocks.wool.getIcon(0, 15);
        RendererHelper.renderWithIconAndRotation(pimpModel, (this.blockMetadata & 0x3) * 90.0F, pimpTexture, Tessellator.instance);
    }
    if ((this.blockMetadata & 0xC) == 0) {
        RendererHelper.renderWithIconAndRotation(tallSidesModel, (this.blockMetadata & 0x3) * 90.0F, this.sidesIcon, Tessellator.instance);
    } else {
        RendererHelper.renderWithIconAndRotation(sidesModel, (this.blockMetadata & 0x3) * 90.0F, this.sidesIcon, Tessellator.instance);
    }
    Tessellator.instance.addTranslation(-x - 0.5F, -y + (this.blockMetadata & 0x4) / 8.0F, -z - 0.5F);
    return true;
}
Also used : IIcon(net.minecraft.util.IIcon) TileEntityGlassShieldBase(club.nsdn.nyasamarailway.tileblock.signal.TileEntityGlassShieldBase)

Example 2 with TileEntityGlassShieldBase

use of club.nsdn.nyasamarailway.tileblock.signal.TileEntityGlassShieldBase in project NyaSamaRailway by NSDN.

the class GlassShieldRenderer method doInterpolation.

public void doInterpolation(TileEntity tileEntity) {
    if (tileEntity instanceof TileEntityGlassShieldBase) {
        TileEntityGlassShieldBase glassShield = (TileEntityGlassShieldBase) tileEntity;
        float max = (float) TileEntityGlassShieldBase.PROGRESS_MAX;
        float dist = ((float) glassShield.progress) / max * MOVE_DIST;
        if (dist != glassShield.prevDist) {
            if (Math.abs(dist - glassShield.prevDist) > 1 / max * MOVE_DIST) {
                if (dist > glassShield.prevDist)
                    glassShield.prevDist = dist - 1 / max * MOVE_DIST;
                else
                    glassShield.prevDist = dist + 1 / max * MOVE_DIST;
            }
            if (dist > glassShield.prevDist)
                glassShield.prevDist += 1 / max * MOVE_DIST / ANIMATION_STEP;
            else if (dist < glassShield.prevDist)
                glassShield.prevDist -= 1 / max * MOVE_DIST / ANIMATION_STEP;
        }
    }
}
Also used : TileEntityGlassShieldBase(club.nsdn.nyasamarailway.tileblock.signal.TileEntityGlassShieldBase)

Example 3 with TileEntityGlassShieldBase

use of club.nsdn.nyasamarailway.tileblock.signal.TileEntityGlassShieldBase in project NyaSamaRailway by NSDN.

the class GlassShieldRenderer method renderTileEntityAt.

public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {
    GL11.glPushMatrix();
    GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
    RenderHelper.disableStandardItemLighting();
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_CULL_FACE);
    if (Minecraft.isAmbientOcclusionEnabled()) {
        GL11.glShadeModel(GL11.GL_SMOOTH);
    } else {
        GL11.glShadeModel(GL11.GL_FLAT);
    }
    Tessellator.instance.setColorOpaque_F(1.0F, 1.0F, 1.0F);
    int meta = te.getWorldObj().getBlockMetadata(te.xCoord, te.yCoord, te.zCoord);
    int angle = (meta & 0x3) * 90;
    if (te instanceof TileEntityGlassShieldBase) {
        TileEntityGlassShieldBase glassShield = (TileEntityGlassShieldBase) te;
        switch(renderType) {
            case SHIELD:
                MOVE_DIST = 1.0F - (1.0F / 16.0F);
                doInterpolation(te);
                GL11.glPushMatrix();
                GL11.glRotatef(angle, 0.0F, -1.0F, 0.0F);
                GL11.glPushMatrix();
                GL11.glTranslatef(glassShield.prevDist, 0.0F, 0.0F);
                RendererHelper.renderWithResource(modelMain[MODEL_NORMAL], textureMain);
                GL11.glPopMatrix();
                GL11.glPopMatrix();
                break;
            case SHIELD_HALF:
                MOVE_DIST = 1.0F - (1.0F / 16.0F);
                doInterpolation(te);
                GL11.glPushMatrix();
                GL11.glRotatef(angle, 0.0F, -1.0F, 0.0F);
                GL11.glPushMatrix();
                GL11.glTranslatef(glassShield.prevDist, 0.0F, 0.0F);
                RendererHelper.renderWithResource(modelMain[MODEL_HALF], textureMain);
                GL11.glPopMatrix();
                GL11.glPopMatrix();
                break;
            case SHIELD_1X1:
                MOVE_DIST = 1.0F - (1.0F / 16.0F);
                if (te.getBlockType() instanceof BlockGlassShield1X1) {
                    BlockGlassShield1X1 shield1X1 = (BlockGlassShield1X1) te.getBlockType();
                    World W = te.getWorldObj();
                    int X = te.xCoord, Y = te.yCoord, Z = te.zCoord;
                    if (!shield1X1.checkShield(W, X, Y - 1, Z) && !shield1X1.checkShield(W, X, Y - 2, Z)) {
                        doInterpolation(te);
                        GL11.glPushMatrix();
                        GL11.glRotatef(angle, 0.0F, -1.0F, 0.0F);
                        GL11.glPushMatrix();
                        GL11.glTranslatef(glassShield.prevDist, 0.0F, 0.0F);
                        RendererHelper.renderWithResource(modelMain[MODEL_1X1], textureMain);
                        GL11.glPopMatrix();
                        GL11.glPopMatrix();
                    }
                }
                break;
            case SHIELD_3X1:
                MOVE_DIST = 1.0F - (1.0F / 16.0F);
                doInterpolation(te);
                GL11.glPushMatrix();
                GL11.glRotatef(angle, 0.0F, -1.0F, 0.0F);
                GL11.glPushMatrix();
                GL11.glTranslatef(0.0F, 1.0F, 0.0F);
                GL11.glPushMatrix();
                GL11.glTranslatef(glassShield.prevDist, 0.0F, 0.0F);
                RendererHelper.renderWithResource(modelMain[MODEL_3X1], textureMain);
                GL11.glPopMatrix();
                GL11.glPopMatrix();
                GL11.glPopMatrix();
                break;
            case SHIELD_3X1D5:
                MOVE_DIST = 1.5F - (1.0F / 16.0F);
                doInterpolation(te);
                GL11.glPushMatrix();
                GL11.glRotatef(angle, 0.0F, -1.0F, 0.0F);
                GL11.glPushMatrix();
                GL11.glTranslatef(0.0F, 1.0F, 0.0F);
                GL11.glPushMatrix();
                GL11.glTranslatef(glassShield.prevDist, 0.0F, 0.0F);
                RendererHelper.renderWithResource(modelMain[MODEL_3X1D5], textureMain);
                GL11.glPopMatrix();
                GL11.glPopMatrix();
                GL11.glPopMatrix();
                break;
            default:
                break;
        }
    } else {
        switch(renderType) {
            case SHIELD_AL:
                GL11.glPushMatrix();
                GL11.glRotatef(angle, 0.0F, -1.0F, 0.0F);
                GL11.glPushMatrix();
                GL11.glScalef(1.0F, 1.0F, 1.5F);
                RendererHelper.renderWithResource(modelMainAl[MODEL_NORMAL], textureMainAl);
                GL11.glPopMatrix();
                GL11.glPopMatrix();
                break;
            case SHIELD_AL_HALF:
                GL11.glPushMatrix();
                GL11.glRotatef(angle, 0.0F, -1.0F, 0.0F);
                GL11.glPushMatrix();
                GL11.glScalef(1.0F, 1.0F, 1.5F);
                RendererHelper.renderWithResource(modelMainAl[MODEL_HALF], textureMainAl);
                GL11.glPopMatrix();
                GL11.glPopMatrix();
                break;
            case SHIELD_AL_BASE:
                GL11.glPushMatrix();
                GL11.glRotatef(angle, 0.0F, -1.0F, 0.0F);
                GL11.glPushMatrix();
                GL11.glScalef(1.0F, 1.0F, 1.5F);
                RendererHelper.renderWithResource(modelMainAl[MODEL_ALBASE], textureMainAl);
                GL11.glPopMatrix();
                GL11.glPopMatrix();
                break;
            case SHIELD_CORNER:
                RendererHelper.renderWithResourceAndRotation(modelCorner[MODEL_NORMAL], angle, textureCorner);
                break;
            case SHIELD_CORNER_HALF:
                RendererHelper.renderWithResourceAndRotation(modelCorner[MODEL_HALF], angle, textureCorner);
                break;
            default:
                break;
        }
    }
    RenderHelper.enableStandardItemLighting();
    GL11.glPopMatrix();
}
Also used : BlockGlassShield1X1(club.nsdn.nyasamarailway.tileblock.signal.deco.BlockGlassShield1X1) TileEntityGlassShieldBase(club.nsdn.nyasamarailway.tileblock.signal.TileEntityGlassShieldBase) World(net.minecraft.world.World)

Aggregations

TileEntityGlassShieldBase (club.nsdn.nyasamarailway.tileblock.signal.TileEntityGlassShieldBase)3 BlockGlassShield1X1 (club.nsdn.nyasamarailway.tileblock.signal.deco.BlockGlassShield1X1)1 IIcon (net.minecraft.util.IIcon)1 World (net.minecraft.world.World)1