Search in sources :

Example 1 with ItemAtmosphericValve

use of micdoodle8.mods.galacticraft.planets.asteroids.items.ItemAtmosphericValve in project Galacticraft by micdoodle8.

the class AsteroidsItems method initItems.

public static void initItems() {
    AsteroidsItems.grapple = new ItemGrappleHook("grapple");
    AsteroidsItems.tier3Rocket = new ItemTier3Rocket("rocket_t3");
    AsteroidsItems.astroMiner = new ItemAstroMiner("astro_miner");
    AsteroidsItems.thermalPadding = new ItemThermalPadding("thermal_padding");
    AsteroidsItems.basicItem = new ItemBasicAsteroids("item_basic_asteroids");
    AsteroidsItems.methaneCanister = new ItemCanisterMethane("methane_canister_partial");
    AsteroidsItems.canisterLOX = new ItemCanisterLiquidOxygen("canister_partial_lox");
    AsteroidsItems.canisterLN2 = new ItemCanisterLiquidNitrogen("canister_partial_ln2");
    // AsteroidsItems.canisterLAr = new ItemCanisterLiquidArgon("canisterPartialLAr");
    AsteroidsItems.atmosphericValve = new ItemAtmosphericValve("atmospheric_valve");
    AsteroidsItems.heavyNoseCone = new ItemHeavyNoseCone("heavy_nose_cone");
    AsteroidsItems.orionDrive = new ItemOrionDrive("orion_drive");
    AsteroidsItems.titaniumHelmet = new ItemArmorAsteroids(0, "helmet");
    AsteroidsItems.titaniumChestplate = new ItemArmorAsteroids(1, "chestplate");
    AsteroidsItems.titaniumLeggings = new ItemArmorAsteroids(2, "leggings");
    AsteroidsItems.titaniumBoots = new ItemArmorAsteroids(3, "boots");
    AsteroidsItems.titaniumAxe = new ItemAxeAsteroids("titanium_axe");
    AsteroidsItems.titaniumPickaxe = new ItemPickaxeAsteroids("titanium_pickaxe");
    AsteroidsItems.titaniumSpade = new ItemSpadeAsteroids("titanium_shovel");
    AsteroidsItems.titaniumHoe = new ItemHoeAsteroids("titanium_hoe");
    AsteroidsItems.titaniumSword = new ItemSwordAsteroids("titanium_sword");
    AsteroidsItems.strangeSeed = new ItemStrangeSeed("strange_seed");
    AsteroidsItems.registerItems();
    OreDictionary.registerOre("compressedTitanium", new ItemStack(AsteroidsItems.basicItem, 1, 6));
    OreDictionary.registerOre("ingotTitanium", new ItemStack(AsteroidsItems.basicItem, 1, 0));
    OreDictionary.registerOre("shardTitanium", new ItemStack(AsteroidsItems.basicItem, 1, 4));
    OreDictionary.registerOre("shardIron", new ItemStack(AsteroidsItems.basicItem, 1, 3));
    OreDictionary.registerOre("dustTitanium", new ItemStack(AsteroidsItems.basicItem, 1, 9));
    AsteroidsItems.registerHarvestLevels();
    GalacticraftCore.proxy.registerCanister(new PartialCanister(AsteroidsItems.methaneCanister, Constants.MOD_ID_PLANETS, "methane_canister_partial", 7));
    GalacticraftCore.proxy.registerCanister(new PartialCanister(AsteroidsItems.canisterLOX, Constants.MOD_ID_PLANETS, "canister_partial_lox", 7));
    GalacticraftCore.proxy.registerCanister(new PartialCanister(AsteroidsItems.canisterLN2, Constants.MOD_ID_PLANETS, "canister_partial_ln2", 7));
}
Also used : PartialCanister(micdoodle8.mods.galacticraft.core.wrappers.PartialCanister) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ItemAtmosphericValve

