use of forestry.mail.network.packets.PacketPOBoxInfoResponse in project ForestryMC by ForestryMC.
the class PostRegistry method getOrCreatePOBox.
public static POBox getOrCreatePOBox(World world, IMailAddress address) {
POBox pobox = getPOBox(world, address);
if (pobox == null) {
pobox = new POBox(address);
world.setData(POBox.SAVE_NAME + address, pobox);
pobox.markDirty();
cachedPOBoxes.put(address, pobox);
EntityPlayer player = PlayerUtil.getPlayer(world, address.getPlayerProfile());
if (player != null) {
NetworkUtil.sendToPlayer(new PacketPOBoxInfoResponse(pobox.getPOBoxInfo()), player);
}
}
return pobox;
}
use of forestry.mail.network.packets.PacketPOBoxInfoResponse in project ForestryMC by ForestryMC.
the class EventHandlerMailAlert method handlePlayerLoggedIn.
@SubscribeEvent
public void handlePlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
EntityPlayer player = event.player;
IMailAddress address = PostManager.postRegistry.getMailAddress(player.getGameProfile());
POBox pobox = PostRegistry.getOrCreatePOBox(player.world, address);
PacketPOBoxInfoResponse packet = new PacketPOBoxInfoResponse(pobox.getPOBoxInfo());
NetworkUtil.sendToPlayer(packet, player);
}
use of forestry.mail.network.packets.PacketPOBoxInfoResponse in project ForestryMC by ForestryMC.
the class ContainerMailbox method slotClick.
@Override
public ItemStack slotClick(int slotId, int dragType_or_button, ClickType clickTypeIn, EntityPlayer player) {
ItemStack stack = super.slotClick(slotId, dragType_or_button, clickTypeIn, player);
if (SlotUtil.isSlotInRange(slotId, SLOT_LETTERS, SLOT_LETTERS_COUNT)) {
if (!player.world.isRemote && mailInventory != null) {
POBoxInfo info = mailInventory.getPOBoxInfo();
NetworkUtil.sendToPlayer(new PacketPOBoxInfoResponse(info), player);
}
}
return stack;
}
Aggregations