From d7dde42add73db33c7b068ac12faa24d5a450714 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Sat, 27 Feb 2021 14:44:34 +0100 Subject: [PATCH] Move HideInvisibleEntities into 1.12.2 project --- .../HideInvisibleEntities.java | 33 +------------------ .../HideInvisibleEntities.java | 30 +++++++++++++++++ 2 files changed, 31 insertions(+), 32 deletions(-) create mode 100644 versions/1.12.2/src/main/java/com/replaymod/compat/oranges17animations/HideInvisibleEntities.java diff --git a/src/main/java/com/replaymod/compat/oranges17animations/HideInvisibleEntities.java b/src/main/java/com/replaymod/compat/oranges17animations/HideInvisibleEntities.java index 75ac3000..fca4cd6c 100644 --- a/src/main/java/com/replaymod/compat/oranges17animations/HideInvisibleEntities.java +++ b/src/main/java/com/replaymod/compat/oranges17animations/HideInvisibleEntities.java @@ -1,32 +1 @@ -//#if MC<11400 -//$$ package com.replaymod.compat.oranges17animations; -//$$ -//$$ import com.replaymod.replay.camera.CameraEntity; -//$$ import de.johni0702.minecraft.gui.utils.EventRegistrations; -//$$ import net.minecraft.client.Minecraft; -//$$ import net.minecraftforge.client.event.RenderLivingEvent; -//$$ import net.minecraftforge.fml.common.eventhandler.EventPriority; -//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -//$$ -//$$ import static com.replaymod.core.versions.MCVer.*; -//$$ -//$$ /** -//$$ * Orange seems to have copied vast parts of the RendererLivingEntity into their ArmorAnimation class which cancels the RenderLivingEvent.Pre and calls its own code instead. -//$$ * This breaks our mixin which assures that, even though the camera is in spectator mode, it cannot see invisible entities. -//$$ * -//$$ * To fix this issue, we simply cancel the RenderLivingEvent.Pre before it gets to ArmorAnimation if the entity is invisible. -//$$ */ -//$$ public class HideInvisibleEntities extends EventRegistrations { -//$$ private final Minecraft mc = Minecraft.getMinecraft(); -//$$ private final boolean modLoaded = isModLoaded("animations"); -//$$ -//$$ @SubscribeEvent(priority = EventPriority.HIGH) -//$$ public void preRenderLiving(RenderLivingEvent.Pre event) { -//$$ if (modLoaded) { -//$$ if (mc.player instanceof CameraEntity && getEntity(event).isInvisible()) { -//$$ event.setCanceled(true); -//$$ } -//$$ } -//$$ } -//$$ } -//#endif +// 1.12.2 and below diff --git a/versions/1.12.2/src/main/java/com/replaymod/compat/oranges17animations/HideInvisibleEntities.java b/versions/1.12.2/src/main/java/com/replaymod/compat/oranges17animations/HideInvisibleEntities.java new file mode 100644 index 00000000..d97a953a --- /dev/null +++ b/versions/1.12.2/src/main/java/com/replaymod/compat/oranges17animations/HideInvisibleEntities.java @@ -0,0 +1,30 @@ +package com.replaymod.compat.oranges17animations; + +import com.replaymod.replay.camera.CameraEntity; +import de.johni0702.minecraft.gui.utils.EventRegistrations; +import net.minecraft.client.Minecraft; +import net.minecraftforge.client.event.RenderLivingEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import static com.replaymod.core.versions.MCVer.*; + +/** + * Orange seems to have copied vast parts of the RendererLivingEntity into their ArmorAnimation class which cancels the RenderLivingEvent.Pre and calls its own code instead. + * This breaks our mixin which assures that, even though the camera is in spectator mode, it cannot see invisible entities. + * + * To fix this issue, we simply cancel the RenderLivingEvent.Pre before it gets to ArmorAnimation if the entity is invisible. + */ +public class HideInvisibleEntities extends EventRegistrations { + private final Minecraft mc = Minecraft.getMinecraft(); + private final boolean modLoaded = isModLoaded("animations"); + + @SubscribeEvent(priority = EventPriority.HIGH) + public void preRenderLiving(RenderLivingEvent.Pre event) { + if (modLoaded) { + if (mc.player instanceof CameraEntity && getEntity(event).isInvisible()) { + event.setCanceled(true); + } + } + } +}