Skip to content

Commit

Permalink
Use PlayerLoggedInEvent instead of EntityJoinWorldEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
glowredman committed Jul 29, 2023
1 parent afd991b commit 388ed14
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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());
}
}
}
}
17 changes: 17 additions & 0 deletions src/main/java/com/sinthoras/visualprospecting/hooks/HooksFML.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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());
}
}
}

0 comments on commit 388ed14

Please sign in to comment.