use of omtteam.openmodularturrets.items.blocks.ItemBlockBaseAddon in project OpenModularTurrets by OpenModularTurretsTeam.
the class EventHandler method drawBlockOutline.
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void drawBlockOutline(DrawBlockHighlightEvent event) {
if (event.getTarget() != null && event.getTarget().getBlockPos() != null && event.getTarget().sideHit != null && event.getPlayer().getHeldItemMainhand() != null && event.getPlayer().getHeldItemMainhand().getItem() instanceof ItemBlockBaseAddon) {
BlockPos blockpos = event.getTarget().getBlockPos().offset(event.getTarget().sideHit);
if (getTurretBase(event.getPlayer().getEntityWorld(), blockpos) != null) {
ItemBlockBaseAddon addon = (ItemBlockBaseAddon) event.getPlayer().getHeldItemMainhand().getItem();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.glLineWidth(2.0F);
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
AxisAlignedBB alignedBB;
EnumFacing facing = getTurretBaseFacing(event.getPlayer().getEntityWorld(), blockpos);
if (addon.getBlock().getDefaultState().getProperties().containsKey(FACING)) {
alignedBB = addon.getRenderOutline(addon.getBlock().getDefaultState().withProperty(FACING, facing), event.getPlayer().getEntityWorld(), blockpos);
} else {
alignedBB = addon.getRenderOutline(addon.getBlock().getDefaultState(), event.getPlayer().getEntityWorld(), blockpos);
}
EntityPlayer player = event.getPlayer();
double partialTicks = event.getPartialTicks();
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
float[] color = new float[3];
if (event.getPlayer().getEntityWorld().isAirBlock(blockpos)) {
color[0] = 0F;
color[1] = 1F;
color[2] = 1F;
} else {
color[0] = 1F;
color[1] = 0F;
color[2] = 0F;
}
alignedBB = alignedBB.offset(-d0, -d1, -d2);
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexbuffer = tessellator.getBuffer();
vertexbuffer.begin(3, DefaultVertexFormats.POSITION_COLOR);
drawHighlightBox(vertexbuffer, alignedBB.minX, alignedBB.minY, alignedBB.minZ, alignedBB.maxX, alignedBB.maxY, alignedBB.maxZ, color[0], color[1], color[2], 0.5F);
tessellator.draw();
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
}
}
}
Aggregations