Search in sources :

Example 1 with TileEngine

use of com.bluepowermod.tile.tier3.TileEngine in project BluePower by Qmunity.

the class RenderEngine method renderTileEntityAt.

@SuppressWarnings("cast")
@Override
public void renderTileEntityAt(TileEntity engine, double x, double y, double z, float f) {
    if (engine instanceof TileEngine) {
        GL11.glPushMatrix();
        GL11.glDisable(GL11.GL_LIGHTING);
        TileEngine tile = (TileEngine) engine.getWorldObj().getTileEntity(engine.xCoord, engine.yCoord, engine.zCoord);
        ForgeDirection direction = tile.getOrientation();
        GL11.glTranslated(x, y, z);
        GL11.glScaled(.0315, .0315, .0315);
        if (direction == ForgeDirection.UP) {
            GL11.glTranslated(16, 28, 16);
            GL11.glRotatef(180, 1, 0, 0);
        }
        if (direction == ForgeDirection.DOWN) {
            GL11.glTranslated(16, 4, 16);
            GL11.glRotatef(0, 0, 0, 0);
        }
        if (direction == ForgeDirection.EAST) {
            GL11.glTranslated(28, 16, 16);
            GL11.glRotatef(90, 0, 0, 1);
        }
        if (direction == ForgeDirection.WEST) {
            GL11.glTranslated(4, 16, 16);
            GL11.glRotatef(90, 0, 0, -1);
        }
        if (direction == ForgeDirection.NORTH) {
            GL11.glTranslated(16, 16, 4);
            GL11.glRotatef(90, 1, 0, 0);
        }
        if (direction == ForgeDirection.SOUTH) {
            GL11.glTranslated(16, 16, 28);
            GL11.glRotatef(90, -1, 0, 0);
        }
        if (tile.isActive) {
            bindTexture(textureLocationOn);
        } else {
            bindTexture(textureLocationOff);
        }
        engineModel.renderAllExcept("gear", "glider");
        if (tile.isActive) {
            f += tile.pumpTick;
            if (tile.pumpSpeed > 0) {
                f /= tile.pumpSpeed;
            }
        } else {
            f = 0;
        }
        f = (float) ((float) 6 * (.5 - .5 * Math.cos(3.1415926535897931D * (double) f)));
        GL11.glTranslatef(0, f, 0);
        engineModel.renderPart("glider");
        GL11.glTranslatef(0, -f, 0);
        if (tile.isActive) {
            if (tile.getWorldObj().isRemote) {
                rotateAmount++;
                GL11.glRotated(tile.gearTick * 19, 0, 1.5707963267948966D * (double) f, 0);
            }
        }
        engineModel.renderPart("gear");
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glPopMatrix();
    }
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) TileEngine(com.bluepowermod.tile.tier3.TileEngine)

Example 2 with TileEngine

use of com.bluepowermod.tile.tier3.TileEngine in project BluePower by Qmunity.

the class BlockEngine method onBlockActivated.

@SuppressWarnings("cast")
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
    if (player.inventory.getCurrentItem() != null) {
        Item item = player.inventory.getCurrentItem().getItem();
        if (item == BPItems.screwdriver) {
            if (!world.isRemote) {
                int direction = 0;
                int facing = 0;
                if (player.rotationPitch > 45) {
                    facing = 5;
                } else if (player.rotationPitch < -45) {
                    facing = 4;
                } else {
                    facing = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
                }
                TileEngine engine = (TileEngine) world.getTileEntity(x, y, z);
                if (facing == 0) {
                    if (player.isSneaking())
                        direction = ForgeDirection.NORTH.ordinal();
                    direction = ForgeDirection.SOUTH.ordinal();
                } else if (facing == 1) {
                    if (player.isSneaking())
                        direction = ForgeDirection.EAST.ordinal();
                    direction = ForgeDirection.WEST.ordinal();
                } else if (facing == 2) {
                    if (player.isSneaking())
                        direction = ForgeDirection.SOUTH.ordinal();
                    direction = ForgeDirection.NORTH.ordinal();
                } else if (facing == 3) {
                    if (player.isSneaking())
                        direction = ForgeDirection.WEST.ordinal();
                    direction = ForgeDirection.EAST.ordinal();
                } else if (facing == 4) {
                    if (player.isSneaking())
                        direction = ForgeDirection.DOWN.ordinal();
                    direction = ForgeDirection.UP.ordinal();
                } else if (facing == 5) {
                    if (player.isSneaking())
                        direction = ForgeDirection.UP.ordinal();
                    direction = ForgeDirection.DOWN.ordinal();
                }
                engine.setOrientation(direction);
                world.markBlockForUpdate(x, y, z);
            }
        }
    }
    return false;
}
Also used : Item(net.minecraft.item.Item) TileEngine(com.bluepowermod.tile.tier3.TileEngine)

Example 3 with TileEngine

use of com.bluepowermod.tile.tier3.TileEngine in project BluePower by Qmunity.

the class BlockEngine method onBlockPlacedBy.

@SuppressWarnings("cast")
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
    if (world.getTileEntity(x, y, z) instanceof TileEngine) {
        int direction = 0;
        int facing;
        if (player.rotationPitch > 45) {
            facing = 5;
        } else if (player.rotationPitch < -45) {
            facing = 4;
        } else {
            facing = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
        }
        if (facing == 0) {
            direction = ForgeDirection.SOUTH.ordinal();
        } else if (facing == 1) {
            direction = ForgeDirection.WEST.ordinal();
        } else if (facing == 2) {
            direction = ForgeDirection.NORTH.ordinal();
        } else if (facing == 3) {
            direction = ForgeDirection.EAST.ordinal();
        } else if (facing == 4) {
            direction = ForgeDirection.UP.ordinal();
        } else if (facing == 5) {
            direction = ForgeDirection.DOWN.ordinal();
        }
        TileEngine tile = (TileEngine) world.getTileEntity(x, y, z);
        tile.setOrientation(direction);
    }
}
Also used : TileEngine(com.bluepowermod.tile.tier3.TileEngine)

Aggregations

TileEngine (com.bluepowermod.tile.tier3.TileEngine)3 Item (net.minecraft.item.Item)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1