Search in sources :

Example 1 with PacketLetterInfo

use of forestry.mail.network.PacketLetterInfo in project ForestryMC by ForestryMC.

the class PacketHandlerMail method onPacketData.

@Override
public boolean onPacketData(int packetID, DataInputStream data, EntityPlayer player) throws IOException {
    PacketUpdate packet;
    switch(packetID) {
        case PacketIds.LETTER_INFO:
            PacketLetterInfo packetT = new PacketLetterInfo();
            packetT.readData(data);
            onLetterInfo(packetT);
            return true;
        case PacketIds.POBOX_INFO:
            PacketPOBoxInfo packetP = new PacketPOBoxInfo();
            packetP.readData(data);
            onPOBoxInfo(packetP);
            return true;
        case PacketIds.LETTER_RECIPIENT:
            packet = new PacketUpdate();
            packet.readData(data);
            onLetterRecipient(player, packet);
            return true;
        case PacketIds.LETTER_TEXT:
            packet = new PacketUpdate();
            packet.readData(data);
            onLetterText(player, packet);
            return true;
        case PacketIds.TRADING_ADDRESS_SET:
            packet = new PacketUpdate();
            packet.readData(data);
            onAddressSet(player, packet);
            return true;
        case PacketIds.POBOX_INFO_REQUEST:
            onPOBoxInfoRequest(player);
            return true;
    }
    return false;
}
Also used : PacketPOBoxInfo(forestry.mail.network.PacketPOBoxInfo) PacketUpdate(forestry.core.network.PacketUpdate) PacketLetterInfo(forestry.mail.network.PacketLetterInfo)

Example 2 with PacketLetterInfo

use of forestry.mail.network.PacketLetterInfo in project ForestryMC by ForestryMC.

the class ContainerCatalogue method detectAndSendChanges.

@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();
    if (needsSynch) {
        for (Object crafter1 : crafters) {
            ICrafting crafter = (ICrafting) crafter1;
            crafter.sendProgressBarUpdate(this, 0, stationIndex);
            crafter.sendProgressBarUpdate(this, 1, stations.size());
            crafter.sendProgressBarUpdate(this, 2, currentFilter);
        }
        Proxies.net.sendToPlayer(new PacketLetterInfo(PacketIds.LETTER_INFO, EnumAddressee.TRADER, currentTrade, null), player);
        needsSynch = false;
    }
}
Also used : ICrafting(net.minecraft.inventory.ICrafting) PacketLetterInfo(forestry.mail.network.PacketLetterInfo)

Example 3 with PacketLetterInfo

use of forestry.mail.network.PacketLetterInfo in project ForestryMC by ForestryMC.

the class ContainerLetter method handleSetRecipient.

public void handleSetRecipient(EntityPlayer player, PacketUpdate packet) {
    String recipientName = packet.payload.stringPayload[0];
    String typeName = packet.payload.stringPayload[1];
    EnumAddressee type = EnumAddressee.fromString(typeName);
    IMailAddress recipient;
    if (type == EnumAddressee.PLAYER) {
        GameProfile gameProfile = MinecraftServer.getServer().func_152358_ax().func_152655_a(recipientName);
        if (gameProfile == null) {
            gameProfile = new GameProfile(new UUID(0, 0), recipientName);
        }
        recipient = PostManager.postRegistry.getMailAddress(gameProfile);
    } else if (type == EnumAddressee.TRADER) {
        recipient = PostManager.postRegistry.getMailAddress(recipientName);
    } else {
        return;
    }
    getLetter().setRecipient(recipient);
    // Update the trading info
    if (recipient == null || recipient.isTrader()) {
        updateTradeInfo(player.worldObj, recipient);
    }
    // Update info on client
    Proxies.net.sendToPlayer(new PacketLetterInfo(PacketIds.LETTER_INFO, type, tradeInfo, recipient), player);
}
Also used : EnumAddressee(forestry.api.mail.EnumAddressee) IMailAddress(forestry.api.mail.IMailAddress) GameProfile(com.mojang.authlib.GameProfile) UUID(java.util.UUID) PacketLetterInfo(forestry.mail.network.PacketLetterInfo)

Aggregations

PacketLetterInfo (forestry.mail.network.PacketLetterInfo)3 GameProfile (com.mojang.authlib.GameProfile)1 EnumAddressee (forestry.api.mail.EnumAddressee)1 IMailAddress (forestry.api.mail.IMailAddress)1 PacketUpdate (forestry.core.network.PacketUpdate)1 PacketPOBoxInfo (forestry.mail.network.PacketPOBoxInfo)1 UUID (java.util.UUID)1 ICrafting (net.minecraft.inventory.ICrafting)1