Search in sources :

Example 6 with ItemOxygenTank

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;
}
Also used : IItemOxygenSupply(micdoodle8.mods.galacticraft.api.item.IItemOxygenSupply) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack) ItemOxygenTank(micdoodle8.mods.galacticraft.core.items.ItemOxygenTank)

Example 7 with ItemOxygenTank

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;
}
Also used : Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack) ItemOxygenTank(micdoodle8.mods.galacticraft.core.items.ItemOxygenTank) ItemCanisterOxygenInfinite(micdoodle8.mods.galacticraft.core.items.ItemCanisterOxygenInfinite)

Example 8 with ItemOxygenTank

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;
}
Also used : Item(net.minecraft.item.Item) ItemStack(net.minecraft.item.ItemStack) ItemOxygenTank(micdoodle8.mods.galacticraft.core.items.ItemOxygenTank) ItemCanisterLiquidOxygen(micdoodle8.mods.galacticraft.planets.asteroids.items.ItemCanisterLiquidOxygen)

Example 9 with ItemOxygenTank

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;
}
Also used : Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack) ItemOxygenTank(micdoodle8.mods.galacticraft.core.items.ItemOxygenTank) ItemCanisterOxygenInfinite(micdoodle8.mods.galacticraft.core.items.ItemCanisterOxygenInfinite)

Aggregations

ItemStack (net.minecraft.item.ItemStack)9 ItemOxygenTank (micdoodle8.mods.galacticraft.core.items.ItemOxygenTank)7 ItemCanisterOxygenInfinite (micdoodle8.mods.galacticraft.core.items.ItemCanisterOxygenInfinite)3 Slot (net.minecraft.inventory.Slot)3 IItemOxygenSupply (micdoodle8.mods.galacticraft.api.item.IItemOxygenSupply)2 ItemCanisterLiquidOxygen (micdoodle8.mods.galacticraft.planets.asteroids.items.ItemCanisterLiquidOxygen)2 Item (net.minecraft.item.Item)2 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)1 AtmosphereInfo (micdoodle8.mods.galacticraft.api.world.AtmosphereInfo)1 ConnectionEvents (micdoodle8.mods.galacticraft.core.network.ConnectionEvents)1 SchematicAdd (micdoodle8.mods.galacticraft.core.schematic.SchematicAdd)1 SchematicMoonBuggy (micdoodle8.mods.galacticraft.core.schematic.SchematicMoonBuggy)1 SchematicRocketT1 (micdoodle8.mods.galacticraft.core.schematic.SchematicRocketT1)1 ChunkLoadingCallback (micdoodle8.mods.galacticraft.core.world.ChunkLoadingCallback)1 BiomeGenBaseMoon (micdoodle8.mods.galacticraft.core.world.gen.BiomeGenBaseMoon)1 OverworldGenerator (micdoodle8.mods.galacticraft.core.world.gen.OverworldGenerator)1 PartialCanister (micdoodle8.mods.galacticraft.core.wrappers.PartialCanister)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 WorldProvider (net.minecraft.world.WorldProvider)1 SpawnListEntry (net.minecraft.world.biome.BiomeGenBase.SpawnListEntry)1