From 825768e5222d453ccec841541680148074132b99 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 1 Jan 2016 11:55:39 -0800 Subject: [PATCH 1/2] Fix naturalist's eye lag on multiplayer servers --- .../java/forestry/core/TickHandlerCoreClient.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/forestry/core/TickHandlerCoreClient.java b/src/main/java/forestry/core/TickHandlerCoreClient.java index 723648008..1499173b4 100755 --- a/src/main/java/forestry/core/TickHandlerCoreClient.java +++ b/src/main/java/forestry/core/TickHandlerCoreClient.java @@ -10,13 +10,13 @@ ******************************************************************************/ package forestry.core; +import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; -import forestry.core.proxy.Proxies; import forestry.core.utils.GeneticsUtil; public class TickHandlerCoreClient { @@ -24,16 +24,18 @@ public class TickHandlerCoreClient { private boolean hasNaturalistEye; @SubscribeEvent - public void onPlayerTick(PlayerTickEvent event) { + public void onClientTick(TickEvent.ClientTickEvent event) { if (event.phase != Phase.END) { return; } - EntityPlayer player = event.player; + Minecraft minecraft = Minecraft.getMinecraft(); + EntityPlayer player = minecraft.thePlayer; + boolean hasNaturalistEye = GeneticsUtil.hasNaturalistEye(player); if (this.hasNaturalistEye != hasNaturalistEye) { this.hasNaturalistEye = hasNaturalistEye; - Proxies.common.getClientInstance().renderGlobal.markBlockRangeForRenderUpdate( + minecraft.renderGlobal.markBlockRangeForRenderUpdate( (int) player.posX - 32, (int) player.posY - 32, (int) player.posZ - 32, (int) player.posX + 32, (int) player.posY + 32, (int) player.posZ + 32); } From e0c1c538aab3dbb246e4fe59743a8f7f1685890a Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 10 Jan 2016 21:04:35 -0800 Subject: [PATCH 2/2] Fix ClientTickEvent crash on disconnect from server --- gradle.properties | 2 +- .../forestry/core/TickHandlerCoreClient.java | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index 266f12eea..ab9d1f9aa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,4 @@ mcversion=1.7.10 forgeversion=10.13.4.1566-1.7.10 version_major=4 version_minor=2 -version_patch=4 +version_patch=5 diff --git a/src/main/java/forestry/core/TickHandlerCoreClient.java b/src/main/java/forestry/core/TickHandlerCoreClient.java index 1499173b4..7646361b8 100755 --- a/src/main/java/forestry/core/TickHandlerCoreClient.java +++ b/src/main/java/forestry/core/TickHandlerCoreClient.java @@ -11,6 +11,7 @@ package forestry.core; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderGlobal; import net.minecraft.entity.player.EntityPlayer; import cpw.mods.fml.common.eventhandler.SubscribeEvent; @@ -30,14 +31,24 @@ public class TickHandlerCoreClient { } Minecraft minecraft = Minecraft.getMinecraft(); + if (minecraft == null) { + return; + } + EntityPlayer player = minecraft.thePlayer; + if (player == null) { + return; + } boolean hasNaturalistEye = GeneticsUtil.hasNaturalistEye(player); if (this.hasNaturalistEye != hasNaturalistEye) { this.hasNaturalistEye = hasNaturalistEye; - minecraft.renderGlobal.markBlockRangeForRenderUpdate( - (int) player.posX - 32, (int) player.posY - 32, (int) player.posZ - 32, - (int) player.posX + 32, (int) player.posY + 32, (int) player.posZ + 32); + RenderGlobal renderGlobal = minecraft.renderGlobal; + if (renderGlobal != null) { + renderGlobal.markBlockRangeForRenderUpdate( + (int) player.posX - 32, (int) player.posY - 32, (int) player.posZ - 32, + (int) player.posX + 32, (int) player.posY + 32, (int) player.posZ + 32); + } } } }