Search in sources :

Example 1 with TileArmorStand

use of net.mcft.copy.betterstorage.tile.stand.TileArmorStand 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);
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) TileArmorStand(net.mcft.copy.betterstorage.tile.stand.TileArmorStand) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) World(net.minecraft.world.World) IHasAttachments(net.mcft.copy.betterstorage.attachment.IHasAttachments) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 IHasAttachments (net.mcft.copy.betterstorage.attachment.IHasAttachments)1 TileArmorStand (net.mcft.copy.betterstorage.tile.stand.TileArmorStand)1 Block (net.minecraft.block.Block)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 TileEntity (net.minecraft.tileentity.TileEntity)1 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)1 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)1 World (net.minecraft.world.World)1