use of buildcraft.lib.gui.slot.SlotPhantom in project BuildCraft by BuildCraft.
the class ContainerBC_Neptune method readSingleSetPhantom.
private void readSingleSetPhantom(PacketBufferBC buffer, MessageContext ctx) throws IOException {
int idx = buffer.readVarInt();
ItemStack stack = buffer.readItemStack();
if (idx >= 0 && idx < inventorySlots.size()) {
Slot s = inventorySlots.get(idx);
if (s instanceof SlotPhantom) {
SlotPhantom ph = (SlotPhantom) s;
IItemHandlerAdv handler = ph.itemHandler;
if (handler instanceof IItemHandlerModifiable && handler.canSet(ph.handlerIndex, stack)) {
((IItemHandlerModifiable) handler).setStackInSlot(ph.handlerIndex, stack);
} else {
// log rather than throw an exception because of bugged/naughty clients
String s2 = "[lib.container] Received an illegal phantom slot setting request! ";
s2 += "[The item handler disallowed the replacement] (Client = ";
s2 += ctx.getServerHandler().player.getName() + ", slot_index = " + idx;
s2 += ", stack = " + stack + ")";
BCLog.logger.warn(s2);
}
return;
}
}
// log rather than throw an exception because of bugged/naughty clients
String s2 = "[lib.container] Received an illegal phantom slot setting request! ";
s2 += "[Didn't find a phantom slot for the given index] (Client = ";
s2 += ctx.getServerHandler().player.getName() + ", slot_index = " + idx;
s2 += ", stack = " + stack + ")";
BCLog.logger.warn(s2);
}
Aggregations