use of net.minecraft.inventory.IInventory in project LogisticsPipes by RS485.
the class PipeLogisticsChassi method getConnectedRawInventories.
@Override
protected List<IInventory> getConnectedRawInventories() {
if (_cachedAdjacentInventories != null) {
return _cachedAdjacentInventories;
}
List<IInventory> adjacent = new ArrayList<>(1);
IInventory adjinv = getRealInventory();
if (adjinv != null) {
adjacent.add(adjinv);
}
_cachedAdjacentInventories = adjacent;
return _cachedAdjacentInventories;
}
use of net.minecraft.inventory.IInventory in project LogisticsPipes by RS485.
the class PipeItemsSatelliteLogistics method updateInv.
private void updateInv(boolean force) {
itemList.clear();
for (ForgeDirection ori : ForgeDirection.VALID_DIRECTIONS) {
if (!this.container.isPipeConnected(ori))
continue;
IInventory inv = getInventory(ori);
if (inv != null) {
for (int i = 0; i < inv.getSizeInventory(); i++) {
if (inv.getStackInSlot(i) != null) {
addToList(ItemIdentifierStack.getFromStack(inv.getStackInSlot(i)));
}
}
}
}
if (!itemList.equals(oldList) || force) {
oldList.clear();
oldList.addAll(itemList);
MainProxy.sendToPlayerList(PacketHandler.getPacket(ChestContent.class).setIdentList(itemList).setPosX(getX()).setPosY(getY()).setPosZ(getZ()), localModeWatchers);
}
}
use of net.minecraft.inventory.IInventory in project LogisticsPipes by RS485.
the class PipeItemsInvSysConnector method inventoryConnected.
private boolean inventoryConnected() {
for (int i = 0; i < 6; i++) {
ForgeDirection dir = ForgeDirection.values()[i];
DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(this), dir);
TileEntity tile = p.getTileEntity(getWorld());
if (tile instanceof IInventory && this.container.canPipeConnect(tile, dir)) {
return true;
}
}
return false;
}
use of net.minecraft.inventory.IInventory in project LogisticsPipes by RS485.
the class ImmibisCraftingTableMk2 method importRecipe.
@Override
public boolean importRecipe(TileEntity tile, ItemIdentifierInventory inventory) {
try {
if (tileAutoCraftingMk2.isInstance(tile)) {
// Import recipeInputs
ItemStack[][] recipe = (ItemStack[][]) tileAutoCraftingMk2.getField("recipeInputs").get(tile);
// Not really a AutoCraftingInventory, but same content
InventoryCrafting tempCraftingInv = new InventoryCrafting(new Container() {
@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return false;
}
@Override
public void onCraftMatrixChanged(IInventory par1iInventory) {
}
}, 3, 3);
for (int i = 0; i < 9; i++) {
if (recipe[i].length > 0) {
tempCraftingInv.setInventorySlotContents(i, recipe[i][0]);
inventory.setInventorySlotContents(i, recipe[i][0]);
} else {
inventory.clearInventorySlotContents(i);
}
}
// Compact
int slotCount = 0;
for (int i = 0; i < 9; i++) {
ItemStack slotStack = inventory.getStackInSlot(i);
inventory.clearInventorySlotContents(i);
if (slotStack != null && slotStack.getItem() != null) {
int count = 1;
for (int j = i + 1; j < 9; j++) {
ItemStack tempStack = inventory.getStackInSlot(j);
if (tempStack != null && ItemIdentifier.get(slotStack).equals(ItemIdentifier.get(tempStack))) {
inventory.clearInventorySlotContents(j);
count++;
}
}
slotStack.stackSize = count;
inventory.setInventorySlotContents(slotCount, slotStack);
slotCount++;
}
}
ItemStack result = null;
for (IRecipe r : CraftingUtil.getRecipeList()) {
if (r.matches(tempCraftingInv, tile.getWorldObj())) {
result = r.getCraftingResult(tempCraftingInv);
break;
}
}
inventory.setInventorySlotContents(9, result);
return true;
}
} catch (IllegalArgumentException | NoSuchFieldException e) {
LogisticsPipes.log.fatal("Error while importing recipe from Tubestuff's AutoCraftingMk2");
e.printStackTrace();
} catch (Exception e) {
LogisticsPipes.log.error("Got a problem on ImmibisCraftingTableMk2 CraftingRecipeProvider:");
LogisticsPipes.log.error(e.getMessage());
}
return false;
}
use of net.minecraft.inventory.IInventory in project Witchworks by Um-Mitternacht.
the class ItemBauble method onItemRightClick.
@SuppressWarnings("deprecation")
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack toEquip = player.getHeldItem(hand).copy();
toEquip.setCount(1);
if (canEquip(toEquip, player)) {
IInventory baubles = BaublesApi.getBaubles(player);
for (int i = 0; i < baubles.getSizeInventory(); i++) {
if (baubles.isItemValidForSlot(i, toEquip)) {
ItemStack stackInSlot = baubles.getStackInSlot(i);
if (stackInSlot.isEmpty() || ((IBauble) stackInSlot.getItem()).canUnequip(stackInSlot, player)) {
if (!world.isRemote) {
baubles.setInventorySlotContents(i, toEquip);
stackInSlot.shrink(1);
}
if (!stackInSlot.isEmpty()) {
((IBauble) stackInSlot.getItem()).onUnequipped(stackInSlot, player);
return ActionResult.newResult(EnumActionResult.SUCCESS, stackInSlot.copy());
}
break;
}
}
}
}
return ActionResult.newResult(EnumActionResult.PASS, player.getHeldItem(hand));
}
Aggregations