mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 17:44:55 +00:00
Sync mail to client on login, do not display mail indicator on logout
This commit is contained in:
1 parent
d0c8c92863
commit
e2f32ab767
8 files changed
+31
-70
No files matched your search
@@ -0,0 +1,48 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.mail;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
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.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()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user