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);
}
}
}
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);
}
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;
}
}
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();
}
}
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;
}
}
Aggregations