use of logisticspipes.utils.item.ItemIdentifierInventory in project LogisticsPipes by RS485.
the class ItemModule method addInformation.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean flag) {
if (itemStack.hasTagCompound()) {
NBTTagCompound nbt = itemStack.getTagCompound();
if (nbt.hasKey("informationList")) {
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
NBTTagList nbttaglist = nbt.getTagList("informationList", 8);
for (int i = 0; i < nbttaglist.tagCount(); i++) {
Object nbttag = nbttaglist.tagList.get(i);
String data = ((NBTTagString) nbttag).func_150285_a_();
if (data.equals("<inventory>") && i + 1 < nbttaglist.tagCount()) {
nbttag = nbttaglist.tagList.get(i + 1);
data = ((NBTTagString) nbttag).func_150285_a_();
if (data.startsWith("<that>")) {
String prefix = data.substring(6);
NBTTagCompound module = nbt.getCompoundTag("moduleInformation");
int size = module.getTagList(prefix + "items", module.getId()).tagCount();
if (module.hasKey(prefix + "itemsCount")) {
size = module.getInteger(prefix + "itemsCount");
}
ItemIdentifierInventory inv = new ItemIdentifierInventory(size, "InformationTempInventory", Integer.MAX_VALUE);
inv.readFromNBT(module, prefix);
for (int pos = 0; pos < inv.getSizeInventory(); pos++) {
ItemIdentifierStack stack = inv.getIDStackInSlot(pos);
if (stack != null) {
if (stack.getStackSize() > 1) {
list.add(" " + stack.getStackSize() + "x " + stack.getFriendlyName());
} else {
list.add(" " + stack.getFriendlyName());
}
}
}
}
i++;
} else {
list.add(data);
}
}
} else {
list.add(StringUtils.translate(StringUtils.KEY_HOLDSHIFT));
}
} else {
StringUtils.addShiftAddition(itemStack, list);
}
} else {
StringUtils.addShiftAddition(itemStack, list);
}
}
use of logisticspipes.utils.item.ItemIdentifierInventory in project LogisticsPipes by RS485.
the class ThaumicAspectSinkModuleSlot method getContainer.
@Override
public DummyContainer getContainer(EntityPlayer player) {
ModuleThaumicAspectSink module = this.getLogisticsModule(player.getEntityWorld(), ModuleThaumicAspectSink.class);
if (module == null) {
return null;
}
DummyContainer dummy = new DummyContainer(player.inventory, new ItemIdentifierInventory(1, "TMP", 1));
dummy.addDummySlot(0, 0, 0);
dummy.addNormalSlotsForPlayerInventory(0, 0);
return dummy;
}
use of logisticspipes.utils.item.ItemIdentifierInventory in project LogisticsPipes by RS485.
the class OreDictItemSinkModuleSlot method getContainer.
@Override
public DummyContainer getContainer(EntityPlayer player) {
ModuleOreDictItemSink module = this.getLogisticsModule(player.getEntityWorld(), ModuleOreDictItemSink.class);
if (module == null) {
return null;
}
DummyContainer dummy = new DummyContainer(player.inventory, new ItemIdentifierInventory(1, "TMP", 1));
dummy.addDummySlot(0, 0, 0);
dummy.addNormalSlotsForPlayerInventory(0, 0);
return dummy;
}
use of logisticspipes.utils.item.ItemIdentifierInventory in project LogisticsPipes by RS485.
the class AssemblyTable method importRecipe.
@Override
public boolean importRecipe(TileEntity tile, ItemIdentifierInventory inventory) {
if (!(tile instanceof TileAssemblyTable)) {
return false;
}
TileAssemblyTable table = (TileAssemblyTable) tile;
//current pipe inputs/outputs
final ItemIdentifierInventory inputs = new ItemIdentifierInventory(inventory.getSizeInventory() - 2, "AssemblyTableDummyInv", 64, false);
for (int i = 0; i < inventory.getSizeInventory() - 2; i++) {
inputs.setInventorySlotContents(i, inventory.getIDStackInSlot(i));
}
ItemStack output = inventory.getStackInSlot(inventory.getSizeInventory() - 2);
//see if there's a recipe planned in the table that matches the current pipe settings, if yes take the next, otherwise take the first
FlexibleRecipe<ItemStack> firstRecipe = null;
FlexibleRecipe<ItemStack> nextRecipe = null;
boolean takeNext = false;
for (IFlexibleRecipe<ItemStack> r : AssemblyRecipeManager.INSTANCE.getRecipes()) {
if (!(r instanceof FlexibleRecipe)) {
continue;
}
if (!((FlexibleRecipe<ItemStack>) r).inputFluids.isEmpty()) {
continue;
}
if (table.isPlanned(r)) {
if (firstRecipe == null) {
firstRecipe = (FlexibleRecipe<ItemStack>) r;
}
if (takeNext) {
nextRecipe = (FlexibleRecipe<ItemStack>) r;
break;
}
if (output != null && ItemStack.areItemStacksEqual(output, ((FlexibleRecipe<ItemStack>) r).output)) {
if (((FlexibleRecipe<ItemStack>) r).canBeCrafted(new // Read Proxy to IInventory
IFlexibleCrafter() {
@Override
public int getCraftingItemStackSize() {
return inputs.getSizeInventory();
}
@Override
public ItemStack getCraftingItemStack(int paramInt) {
return inputs.getStackInSlot(paramInt);
}
@Override
public int getCraftingFluidStackSize() {
return 0;
}
@Override
public FluidStack getCraftingFluidStack(int paramInt) {
return null;
}
@Override
public ItemStack decrCraftingItemStack(int paramInt1, int paramInt2) {
return null;
}
@Override
public FluidStack decrCraftingFluidStack(int paramInt1, int paramInt2) {
return null;
}
})) {
takeNext = true;
}
}
}
}
if (nextRecipe == null) {
nextRecipe = firstRecipe;
}
if (nextRecipe == null) {
return false;
}
// Import
inventory.setInventorySlotContents(inventory.getSizeInventory() - 2, nextRecipe.output);
try {
for (int i = 0; i < inventory.getSizeInventory() - 2; i++) {
inventory.clearInventorySlotContents(i);
}
int i = 0;
for (Object input : nextRecipe.inputItems) {
ItemStack processed = null;
if (input instanceof String) {
List<ItemStack> ores = OreDictionary.getOres((String) input);
if (ores != null && ores.size() > 0) {
input = ores.get(0);
}
} else if (input instanceof ItemStack) {
processed = (ItemStack) input;
} else if (input instanceof Item) {
processed = new ItemStack((Item) input);
} else if (input instanceof Block) {
processed = new ItemStack((Block) input, 1, 0);
} else if (input instanceof Integer) {
processed = null;
} else {
throw new IllegalArgumentException("Unknown Object passed to recipe!");
}
if (processed != null) {
inventory.setInventorySlotContents(i, processed);
++i;
}
}
} catch (ClassCastException e) {
// TODO: make it show a nice error or
// remove this hack altogether.
}
// Compact
inventory.compact_first(9);
return true;
}
use of logisticspipes.utils.item.ItemIdentifierInventory in project LogisticsPipes by RS485.
the class OreDictItemSinkModuleInHand method getContainer.
@Override
public DummyContainer getContainer(EntityPlayer player) {
DummyModuleContainer dummy = new DummyModuleContainer(player, getInvSlot());
if (!(dummy.getModule() instanceof ModuleOreDictItemSink)) {
return null;
}
dummy.setInventory(new ItemIdentifierInventory(1, "TMP", 1));
dummy.addDummySlot(0, 0, 0);
dummy.addNormalSlotsForPlayerInventory(0, 0);
return dummy;
}
Aggregations