use of gregtech.api.items.toolitem.IAOEItem in project GregTech by GregTechCE.
the class ToolRenderHandler method onRenderWorldLast.
@SubscribeEvent
public void onRenderWorldLast(RenderWorldLastEvent event) {
Minecraft mc = Minecraft.getMinecraft();
// render block damage progress for all breakers
for (int breakerEntityId : event.getContext().damagedBlocks.keySet()) {
Entity breakerEntity = mc.world.getEntityByID(breakerEntityId);
if (!(breakerEntity instanceof EntityPlayer)) {
continue;
}
EntityPlayer entityPlayer = (EntityPlayer) breakerEntity;
ItemStack itemStack = entityPlayer.getHeldItem(EnumHand.MAIN_HAND);
if (!(itemStack.getItem() instanceof IAOEItem)) {
continue;
}
DestroyBlockProgress progress = event.getContext().damagedBlocks.get(breakerEntityId);
RayTraceResult rayTraceResult = RayTracer.retraceBlock(mc.world, entityPlayer, progress.getPosition());
if (rayTraceResult == null || rayTraceResult.typeOfHit != Type.BLOCK) {
continue;
}
List<BlockPos> aoeBlocksToRender = ((IAOEItem) itemStack.getItem()).getAOEBlocks(itemStack, entityPlayer, rayTraceResult);
int breakProgress = progress.getPartialBlockDamage();
preRenderDamagedBlocks();
drawBlockDamageTexture(mc, Tessellator.getInstance(), mc.getRenderViewEntity(), event.getPartialTicks(), aoeBlocksToRender, breakProgress);
postRenderDamagedBlocks();
}
// render block selection only for current player
PlayerControllerMP playerController = mc.playerController;
if (!playerController.getIsHittingBlock()) {
ItemStack itemStack = mc.player.getHeldItem(EnumHand.MAIN_HAND);
if (itemStack.getItem() instanceof IAOEItem) {
RayTraceResult rayTraceResult = RayTracer.retrace(mc.player);
if (rayTraceResult != null && rayTraceResult.typeOfHit == Type.BLOCK) {
List<BlockPos> aoeBlocksToRender = ((IAOEItem) itemStack.getItem()).getAOEBlocks(itemStack, mc.player, rayTraceResult);
preRenderSelectionOutline();
drawSelectionOutlines(mc, aoeBlocksToRender, mc.getRenderViewEntity(), event.getPartialTicks());
postRenderSelectionOutline();
}
}
}
}
Aggregations