From 388ed14d9ae91ab91799b1425a43abc8f1f67058 Mon Sep 17 00:00:00 2001 From: glowredman <35727266+glowredman@users.noreply.github.com> Date: Thu, 27 Jul 2023 21:41:56 +0200 Subject: [PATCH] Use PlayerLoggedInEvent instead of EntityJoinWorldEvent --- .../visualprospecting/hooks/HooksEventBus.java | 17 ----------------- .../visualprospecting/hooks/HooksFML.java | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/sinthoras/visualprospecting/hooks/HooksEventBus.java b/src/main/java/com/sinthoras/visualprospecting/hooks/HooksEventBus.java index 45d7bbff..7f9350f9 100644 --- a/src/main/java/com/sinthoras/visualprospecting/hooks/HooksEventBus.java +++ b/src/main/java/com/sinthoras/visualprospecting/hooks/HooksEventBus.java @@ -1,16 +1,10 @@ package com.sinthoras.visualprospecting.hooks; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.world.WorldEvent; import com.sinthoras.visualprospecting.Utils; -import com.sinthoras.visualprospecting.VP; import com.sinthoras.visualprospecting.database.ClientCache; import com.sinthoras.visualprospecting.database.ServerCache; -import com.sinthoras.visualprospecting.database.WorldIdHandler; -import com.sinthoras.visualprospecting.network.WorldIdNotification; import cpw.mods.fml.common.eventhandler.SubscribeEvent; @@ -27,15 +21,4 @@ public void onEvent(WorldEvent.Unload event) { public void onEvent(WorldEvent.Save event) { ServerCache.instance.saveVeinCache(); } - - @SubscribeEvent - public void onEvent(EntityJoinWorldEvent event) { - if (event.world.isRemote == false) { - if (event.entity instanceof EntityPlayerMP) { - VP.network.sendTo(new WorldIdNotification(WorldIdHandler.getWorldId()), (EntityPlayerMP) event.entity); - } else if (event.entity instanceof EntityPlayer) { - ClientCache.instance.loadVeinCache(WorldIdHandler.getWorldId()); - } - } - } } diff --git a/src/main/java/com/sinthoras/visualprospecting/hooks/HooksFML.java b/src/main/java/com/sinthoras/visualprospecting/hooks/HooksFML.java index 530734e5..31c6297f 100644 --- a/src/main/java/com/sinthoras/visualprospecting/hooks/HooksFML.java +++ b/src/main/java/com/sinthoras/visualprospecting/hooks/HooksFML.java @@ -1,9 +1,17 @@ package com.sinthoras.visualprospecting.hooks; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; + +import com.sinthoras.visualprospecting.VP; import com.sinthoras.visualprospecting.database.ClientCache; +import com.sinthoras.visualprospecting.database.WorldIdHandler; +import com.sinthoras.visualprospecting.network.WorldIdNotification; import com.sinthoras.visualprospecting.task.TaskManager; +import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.network.FMLNetworkEvent; @@ -18,4 +26,13 @@ public void onEvent(FMLNetworkEvent.ClientConnectedToServerEvent event) { public void onEvent(TickEvent event) { TaskManager.instance.onTick(); } + + @SubscribeEvent(priority = EventPriority.LOW) + public void onEvent(PlayerEvent.PlayerLoggedInEvent event) { + if (event.player instanceof EntityPlayerMP playerMP) { + VP.network.sendTo(new WorldIdNotification(WorldIdHandler.getWorldId()), playerMP); + } else if (event.player instanceof EntityPlayer) { + ClientCache.instance.loadVeinCache(WorldIdHandler.getWorldId()); + } + } }