use of logisticspipes.utils.item.ItemIdentifierStack in project LogisticsPipes by RS485.
the class ClientProxy method openFluidSelectGui.
@Override
public void openFluidSelectGui(final int slotId) {
if (Minecraft.getMinecraft().currentScreen instanceof LogisticsBaseGuiScreen) {
final List<ItemIdentifierStack> list = new ArrayList<>();
for (FluidIdentifier fluid : FluidIdentifier.all()) {
if (fluid == null) {
continue;
}
list.add(fluid.getItemIdentifier().makeStack(1));
}
SelectItemOutOfList subGui = new SelectItemOutOfList(list, slot -> MainProxy.sendPacketToServer(PacketHandler.getPacket(DummyContainerSlotClick.class).setSlotId(slotId).setStack(list.get(slot).makeNormalStack()).setButton(0)));
LogisticsBaseGuiScreen gui = (LogisticsBaseGuiScreen) Minecraft.getMinecraft().currentScreen;
if (!gui.hasSubGui()) {
gui.setSubGui(subGui);
} else {
SubGuiScreen nextGui = gui.getSubGui();
while (nextGui.hasSubGui()) {
nextGui = nextGui.getSubGui();
}
nextGui.setSubGui(subGui);
}
} else {
throw new UnsupportedOperationException(String.valueOf(Minecraft.getMinecraft().currentScreen));
}
}
use of logisticspipes.utils.item.ItemIdentifierStack in project LogisticsPipes by RS485.
the class DictResource method clone.
@Override
public IResource clone(int multiplier) {
ItemIdentifierStack stack = this.stack.clone();
stack.setStackSize(stack.getStackSize() * multiplier);
DictResource clone = new DictResource(stack, requester);
clone.use_od = use_od;
clone.ignore_dmg = ignore_dmg;
clone.ignore_nbt = ignore_nbt;
clone.use_category = use_category;
return clone;
}
use of logisticspipes.utils.item.ItemIdentifierStack in project LogisticsPipes by RS485.
the class DictResource method copyForDisplayWith.
@Override
public IResource copyForDisplayWith(int amount) {
ItemIdentifierStack stack = this.stack.clone();
stack.setStackSize(amount);
DictResource clone = new DictResource(stack, null);
clone.use_od = use_od;
clone.ignore_dmg = ignore_dmg;
clone.ignore_nbt = ignore_nbt;
clone.use_category = use_category;
return clone;
}
use of logisticspipes.utils.item.ItemIdentifierStack in project LogisticsPipes by RS485.
the class RequestHandler method refresh.
public static void refresh(EntityPlayer player, CoreRoutedPipe pipe, DisplayOptions option) {
Map<ItemIdentifier, Integer> _availableItems;
LinkedList<ItemIdentifier> _craftableItems;
if (option == DisplayOptions.SupplyOnly || option == DisplayOptions.Both) {
_availableItems = SimpleServiceLocator.logisticsManager.getAvailableItems(pipe.getRouter().getIRoutersByCost());
} else {
_availableItems = new HashMap<>();
}
if (option == DisplayOptions.CraftOnly || option == DisplayOptions.Both) {
_craftableItems = SimpleServiceLocator.logisticsManager.getCraftableItems(pipe.getRouter().getIRoutersByCost());
} else {
_craftableItems = new LinkedList<>();
}
TreeSet<ItemIdentifierStack> _allItems = new TreeSet<>();
for (Entry<ItemIdentifier, Integer> item : _availableItems.entrySet()) {
ItemIdentifierStack newStack = item.getKey().makeStack(item.getValue());
_allItems.add(newStack);
}
for (ItemIdentifier item : _craftableItems) {
if (_availableItems.containsKey(item)) {
continue;
}
_allItems.add(item.makeStack(0));
}
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(OrdererContent.class).setIdentSet(_allItems), player);
}
use of logisticspipes.utils.item.ItemIdentifierStack in project LogisticsPipes by RS485.
the class RequestHandler method requestMacrolist.
public static void requestMacrolist(NBTTagCompound itemlist, final CoreRoutedPipe requester, final EntityPlayer player) {
if (!requester.useEnergy(5)) {
player.addChatMessage(new ChatComponentTranslation("lp.misc.noenergy"));
return;
}
NBTTagList list = itemlist.getTagList("inventar", 10);
final List<ItemIdentifierStack> transaction = new ArrayList<>(list.tagCount());
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound itemnbt = list.getCompoundTagAt(i);
NBTTagCompound itemNBTContent = itemnbt.getCompoundTag("nbt");
if (!itemnbt.hasKey("nbt")) {
itemNBTContent = null;
}
ItemIdentifierStack stack = ItemIdentifier.get(Item.getItemById(itemnbt.getInteger("id")), itemnbt.getInteger("data"), itemNBTContent).makeStack(itemnbt.getInteger("amount"));
transaction.add(stack);
}
RequestTree.request(transaction, requester, new RequestLog() {
@Override
public void handleMissingItems(List<IResource> resources) {
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(MissingItems.class).setItems(resources).setFlag(true), player);
}
@Override
public void handleSucessfullRequestOf(IResource item, LinkedLogisticsOrderList parts) {
}
@Override
public void handleSucessfullRequestOfList(List<IResource> resources, LinkedLogisticsOrderList parts) {
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(MissingItems.class).setItems(resources).setFlag(false), player);
if (requester instanceof IRequestWatcher) {
((IRequestWatcher) requester).handleOrderList(null, parts);
}
}
}, RequestTree.defaultRequestFlags, null);
}
Aggregations