use of net.minecraft.tileentity.TileEntity in project BetterStorage by copygirl.
the class ClientProxy method drawBlockHighlight.
@SubscribeEvent
public void drawBlockHighlight(DrawBlockHighlightEvent event) {
EntityPlayer player = event.player;
World world = player.worldObj;
MovingObjectPosition target = WorldUtils.rayTrace(player, event.partialTicks);
if ((target == null) || (target.typeOfHit != MovingObjectType.BLOCK))
return;
int x = target.blockX;
int y = target.blockY;
int z = target.blockZ;
AxisAlignedBB box = null;
Block block = world.getBlock(x, y, z);
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (block instanceof TileArmorStand)
box = getArmorStandHighlightBox(player, world, x, y, z, target.hitVec);
else if (block == Blocks.iron_door)
box = getIronDoorHightlightBox(player, world, x, y, z, target.hitVec, block);
else if (tileEntity instanceof IHasAttachments)
box = getAttachmentPointsHighlightBox(player, tileEntity, target);
if (box == null)
return;
double xOff = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.partialTicks;
double yOff = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.partialTicks;
double zOff = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.partialTicks;
box.offset(-xOff, -yOff, -zOff);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F);
GL11.glLineWidth(2.0F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(false);
RenderGlobal.drawOutlinedBoundingBox(box, -1);
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
event.setCanceled(true);
}
use of net.minecraft.tileentity.TileEntity 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.minecraft.tileentity.TileEntity 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 net.minecraft.tileentity.TileEntity 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 net.minecraft.tileentity.TileEntity in project BluePower by Qmunity.
the class MessageSyncMachineBacklog method handleClientSide.
@Override
public void handleClientSide(EntityPlayer player) {
TileEntity te = player.worldObj.getTileEntity(x, y, z);
if (te instanceof TileMachineBase) {
((TileMachineBase) te).setBacklog(stacks);
GuiContainerBase gui = (GuiContainerBase) ClientProxy.getOpenedGui();
if (gui != null)
gui.redraw();
}
}
Aggregations