Search in sources :

Example 1 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project SimplyJetpacks by Tonius.

the class ItemJetpackFueller method onUsingTick.

@Override
public void onUsingTick(ItemStack itemStack, EntityPlayer player, int count) {
    MovingObjectPosition blockPos = BlockHelper.getCurrentMovingObjectPosition(player, true);
    if (blockPos == null || blockPos.sideHit < 0) {
        player.setItemInUse(null, 1);
    } else {
        player.setItemInUse(itemStack, this.getMaxItemUseDuration(itemStack));
        if (player.worldObj.isRemote) {
            return;
        }
        ItemStack chestplate = player.getCurrentArmor(2);
        if (chestplate == null || !(chestplate.getItem() instanceof ItemPack)) {
            return;
        }
        ItemPack packItem = (ItemPack) chestplate.getItem();
        PackBase pack = packItem.getPack(chestplate);
        if (pack == null) {
            return;
        }
        FuelType fuelType = pack.fuelType;
        ForgeDirection pullSide = ForgeDirection.values()[blockPos.sideHit];
        player.worldObj.getBlock(blockPos.blockX, blockPos.blockY, blockPos.blockZ);
        TileEntity tile = player.worldObj.getTileEntity(blockPos.blockX, blockPos.blockY, blockPos.blockZ);
        int toPull = Math.min(pack.fuelPerTickIn, packItem.getMaxFuelStored(chestplate) - packItem.getFuelStored(chestplate));
        int pulled = 0;
        if (fuelType == FuelType.ENERGY && tile instanceof IEnergyProvider) {
            IEnergyProvider energyTile = (IEnergyProvider) tile;
            pulled = energyTile.extractEnergy(pullSide, toPull, false);
        } else if (fuelType == FuelType.FLUID) {
            if (tile instanceof IFluidHandler) {
                IFluidHandler fluidTile = (IFluidHandler) tile;
                FluidStack fluid = fluidTile.drain(pullSide, toPull, false);
                if (fluid == null || !fluid.getFluid().getName().equals(pack.fuelFluid)) {
                    return;
                }
                fluid = fluidTile.drain(pullSide, toPull, true);
                pulled = fluid.amount;
            }
        }
        if (pulled > 0) {
            packItem.addFuel(chestplate, pulled, false);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) IEnergyProvider(cofh.api.energy.IEnergyProvider) FluidStack(net.minecraftforge.fluids.FluidStack) PackBase(tonius.simplyjetpacks.item.meta.PackBase) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ItemStack(net.minecraft.item.ItemStack) FuelType(tonius.simplyjetpacks.setup.FuelType) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Example 2 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project BluePower by Qmunity.

the class BlockContainerBase method getIcon.

@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
    if (textures == null)
        return super.getIcon(world, x, y, z, side);
    TileEntity te = get(world, x, y, z);
    RendererBlockBase.EnumFaceType faceType = EnumFaceType.SIDE;
    boolean powered = false;
    boolean ejecting = false;
    if (te instanceof IRotatable) {
        ForgeDirection rotation = ((IRotatable) te).getFacingDirection();
        if (rotation.ordinal() == side)
            faceType = EnumFaceType.FRONT;
        if (rotation.getOpposite().ordinal() == side)
            faceType = EnumFaceType.BACK;
    }
    if (te instanceof IBluePowered) {
        powered = ((IBluePowered) te).isPowered();
    }
    if (te instanceof IEjectAnimator) {
        ejecting = ((IEjectAnimator) te).isEjecting();
    }
    return getIcon(faceType, ejecting, powered, side, te);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFaceType(com.bluepowermod.client.render.RendererBlockBase.EnumFaceType) IBluePowered(com.bluepowermod.tile.IBluePowered) IRotatable(com.bluepowermod.tile.IRotatable) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IEjectAnimator(com.bluepowermod.tile.IEjectAnimator) RendererBlockBase(com.bluepowermod.client.render.RendererBlockBase) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 3 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project BluePower by Qmunity.

the class BlockCPU method getIcon.

@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
    TileCPU tile = (TileCPU) world.getTileEntity(x, y, z);
    ForgeDirection dir = tile.getFacingDirection();
    if (dir.ordinal() == side) {
        return frontTexture;
    } else if (dir.getOpposite().ordinal() == side) {
        return backTexture;
    } else if (ForgeDirection.UP.ordinal() == side) {
        return topTexture;
    } else if (ForgeDirection.DOWN.ordinal() == side) {
        return bottomTexture;
    } else {
        return sideTexture;
    }
}
Also used : TileCPU(com.bluepowermod.tile.tier3.TileCPU) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 4 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection 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 5 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project BluePower by Qmunity.

the class BlockMonitor method getIcon.

@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
    TileMonitor tile = (TileMonitor) world.getTileEntity(x, y, z);
    ForgeDirection dir = tile.getFacingDirection();
    if (dir.ordinal() == side) {
        return frontTexture;
    } else if (dir.getOpposite().ordinal() == side) {
        return backTexture;
    } else if (ForgeDirection.UP.ordinal() == side) {
        return topTexture;
    } else if (ForgeDirection.DOWN.ordinal() == side) {
        return bottomTexture;
    } else {
        return sideTexture;
    }
}
Also used : TileMonitor(com.bluepowermod.tile.tier3.TileMonitor) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Aggregations

ForgeDirection (net.minecraftforge.common.util.ForgeDirection)257 TileEntity (net.minecraft.tileentity.TileEntity)74 ItemStack (net.minecraft.item.ItemStack)38 Block (net.minecraft.block.Block)34 ArrayList (java.util.ArrayList)23 IInventory (net.minecraft.inventory.IInventory)18 SideOnly (cpw.mods.fml.relauncher.SideOnly)17 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)16 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)11 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)10 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)10 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)10 FluidStack (net.minecraftforge.fluids.FluidStack)10 Pos (com.builtbroken.mc.lib.transform.vector.Pos)8 IPneumaticMachine (pneumaticCraft.api.tileentity.IPneumaticMachine)8 Vec3dCube (uk.co.qmunity.lib.vec.Vec3dCube)8 HashMap (java.util.HashMap)7 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)7 IAirHandler (pneumaticCraft.api.tileentity.IAirHandler)7 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)7