mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-17 02:45:17 +00:00
Fix #1560 network sync issue for genome tracker when player logs in
This commit is contained in:
1 parent
79cf866a96
commit
7c00ea2965
8 files changed
+111
-52
No files matched your search
@@ -10,39 +10,32 @@
|
||||
******************************************************************************/
|
||||
package forestry.mail;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.mail.gui.GuiMailboxInfo;
|
||||
import forestry.mail.network.packets.PacketPOBoxInfoRequest;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
|
||||
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.mail.gui.GuiMailboxInfo;
|
||||
import forestry.mail.network.packets.PacketPOBoxInfoUpdate;
|
||||
|
||||
public class EventHandlerMailAlert {
|
||||
@SubscribeEvent
|
||||
public void onRenderTick(TickEvent.RenderTickEvent event) {
|
||||
if (event.phase != Phase.END) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Minecraft.getMinecraft().theWorld != null && GuiMailboxInfo.instance.hasPOBoxInfo()) {
|
||||
if (event.phase == Phase.END &&
|
||||
Minecraft.getMinecraft().theWorld != null &&
|
||||
GuiMailboxInfo.instance.hasPOBoxInfo()) {
|
||||
GuiMailboxInfo.instance.render();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void handlePlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
EntityPlayer player = event.player;
|
||||
if (player != null) {
|
||||
MailAddress address = new MailAddress(player.getGameProfile());
|
||||
POBox pobox = PostRegistry.getOrCreatePOBox(player.worldObj, address);
|
||||
if (pobox != null) {
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfoUpdate(pobox.getPOBoxInfo()), player);
|
||||
}
|
||||
public void handleWorldLoad(WorldEvent.Load event) {
|
||||
World world = event.getWorld();
|
||||
if (world.isRemote) {
|
||||
PacketPOBoxInfoRequest packet = new PacketPOBoxInfoRequest();
|
||||
world.sendPacketToServer(packet.getPacket());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user