use of micdoodle8.mods.galacticraft.planets.asteroids.items.ItemAtmosphericValve in project Galacticraft by micdoodle8.

the class ContainerGasLiquefier method transferStackInSlot.

/**
 * Called to transfer a stack from one inventory to the other eg. when shift
 * clicking.
 */
@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 var4 = slot.getStack();
        var2 = var4.copy();
        if (par1 < 4) {
            if (!this.mergeItemStack(var4, 4, 40, true)) {
                return null;
            }
            if (par1 == 2) {
                slot.onSlotChange(var4, var2);
            }
        } else {
            if (EnergyUtil.isElectricItem(var4.getItem())) {
                if (!this.mergeItemStack(var4, 0, 1, false)) {
                    return null;
                }
            } else {
                boolean outputTankSlotsSuccess = false;
                if (FluidUtil.isEmptyContainerFor(var4, this.tileEntity.liquidTank2.getFluid())) {
                    if (this.mergeItemStack(var4, 3, 4, false)) {
                        outputTankSlotsSuccess = true;
                    }
                }
                if (!outputTankSlotsSuccess && FluidUtil.isEmptyContainerFor(var4, this.tileEntity.liquidTank.getFluid())) {
                    if (this.mergeItemStack(var4, 2, 3, false)) {
                        outputTankSlotsSuccess = true;
                    }
                }
                if (!outputTankSlotsSuccess) {
                    if (FluidUtil.isFilledContainer(var4) || var4.getItem() instanceof ItemAtmosphericValve) {
                        if (!this.mergeItemStack(var4, 1, 2, false)) {
                            return null;
                        }
                    } else if (par1 < 31) {
                        if (!this.mergeItemStack(var4, 31, 40, false)) {
                            return null;
                        }
                    } else if (!this.mergeItemStack(var4, 4, 31, false)) {
                        return null;
                    }
                }
            }
        }
        if (var4.stackSize == 0) {
            slot.putStack((ItemStack) null);
        } else {
            slot.onSlotChanged();
        }
        if (var4.stackSize == var2.stackSize) {
            return null;
        }
        slot.onPickupFromSlot(par1EntityPlayer, var4);
    }
    return var2;
}
Also used : Slot(net.minecraft.inventory.Slot) ItemAtmosphericValve(micdoodle8.mods.galacticraft.planets.asteroids.items.ItemAtmosphericValve) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ItemAtmosphericValve

use of micdoodle8.mods.galacticraft.planets.asteroids.items.ItemAtmosphericValve in project Galacticraft by micdoodle8.

the class TileEntityGasLiquefier method update.

