Java Code Examples for codechicken.lib.packet.PacketCustom#readUByte()

The following examples show how to use codechicken.lib.packet.PacketCustom#readUByte() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnderStorageCPH.java    From EnderStorage with MIT License 6 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, Minecraft mc, IClientPlayNetHandler handler) {
    switch (packet.getType()) {
        case 1:
            handleTilePacket(mc.world, packet, packet.readPos());
            break;
        case 2:
            int windowID = packet.readUByte();
            //                ((EnderItemStorage) EnderStorageManager.instance(true).getStorage(Frequency.readFromPacket(packet), EnderItemStorage.TYPE)).openClientGui(windowID, mc.player.inventory, packet.readString(), packet.readUByte());
            break;
        case 3:
            EnderStorageManager.instance(true).getStorage(Frequency.readFromPacket(packet), EnderItemStorage.TYPE).setClientOpen(packet.readBoolean() ? 1 : 0);
            break;
        case 4:
            TankSynchroniser.syncClient(Frequency.readFromPacket(packet), packet.readFluidStack());
            break;
        case 5:
        case 6:
            handleTankTilePacket(mc.world, packet.readPos(), packet);
            break;
    }
}
 
Example 2
Source File: EnderStorageCPH.java    From EnderStorage with MIT License 6 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, Minecraft mc, INetHandlerPlayClient handler) {
    switch (packet.getType()) {
        case 1:
            handleTilePacket(mc.theWorld, packet, packet.readCoord());
            break;
        case 2:
            int windowID = packet.readUByte();

            ((EnderItemStorage) EnderStorageManager.instance(true).getStorage(packet.readString(), packet.readUShort(), "item"))
                    .openClientGui(windowID, mc.thePlayer.inventory, packet.readString(), packet.readUByte());
            break;
        case 3:
            ((EnderItemStorage) EnderStorageManager.instance(true).getStorage(packet.readString(), packet.readUShort(), "item"))
                    .setClientOpen(packet.readBoolean() ? 1 : 0);
            break;
        case 4:
            TankSynchroniser.syncClient(packet.readUShort(), packet.readString(), packet.readFluidStack());
            break;
        case 5:
        case 6:
            handleTankTilePacket(mc.theWorld, packet.readCoord(), packet);
            break;
    }
}
 
Example 3
Source File: PlayerChunkViewer.java    From ChickenChunks with MIT License 6 votes vote down vote up
public TicketInfo(PacketCustom packet, WorldClient world)
{
    ID = packet.readInt();
    modId = packet.readString();
    if(packet.readBoolean())
        player = packet.readString();
    type = net.minecraftforge.common.ForgeChunkManager.Type.values()[packet.readUByte()];
    if(type == net.minecraftforge.common.ForgeChunkManager.Type.ENTITY)
        entity = world.getEntityByID(packet.readInt());
    int chunks = packet.readUShort();
    chunkSet = new HashSet<ChunkCoordIntPair>(chunks);
    for(int i = 0; i < chunks; i++)
    {
        chunkSet.add(new ChunkCoordIntPair(packet.readInt(), packet.readInt()));
    }
}
 
Example 4
Source File: NEICPH.java    From NotEnoughItems with MIT License 6 votes vote down vote up
private void handleLoginState(PacketCustom packet) {
    NEIClientConfig.permissableActions.clear();
    int num = packet.readUByte();
    for (int i = 0; i < num; i++)
        NEIClientConfig.permissableActions.add(packet.readString());

    NEIClientConfig.disabledActions.clear();
    num = packet.readUByte();
    for (int i = 0; i < num; i++)
        NEIClientConfig.disabledActions.add(packet.readString());

    NEIClientConfig.enabledActions.clear();
    num = packet.readUByte();
    for (int i = 0; i < num; i++)
        NEIClientConfig.enabledActions.add(packet.readString());

    NEIClientConfig.bannedBlocks.clear();
    num = packet.readInt();
    for(int i = 0; i < num; i++)
        NEIClientConfig.bannedBlocks.add(packet.readItemStack());

    if (NEIClientUtils.getGuiContainer() != null)
        LayoutManager.instance().refresh(NEIClientUtils.getGuiContainer());
}
 
Example 5
Source File: ContainerPotionCreator.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void handleInputPacket(PacketCustom packet) {
    ItemStack potion = potionInv.getStackInSlot(0);
    if (potion == null)
        return;

    boolean add = packet.readBoolean();
    int effectID = packet.readUByte();

    NBTTagList effects = potion.getTagCompound().getTagList("CustomPotionEffects", 10);
    NBTTagList newEffects = new NBTTagList();
    for(int i = 0; i < effects.tagCount(); i++) {
        NBTTagCompound tag = effects.getCompoundTagAt(i);
        PotionEffect e = PotionEffect.readCustomPotionEffectFromNBT(tag);
        if(e.getPotionID() != effectID)
            newEffects.appendTag(tag);
    }
    if(add)
        newEffects.appendTag(new PotionEffect(effectID, packet.readInt(), packet.readUByte()).writeCustomPotionEffectToNBT(new NBTTagCompound()));
    potion.getTagCompound().setTag("CustomPotionEffects", newEffects);
}
 
