use of com.bluepowermod.tile.IRotatable 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 com.bluepowermod.tile.IRotatable in project BluePower by Qmunity.
the class BlockContainerBase method onBlockPlacedBy.
/**
* Method to detect how the block was placed, and what way it's facing.
*/
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack iStack) {
BPApi.getInstance().loadSilkySettings(world, x, y, z, iStack);
TileEntity te = get(world, x, y, z);
if (te instanceof IRotatable) {
((IRotatable) te).setFacingDirection(ForgeDirectionUtils.getDirectionFacing(player, canRotateVertical()).getOpposite());
}
}
use of com.bluepowermod.tile.IRotatable in project BluePower by Qmunity.
the class BlockIgniter method rotateBlock.
@Override
public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) {
TileEntity te = worldObj.getTileEntity(x, y, z);
if (te instanceof IRotatable) {
IRotatable rotatable = (IRotatable) te;
ForgeDirection dir = rotatable.getFacingDirection();
Block target = worldObj.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if (target == Blocks.fire || target == Blocks.portal) {
worldObj.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, Blocks.air);
}
dir = dir.getRotation(axis);
if (dir != ForgeDirection.UP && dir != ForgeDirection.DOWN || canRotateVertical()) {
rotatable.setFacingDirection(dir);
return true;
}
}
return false;
}
use of com.bluepowermod.tile.IRotatable in project BluePower by Qmunity.
the class BlockProjectTable method getIcon.
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
IRotatable rotatable = (IRotatable) world.getTileEntity(x, y, z);
ForgeDirection s = ForgeDirection.getOrientation(side);
if (rotatable.getFacingDirection() == s) {
return textureFront;
}
switch(s) {
case UP:
return textureTop;
case DOWN:
return textureBottom;
case EAST:
case NORTH:
case SOUTH:
case WEST:
case UNKNOWN:
return textureSide;
default:
break;
}
return null;
}
use of com.bluepowermod.tile.IRotatable in project BluePower by Qmunity.
the class RendererBlockBase method renderWorldBlock.
/*
* UV Deobfurscation derp: West = South East = North North = East South = West
*/
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof IRotatable) {
switch(((IRotatable) te).getFacingDirection()) {
case DOWN:
renderer.uvRotateSouth = 3;
renderer.uvRotateNorth = 3;
renderer.uvRotateEast = 3;
renderer.uvRotateWest = 3;
break;
case NORTH:
renderer.uvRotateSouth = 1;
renderer.uvRotateNorth = 2;
break;
case SOUTH:
renderer.uvRotateSouth = 2;
renderer.uvRotateNorth = 1;
renderer.uvRotateTop = 3;
renderer.uvRotateBottom = 3;
break;
case WEST:
renderer.uvRotateEast = 1;
renderer.uvRotateWest = 2;
renderer.uvRotateTop = 2;
renderer.uvRotateBottom = 1;
break;
case EAST:
renderer.uvRotateEast = 2;
renderer.uvRotateWest = 1;
renderer.uvRotateTop = 1;
renderer.uvRotateBottom = 2;
break;
default:
break;
}
}
boolean ret = renderer.renderStandardBlock(block, x, y, z);
renderer.uvRotateSouth = 0;
renderer.uvRotateEast = 0;
renderer.uvRotateWest = 0;
renderer.uvRotateNorth = 0;
renderer.uvRotateTop = 0;
renderer.uvRotateBottom = 0;
return ret;
}
Aggregations