@Override
public void update() {
    super.update();
    if (this.airProducts == -1) {
        this.airProducts = this.getAirProducts();
    }
    if (!this.worldObj.isRemote) {
        FluidStack currentgas = this.gasTank.getFluid();
        if (currentgas == null || currentgas.amount <= 0) {
            this.gasTankType = -1;
        } else {
            this.gasTankType = this.getIdFromName(currentgas.getFluid().getName());
        }
        // If somehow it has air in an airless dimension, flush it out
        if (this.airProducts == 0 && this.gasTankType == TankGases.AIR.index) {
            this.gasTank.drain(this.gasTank.getFluidAmount(), true);
        }
        FluidStack currentLiquid = this.liquidTank.getFluid();
        if (currentLiquid == null || currentLiquid.amount == 0) {
            this.fluidTankType = -1;
        } else {
            this.fluidTankType = this.getProductIdFromName(currentLiquid.getFluid().getName());
        }
        currentLiquid = this.liquidTank2.getFluid();
        if (currentLiquid == null || currentLiquid.amount == 0) {
            this.fluidTank2Type = -1;
        } else {
            this.fluidTank2Type = this.getProductIdFromName(currentLiquid.getFluid().getName());
        }
        // First, see if any gas needs to be put into the gas storage
        ItemStack inputCanister = this.containingItems[1];
        if (inputCanister != null) {
            if (inputCanister.getItem() instanceof ItemAtmosphericValve && this.airProducts > 0) {
                // Air -> Air tank
                if (this.gasTankType == -1 || (this.gasTankType == TankGases.AIR.index && this.gasTank.getFluid().amount < this.gasTank.getCapacity())) {
                    Block blockAbove = this.worldObj.getBlockState(getPos().up()).getBlock();
                    if (blockAbove != null && blockAbove.getMaterial() == Material.air && blockAbove != GCBlocks.breatheableAir && blockAbove != GCBlocks.brightBreatheableAir) {
                        FluidStack gcAtmosphere = FluidRegistry.getFluidStack(TankGases.AIR.gas, 4);
                        this.gasTank.fill(gcAtmosphere, true);
                        this.gasTankType = TankGases.AIR.index;
                    }
                }
            } else if (inputCanister.getItem() instanceof ItemCanisterGeneric) {
                int amount = ItemCanisterGeneric.EMPTY - inputCanister.getItemDamage();
                if (amount > 0) {
                    Item canisterType = inputCanister.getItem();
                    FluidStack canisterGas = null;
                    int factor = 1;
                    if (this.gasTankType <= 0 && canisterType == AsteroidsItems.methaneCanister) {
                        this.gasTankType = TankGases.METHANE.index;
                        canisterGas = FluidRegistry.getFluidStack(TankGases.METHANE.gas, amount);
                    }
                    if ((this.gasTankType == TankGases.OXYGEN.index || this.gasTankType == -1) && canisterType == AsteroidsItems.canisterLOX) {
                        this.gasTankType = TankGases.OXYGEN.index;
                        canisterGas = FluidRegistry.getFluidStack(TankGases.OXYGEN.gas, amount * 2);
                        factor = 2;
                    }
                    if ((this.gasTankType == TankGases.NITROGEN.index || this.gasTankType == -1) && canisterType == AsteroidsItems.canisterLN2) {
                        this.gasTankType = TankGases.NITROGEN.index;
                        canisterGas = FluidRegistry.getFluidStack(TankGases.NITROGEN.gas, amount * 2);
                        factor = 2;
                    }
                    if (canisterGas != null) {
                        int used = this.gasTank.fill(canisterGas, true) / factor;
                        if (used == amount) {
                            this.containingItems[1] = new ItemStack(GCItems.oilCanister, 1, ItemCanisterGeneric.EMPTY);
                        } else {
                            this.containingItems[1] = new ItemStack(canisterType, 1, ItemCanisterGeneric.EMPTY - amount + used);
                        }
                    }
                }
            } else {
                FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(inputCanister);
                if (liquid != null && liquid.amount > 0) {
                    String inputName = FluidRegistry.getFluidName(liquid);
                    // Methane -> Methane tank
                    if (this.gasTankType <= 0 && inputName.contains("methane")) {
                        if (currentgas == null || currentgas.amount + liquid.amount <= this.gasTank.getCapacity()) {
                            FluidStack gcMethane = FluidRegistry.getFluidStack(TankGases.METHANE.gas, liquid.amount);
                            this.gasTank.fill(gcMethane, true);
                            this.gasTankType = 0;
                            this.containingItems[1] = FluidUtil.getUsedContainer(inputCanister);
                        }
                    } else // Oxygen -> Oxygen tank
                    if ((this.gasTankType == TankGases.OXYGEN.index || this.gasTankType == -1) && inputName.contains("oxygen")) {
                        int tankedAmount = liquid.amount * (inputName.contains("liquid") ? 2 : 1);
                        if (currentgas == null || currentgas.amount + tankedAmount <= this.gasTank.getCapacity()) {
                            FluidStack gcgas = FluidRegistry.getFluidStack(TankGases.OXYGEN.gas, tankedAmount);
                            this.gasTank.fill(gcgas, true);
                            this.gasTankType = TankGases.OXYGEN.index;
                            this.containingItems[1] = FluidUtil.getUsedContainer(inputCanister);
                        }
                    } else // Nitrogen -> Nitrogen tank
                    if ((this.gasTankType == TankGases.NITROGEN.index || this.gasTankType == -1) && inputName.contains("nitrogen")) {
                        int tankedAmount = liquid.amount * (inputName.contains("liquid") ? 2 : 1);
                        if (currentgas == null || currentgas.amount + tankedAmount <= this.gasTank.getCapacity()) {
                            FluidStack gcgas = FluidRegistry.getFluidStack(TankGases.NITROGEN.gas, tankedAmount);
                            this.gasTank.fill(gcgas, true);
                            this.gasTankType = TankGases.NITROGEN.index;
                            this.containingItems[1] = FluidUtil.getUsedContainer(inputCanister);
                        }
                    }
                }
            }
        }
        // Now see if any liquids from the output tanks need to be put into the output slot
        checkFluidTankTransfer(2, this.liquidTank);
        checkFluidTankTransfer(3, this.liquidTank2);
        if (this.hasEnoughEnergyToRun && this.canProcess()) {
            // 50% extra speed boost for Tier 2 machine if powered by Tier 2 power
            if (this.tierGC == 2) {
                this.processTimeRequired = Math.max(1, 4 - this.poweredByTierGC);
            }
            if (this.processTicks <= 0) {
                this.processTicks = this.processTimeRequired;
            } else {
                if (--this.processTicks <= 0) {
                    this.doLiquefaction();
                    this.processTicks = this.canProcess() ? this.processTimeRequired : 0;
                }
            }
        } else {
            if (this.processTicks > 0) {
                this.processTicks = 0;
            } else if (--this.processTicks <= -10) {
                this.processTicks = -10;
            }
        }
    }
}
Also used : Item(net.minecraft.item.Item) ItemCanisterGeneric(micdoodle8.mods.galacticraft.core.items.ItemCanisterGeneric) ItemAtmosphericValve(micdoodle8.mods.galacticraft.planets.asteroids.items.ItemAtmosphericValve) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ItemAtmosphericValve

