use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.
the class FuzzyInventoryUtil method getItems.
@Override
public Set<ItemIdentifier> getItems() {
Set<ItemIdentifier> items = new TreeSet<>();
for (int i = 0; i < _inventory.getSizeInventory(); i++) {
ItemStack stack = _inventory.getStackInSlot(i);
if (stack == null) {
continue;
}
items.add(ItemIdentifier.get(stack).getIgnoringNBT());
}
return items;
}
use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.
the class InventoryUtil method getItems.
@Override
public Set<ItemIdentifier> getItems() {
Set<ItemIdentifier> items = new TreeSet<>();
for (int i = _cropStart; i < _inventory.getSizeInventory() - _cropEnd; i++) {
ItemStack stack = _inventory.getStackInSlot(i);
if (stack == null) {
continue;
}
items.add(ItemIdentifier.get(stack));
}
return items;
}
use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.
the class DummyContainer method handleDummyClick.
public void handleDummyClick(Slot slot, int slotId, ItemStack currentlyEquippedStack, int mouseButton, int isShift, EntityPlayer entityplayer) {
if (slot instanceof FluidSlot) {
if (currentlyEquippedStack != null) {
FluidStack liquidId = FluidContainerRegistry.getFluidForFilledItem(currentlyEquippedStack);
if (liquidId != null) {
FluidIdentifier ident = FluidIdentifier.get(liquidId);
if (mouseButton == 0) {
if (ident == null) {
slot.putStack(null);
} else {
slot.putStack(ident.getItemIdentifier().unsafeMakeNormalStack(1));
}
} else {
slot.putStack(null);
}
return;
}
FluidIdentifier ident = FluidIdentifier.get(currentlyEquippedStack);
if (ident != null) {
if (mouseButton == 0) {
slot.putStack(ident.getItemIdentifier().unsafeMakeNormalStack(1));
} else {
slot.putStack(null);
}
return;
}
}
FluidIdentifier ident = null;
if (slot.getStack() != null) {
ident = FluidIdentifier.get(ItemIdentifier.get(slot.getStack()));
}
if (ident == null) {
if (MainProxy.isClient(entityplayer.getEntityWorld())) {
MainProxy.proxy.openFluidSelectGui(slotId);
}
}
slot.putStack(null);
return;
}
if (slot instanceof ColorSlot) {
MinecraftColor equipped = MinecraftColor.getColor(currentlyEquippedStack);
MinecraftColor color = MinecraftColor.getColor(slot.getStack());
if (MinecraftColor.BLANK.equals(equipped)) {
if (mouseButton == 0) {
color = color.getNext();
} else if (mouseButton == 1) {
color = color.getPrev();
} else {
color = MinecraftColor.BLANK;
}
slot.putStack(color.getItemStack());
} else {
if (mouseButton == 1) {
slot.putStack(MinecraftColor.BLANK.getItemStack());
} else {
slot.putStack(equipped.getItemStack());
}
}
if (entityplayer instanceof EntityPlayerMP && MainProxy.isServer(entityplayer.worldObj)) {
((EntityPlayerMP) entityplayer).sendSlotContents(this, slotId, slot.getStack());
}
return;
}
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(true);
}
if (currentlyEquippedStack == null) {
if (slot.getStack() != null && mouseButton == 1) {
ItemStack tstack = slot.getStack();
if (isShift == 1) {
tstack.stackSize = Math.min(slot.getSlotStackLimit(), tstack.stackSize * 2);
} else {
tstack.stackSize /= 2;
if (tstack.stackSize <= 0) {
tstack = null;
}
}
slot.putStack(tstack);
} else {
slot.putStack(null);
}
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(false);
}
return;
}
if (!slot.getHasStack()) {
ItemStack tstack = currentlyEquippedStack.copy();
if (mouseButton == 1) {
tstack.stackSize = 1;
}
if (tstack.stackSize > slot.getSlotStackLimit()) {
tstack.stackSize = slot.getSlotStackLimit();
}
slot.putStack(tstack);
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(false);
}
return;
}
ItemIdentifier currentItem = ItemIdentifier.get(currentlyEquippedStack);
ItemIdentifier slotItem = ItemIdentifier.get(slot.getStack());
if (currentItem.equals(slotItem)) {
ItemStack tstack = slot.getStack();
// Do manual shift-checking to play nice with NEI
int counter = isShift == 1 ? 10 : 1;
if (mouseButton == 1) {
if (tstack.stackSize + counter <= slot.getSlotStackLimit()) {
tstack.stackSize += counter;
} else {
tstack.stackSize = slot.getSlotStackLimit();
}
slot.putStack(tstack);
} else if (mouseButton == 0) {
tstack.stackSize -= counter;
if (tstack.stackSize <= 0) {
tstack = null;
}
slot.putStack(tstack);
}
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(false);
}
return;
}
ItemStack tstack = currentlyEquippedStack.copy();
if (tstack.stackSize > slot.getSlotStackLimit()) {
tstack.stackSize = slot.getSlotStackLimit();
}
slot.putStack(tstack);
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(false);
}
return;
}
use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.
the class LPDataIOWrapper method readItemIdentifierStack.
@Override
public ItemIdentifierStack readItemIdentifierStack() {
int stacksize = readInt();
if (stacksize == -1) {
return null;
}
ItemIdentifier item = readItemIdentifier();
return new ItemIdentifierStack(item, stacksize);
}
Aggregations