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

The following examples show how to use codechicken.lib.packet.PacketCustom#readShort() . 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: NEIServerPacketHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private void setInventorySlot(EntityPlayerMP player, PacketCustom packet) {
    boolean container = packet.readBoolean();
    int slot = packet.readShort();
    ItemStack item = packet.readItemStack();

    ItemStack old = NEIServerUtils.getSlotContents(player, slot, container);
    boolean deleting = item.isEmpty() || !old.isEmpty() && NEIServerUtils.areStacksSameType(item, old) && item.getCount() < old.getCount();
    if (NEIServerConfig.canPlayerPerformAction(player.getName(), deleting ? "delete" : "item")) {
        NEIServerUtils.setSlotContents(player, slot, item, container);
    }
}
 
Example 2
Source File: NEISPH.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private void setInventorySlot(EntityPlayerMP player, PacketCustom packet) {
    boolean container = packet.readBoolean();
    int slot = packet.readShort();
    ItemStack item = packet.readItemStack();

    ItemStack old = NEIServerUtils.getSlotContents(player, slot, container);
    boolean deleting = item == null || old != null && NEIServerUtils.areStacksSameType(item, old) && item.stackSize < old.stackSize;
    if (NEIServerConfig.canPlayerPerformAction(player.getCommandSenderName(), deleting ? "delete" : "item"))
        NEIServerUtils.setSlotContents(player, slot, item, container);
}
 
Example 3
Source File: WRAddonCPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
private static void processMapInfo(World world, EntityPlayer player, PacketCustom packet) {
    short mapno = packet.readShort();
    int xCenter = packet.readInt();
    int zCenter = packet.readInt();
    byte scale = packet.readByte();
    RedstoneEtherAddons.client().setMPMapInfo(mapno, new ClientMapInfo(xCenter, zCenter, scale));
}