Search in sources :

Example 1 with PacketPOBoxInfoResponse

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;
}
Also used : PacketPOBoxInfoResponse(forestry.mail.network.packets.PacketPOBoxInfoResponse) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 2 with PacketPOBoxInfoResponse

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);
}
Also used : IMailAddress(forestry.api.mail.IMailAddress) PacketPOBoxInfoResponse(forestry.mail.network.packets.PacketPOBoxInfoResponse) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with PacketPOBoxInfoResponse

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;
}
Also used : PacketPOBoxInfoResponse(forestry.mail.network.packets.PacketPOBoxInfoResponse) POBoxInfo(forestry.mail.POBoxInfo) ItemStack(net.minecraft.item.ItemStack)

Aggregations

PacketPOBoxInfoResponse (forestry.mail.network.packets.PacketPOBoxInfoResponse)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 IMailAddress (forestry.api.mail.IMailAddress)1 POBoxInfo (forestry.mail.POBoxInfo)1 ItemStack (net.minecraft.item.ItemStack)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1