use of micdoodle8.mods.galacticraft.core.items.ItemOxygenTank in project Galacticraft by micdoodle8.
the class ContainerOxygenCompressor method transferStackInSlot.
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1) {
ItemStack var2 = null;
final Slot slot = (Slot) this.inventorySlots.get(par1);
final int b = this.inventorySlots.size();
if (slot != null && slot.getHasStack()) {
final ItemStack stack = slot.getStack();
var2 = stack.copy();
boolean movedToMachineSlot = false;
if (par1 < 3) {
if (!this.mergeItemStack(stack, b - 36, b, true)) {
return null;
}
} else {
if (EnergyUtil.isElectricItem(stack.getItem())) {
if (!this.mergeItemStack(stack, 1, 2, false)) {
return null;
}
movedToMachineSlot = true;
} else if (stack.getItem() instanceof IItemOxygenSupply) {
if (!this.mergeItemStack(stack, 2, 3, false)) {
return null;
}
movedToMachineSlot = true;
} else if (stack.getItem() instanceof ItemOxygenTank && stack.getItemDamage() > 0) {
if (!this.mergeItemStack(stack, 0, 1, false)) {
return null;
}
movedToMachineSlot = true;
} else {
if (par1 < b - 9) {
if (!this.mergeItemStack(stack, b - 9, b, false)) {
return null;
}
} else if (!this.mergeItemStack(stack, b - 36, b - 9, false)) {
return null;
}
}
}
if (stack.stackSize == 0) {
// Needed where tile has inventoryStackLimit of 1
if (movedToMachineSlot && var2.stackSize > 1) {
ItemStack remainder = var2.copy();
--remainder.stackSize;
slot.putStack(remainder);
} else {
slot.putStack((ItemStack) null);
}
} else {
slot.onSlotChanged();
}
if (stack.stackSize == var2.stackSize) {
return null;
}
slot.onPickupFromSlot(par1EntityPlayer, stack);
}
return var2;
}
use of micdoodle8.mods.galacticraft.core.items.ItemOxygenTank in project Galacticraft by micdoodle8.
the class ContainerOxygenDecompressor method transferStackInSlot.
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1) {
ItemStack var2 = null;
final Slot slot = (Slot) this.inventorySlots.get(par1);
final int b = this.inventorySlots.size();
if (slot != null && slot.getHasStack()) {
final ItemStack stack = slot.getStack();
var2 = stack.copy();
boolean movedToMachineSlot = false;
if (par1 < 2) {
if (!this.mergeItemStack(stack, b - 36, b, true)) {
return null;
}
} else {
if (EnergyUtil.isElectricItem(stack.getItem())) {
if (!this.mergeItemStack(stack, 1, 2, false)) {
return null;
}
movedToMachineSlot = true;
} else if (stack.getItem() instanceof ItemCanisterOxygenInfinite || (stack.getItem() instanceof ItemOxygenTank && stack.getItemDamage() < stack.getMaxDamage())) {
if (!this.mergeItemStack(stack, 0, 1, false)) {
return null;
}
movedToMachineSlot = true;
} else {
if (par1 < b - 9) {
if (!this.mergeItemStack(stack, b - 9, b, false)) {
return null;
}
} else if (!this.mergeItemStack(stack, b - 36, b - 9, false)) {
return null;
}
}
}
if (stack.stackSize == 0) {
// Needed where tile has inventoryStackLimit of 1
if (movedToMachineSlot && var2.stackSize > 1) {
ItemStack remainder = var2.copy();
--remainder.stackSize;
slot.putStack(remainder);
} else {
slot.putStack((ItemStack) null);
}
} else {
slot.onSlotChanged();
}
if (stack.stackSize == var2.stackSize) {
return null;
}
slot.onPickupFromSlot(par1EntityPlayer, stack);
}
return var2;
}
use of micdoodle8.mods.galacticraft.core.items.ItemOxygenTank in project Galacticraft by micdoodle8.
the class CanisterRecipes method matches.
/**
* Used to check if a recipe matches current crafting inventory
*/
@Override
public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_) {
ItemStack itemCanister = null;
ItemStack itemTank = null;
for (int i = 0; i < p_77569_1_.getSizeInventory(); ++i) {
ItemStack itemstack1 = p_77569_1_.getStackInSlot(i);
if (itemstack1 != null) {
Item testItem = itemstack1.getItem();
if (testItem instanceof ItemCanisterLiquidOxygen || testItem == GCItems.oxygenCanisterInfinite) {
if (itemCanister != null) {
// Two canisters
return false;
}
itemCanister = itemstack1;
} else {
if (!(testItem instanceof ItemOxygenTank) || itemTank != null) {
// Something other than an oxygen tank
return false;
}
itemTank = itemstack1;
}
}
}
// Need one canister + one tank
if (itemCanister == null || itemTank == null) {
return false;
}
// Empty canister
if (itemCanister.getItemDamage() >= itemCanister.getMaxDamage()) {
return false;
}
// Full tank
if (itemTank.getItemDamage() <= 0) {
return false;
}
return true;
}
use of micdoodle8.mods.galacticraft.core.items.ItemOxygenTank in project Galacticraft by micdoodle8.
the class ContainerExtendedInventory method transferStackInSlot.
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1) {
ItemStack var2 = null;
final Slot slot = (Slot) this.inventorySlots.get(par1);
if (slot != null && slot.getHasStack()) {
final ItemStack stack = slot.getStack();
var2 = stack.copy();
if (par1 >= 36) {
if (!this.mergeItemStack(stack, 0, 36, true)) {
return null;
}
} else {
boolean flag = false;
for (int j = 36; j < 40; j++) {
if (((SlotArmorGC) this.inventorySlots.get(j)).isItemValid(stack)) {
if (!this.mergeOneItem(stack, j, j + 1, false)) {
return null;
}
flag = true;
break;
}
}
if (!flag) {
if (stack.getItem() instanceof ItemOxygenTank || stack.getItem() instanceof ItemCanisterOxygenInfinite) {
if (!this.mergeOneItem(stack, 42, 44, false)) {
return null;
}
flag = true;
} else {
for (int j = 40; j < 51; j++) {
if (((SlotExtendedInventory) this.inventorySlots.get(j)).isItemValid(stack)) {
if (!this.mergeOneItem(stack, j, j + 1, false)) {
return null;
}
flag = true;
break;
}
}
}
}
if (!flag) {
if (par1 < 27) {
if (!this.mergeItemStack(stack, 27, 36, false)) {
return null;
}
} else if (!this.mergeItemStack(stack, 0, 27, false)) {
return null;
}
}
}
if (stack.stackSize == 0) {
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
if (stack.stackSize == var2.stackSize) {
return null;
}
slot.onPickupFromSlot(par1EntityPlayer, stack);
}
return var2;
}
Aggregations