use of micdoodle8.mods.galacticraft.planets.asteroids.items.ItemAtmosphericValve in project Galacticraft by micdoodle8.

the class TileEntityMethaneSynthesizer method update.

@Override
public void update() {
    super.update();
    if (this.hasCO2 == -1) {
        this.hasCO2 = this.getAirProducts();
    }
    if (!this.worldObj.isRemote) {
        // If somehow it has CO2 in a CO2-free dimension, flush it out
        if (this.hasCO2 == 0 && this.gasTank2.getFluidAmount() > 0) {
            this.gasTank2.drain(this.gasTank2.getFluidAmount(), true);
        }
        // First, see if any gas needs to be put into the hydogen storage
        // TODO - in 1.7.10 implement support for Mekanism internal hydrogen tanks
        // TODO add support for hydrogen atmospheres
        // Now check the CO2 storage
        ItemStack inputCanister = this.containingItems[2];
        if (inputCanister != null) {
            if (inputCanister.getItem() instanceof ItemAtmosphericValve && this.hasCO2 > 0) {
                // CO2 -> CO2 tank
                if (this.gasTank2.getFluidAmount() < this.gasTank2.getCapacity()) {
                    Block blockAbove = this.worldObj.getBlockState(this.getPos().up()).getBlock();
                    if (blockAbove != null && blockAbove.getMaterial() == Material.air && blockAbove != GCBlocks.breatheableAir && blockAbove != GCBlocks.brightBreatheableAir) {
                        if (!OxygenUtil.inOxygenBubble(this.worldObj, this.getPos().getX() + 0.5D, this.getPos().getY() + 1D, this.getPos().getZ() + 0.5D)) {
                            FluidStack gcAtmosphere = FluidRegistry.getFluidStack("carbondioxide", 4);
                            this.gasTank2.fill(gcAtmosphere, true);
                        }
                    }
                }
            }
        }
        // Now see if any methane from the methane tank needs to be put into the output slot
        checkFluidTankTransfer(4, this.liquidTank);
        if (this.hasEnoughEnergyToRun && this.canProcess()) {
            // 50% extra speed boost for Tier 2 machine if powered by Tier 2 power
            if (this.tierGC == 2) {
                this.processTimeRequired = Math.max(1, 4 - this.poweredByTierGC);
            }
            if (this.processTicks <= 0) {
                this.processTicks = this.processTimeRequired;
            } else {
                if (--this.processTicks <= 0) {
                    this.doLiquefaction();
                    this.processTicks = this.canProcess() ? this.processTimeRequired : 0;
                }
            }
        } else {
            if (this.processTicks > 0) {
                this.processTicks = 0;
            } else if (--this.processTicks <= -8) {
                this.processTicks = -8;
            }
        }
        this.produceOutput(this.getHydrogenInputDirection().getOpposite());
    }
}
Also used : ItemAtmosphericValve(micdoodle8.mods.galacticraft.planets.asteroids.items.ItemAtmosphericValve) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack)

