mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-26 23:13:21 +00:00
extracting items from network via inventory panel GUI
This commit is contained in:
1 parent
b2684cd757
commit
c28dc83c79
10 files changed
+242
-22
No files matched your search
@@ -0,0 +1,47 @@
|
||||
package crazypants.enderio.machine.invpanel;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
public class PacketFetchItem implements IMessage, IMessageHandler<PacketFetchItem, IMessage> {
|
||||
|
||||
private int dbID;
|
||||
private int targetSlot;
|
||||
private int count;
|
||||
|
||||
public PacketFetchItem() {
|
||||
}
|
||||
|
||||
public PacketFetchItem(InventoryDatabaseClient.ItemEntry entry, int targetSlot, int count) {
|
||||
this.dbID = entry.dbID;
|
||||
this.targetSlot = targetSlot;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf bb) {
|
||||
dbID = bb.readInt();
|
||||
targetSlot = bb.readShort();
|
||||
count = bb.readShort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf bb) {
|
||||
bb.writeInt(dbID);
|
||||
bb.writeShort(targetSlot);
|
||||
bb.writeShort(count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketFetchItem message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
if(player.openContainer instanceof InventoryPanelContainer) {
|
||||
InventoryPanelContainer ipc = (InventoryPanelContainer) player.openContainer;
|
||||
ipc.executeFetchItems(player, message.dbID, message.targetSlot, message.count);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user