Only displays Crosshair if hovered entity can be spectated | https://trello.com/c/CJBVrB2O/
Fixes background of lowest line of chat being opaque if Crosshair is rendered | https://trello.com/c/66veZRVH/
This commit is contained in:
@@ -2,6 +2,7 @@ package eu.crushedpixel.replaymod.events.handlers;
|
|||||||
|
|
||||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.item.EntityItemFrame;
|
import net.minecraft.entity.item.EntityItemFrame;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
@@ -13,10 +14,20 @@ public class CrosshairRenderHandler {
|
|||||||
private final Minecraft mc = Minecraft.getMinecraft();
|
private final Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onCrosshairRender(RenderGameOverlayEvent.Pre event) {
|
public void preCrosshairRender(RenderGameOverlayEvent.Pre event) {
|
||||||
//Crosshair should only render if hovered Entity can actually be spectated
|
//Crosshair should only render if hovered Entity can actually be spectated
|
||||||
if(ReplayHandler.isInReplay() && ReplayHandler.isCamera() && event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
if(ReplayHandler.isInReplay() && ReplayHandler.isCamera() && event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
||||||
event.setCanceled(!(mc.pointedEntity instanceof EntityPlayer || mc.pointedEntity instanceof EntityLiving || mc.pointedEntity instanceof EntityItemFrame));
|
boolean cancel = !(mc.pointedEntity instanceof EntityPlayer || mc.pointedEntity instanceof EntityLiving || mc.pointedEntity instanceof EntityItemFrame);
|
||||||
|
event.setCanceled(cancel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void preChatRender(RenderGameOverlayEvent.Pre event) {
|
||||||
|
if(ReplayHandler.isInReplay() && ReplayHandler.isCamera() && event.type == RenderGameOverlayEvent.ElementType.CHAT) {
|
||||||
|
//when a crosshair was displayed, the background of the lowest line of chat would be opaque
|
||||||
|
GlStateManager.enableTexture2D();
|
||||||
|
GlStateManager.disableBlend();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user