Example 5 with ItemAtmosphericValve

use of micdoodle8.mods.galacticraft.planets.asteroids.items.ItemAtmosphericValve in project Galacticraft by micdoodle8.

the class ContainerMethaneSynthesizer method transferStackInSlot.

/**
 * Called to transfer a stack from one inventory to the other eg. when shift
 * clicking.
 */
@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 var4 = slot.getStack();
        var2 = var4.copy();
        if (par1 < 5) {
            if (!this.mergeItemStack(var4, 5, 41, true)) {
                return null;
            }
            if (par1 == 2) {
                slot.onSlotChange(var4, var2);
            }
        } else {
            if (EnergyUtil.isElectricItem(var4.getItem())) {
                if (!this.mergeItemStack(var4, 0, 1, false)) {
                    return null;
                }
            } else {
                if (var4.getItem() instanceof ItemAtmosphericValve) {
                    if (!this.mergeItemStack(var4, 2, 3, false)) {
                        return null;
                    }
                } else if (var4.getItem() == MarsItems.carbonFragments) {
                    if (!this.mergeItemStack(var4, 3, 4, false)) {
                        return null;
                    }
                } else if (FluidUtil.isEmptyContainer(var4, AsteroidsItems.methaneCanister)) {
                    if (!this.mergeItemStack(var4, 4, 5, false)) {
                        return null;
                    }
                } else if (par1 < 32) {
                    if (!this.mergeItemStack(var4, 32, 41, false)) {
                        return null;
                    }
                } else if (!this.mergeItemStack(var4, 5, 32, false)) {
                    return null;
                }
            }
        }
        if (var4.stackSize == 0) {
            slot.putStack((ItemStack) null);
        } else {
            slot.onSlotChanged();
        }
        if (var4.stackSize == var2.stackSize) {
            return null;
        }
        slot.onPickupFromSlot(par1EntityPlayer, var4);
    }
    return var2;
}
Also used : Slot(net.minecraft.inventory.Slot) ItemAtmosphericValve(micdoodle8.mods.galacticraft.planets.asteroids.items.ItemAtmosphericValve) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStack (net.minecraft.item.ItemStack)5 ItemAtmosphericValve (micdoodle8.mods.galacticraft.planets.asteroids.items.ItemAtmosphericValve)4 Block (net.minecraft.block.Block)2 Slot (net.minecraft.inventory.Slot)2 ItemCanisterGeneric (micdoodle8.mods.galacticraft.core.items.ItemCanisterGeneric)1 PartialCanister (micdoodle8.mods.galacticraft.core.wrappers.PartialCanister)1 Item (net.minecraft.item.Item)1