Example 6
Source File: TileTranslocator.java    From Translocators with MIT License 6 votes vote down vote up
@Override
public void handleDescriptionPacket(PacketCustom packet)
{
    if(packet.getType() == 1)
    {
        int attachmask = packet.readUByte();
        for(int i = 0; i < 6; i++)
        {
            if((attachmask&1<<i) != 0)
            {
                boolean described = attachments[i] != null;
                if(!described)
                    createAttachment(i);
                attachments[i].read(packet, described);
            }
            else
                attachments[i] = null;
        }
        
        worldObj.func_147479_m(xCoord, yCoord, zCoord);
    }
}
 
Example 7
Source File: TranslocatorCPH.java    From Translocators with MIT License 6 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, Minecraft mc, INetHandlerPlayClient handler) {
    switch (packet.getType()) {
        case 1:
        case 2:
        case 3:
            TileEntity tile = mc.theWorld.getTileEntity(packet.readInt(), packet.readInt(), packet.readInt());
            if (tile instanceof ICustomPacketTile)
                ((ICustomPacketTile) tile).handleDescriptionPacket(packet);
            break;
        case 4:
            int windowId = packet.readUByte();
            GuiTranslocator gui = new GuiTranslocator(new ContainerItemTranslocator(
                    new InventorySimple(9, packet.readUShort(), packet.readString()), mc.thePlayer.inventory));
            ClientUtils.openSMPGui(windowId, gui);
            break;
        case 5:
            mc.thePlayer.openContainer.putStackInSlot(packet.readUByte(), packet.readItemStack(true));
            break;
    }
}
 
Example 8
Source File: NEIClientPacketHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
/**
 * Handles the LoginState sent by the server.
 * Resets and loads from the packet the following things:
 * Permissible actions.
 * Disabled actions.
 * Enabled actions.
 * Banned items.
 *
 * @param packet Packet to handle.
 */
private void handleLoginState(PacketCustom packet) {
    NEIClientConfig.permissibleActions.clear();
    int num = packet.readUByte();
    for (int i = 0; i < num; i++) {
        NEIClientConfig.permissibleActions.add(packet.readString());
    }

    NEIClientConfig.disabledActions.clear();
    num = packet.readUByte();
    for (int i = 0; i < num; i++) {
        NEIClientConfig.disabledActions.add(packet.readString());
    }

    NEIClientConfig.enabledActions.clear();
    num = packet.readUByte();
    for (int i = 0; i < num; i++) {
        NEIClientConfig.enabledActions.add(packet.readString());
    }

    NEIClientConfig.bannedItems.clear();
    num = packet.readInt();
    for (int i = 0; i < num; i++) {
        NEIClientConfig.bannedItems.add(packet.readItemStack());
    }

    if (NEIClientUtils.getGuiContainer() != null) {
        LayoutManager.instance().refresh(NEIClientUtils.getGuiContainer());
    }
}
 
Example 9
Source File: TileEnderTank.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
public void handleDescriptionPacket(PacketCustom desc) {
    super.handleDescriptionPacket(desc);
    rotation = desc.readUByte();
    liquid_state.s_liquid = desc.readFluidStack();
    pressure_state.a_pressure = desc.readBoolean();
    if (!described) {
        liquid_state.c_liquid = liquid_state.s_liquid;
        pressure_state.b_rotate = pressure_state.a_rotate = pressure_state.approachRotate();
    }
    described = true;
}
 
Example 10
Source File: TileItemTranslocator.java    From Translocators with MIT License 5 votes vote down vote up
public MovingItem(PacketCustom packet)
{
    int b = packet.readUByte();
    src = b>>4;
    dst = b&0xF;
    stack = packet.readItemStack();
}
 
Example 11
Source File: TileCraftingGrid.java    From Translocators with MIT License 5 votes vote down vote up
@Override
public void handleDescriptionPacket(PacketCustom packet) {
    rotation = packet.readUByte();

    for (int i = 0; i < 9; i++)
        items[i] = packet.readItemStack();

    updateResult();
}
 
Example 12
Source File: WRCoreSPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
private void handleFreqInfo(PacketCustom packet) {
    int freq = packet.readUShort();
    String name = packet.readString();
    int colourid = packet.readUByte();

    RedstoneEther.get(false).setFreqName(freq, name);
    RedstoneEther.get(false).setFreqColour(freq, colourid);

    sendSetFreqInfoTo(null, freq, name, colourid);
}
 
Example 13
Source File: TileEnderChest.java    From EnderStorage with MIT License 4 votes vote down vote up
@Override
public void handleDescriptionPacket(PacketCustom desc)
{
    super.handleDescriptionPacket(desc);
    rotation = desc.readUByte();
}