Search in sources :

Example 1 with ItemJetpack

use of tonius.simplyjetpacks.item.ItemPack.ItemJetpack in project SimplyJetpacks by Tonius.

the class UpgradingRecipe method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) {
    int addedEnergy = 0;
    ParticleType particleType = null;
    NBTTagCompound tags = null;
    boolean enderiumUpgrade = false;
    ItemStack slotStack;
    for (int i = 0; i < inventoryCrafting.getSizeInventory(); i++) {
        slotStack = inventoryCrafting.getStackInSlot(i);
        if (slotStack != null && slotStack.getItem() != null) {
            if (slotStack.getItem() instanceof ItemPack) {
                tags = (NBTTagCompound) NBTHelper.getNBT(slotStack).copy();
            }
            if (slotStack.getItem() instanceof IEnergyContainerItem) {
                addedEnergy += ((IEnergyContainerItem) slotStack.getItem()).getEnergyStored(slotStack);
            } else if (slotStack.getItem() == ModItems.particleCustomizers) {
                particleType = ParticleType.values()[slotStack.getItemDamage()];
            } else if (ModItems.enderiumUpgrade != null && slotStack.getItem() == ModItems.enderiumUpgrade.getItem() && slotStack.getItemDamage() == ModItems.enderiumUpgrade.getItemDamage()) {
                enderiumUpgrade = true;
            }
        }
    }
    ItemStack result = new ItemStack((Item) this.resultItem, 1, this.resultMeta);
    if (tags != null) {
        result.setTagCompound(tags);
    }
    NBTHelper.getNBT(result).setInteger("Energy", Math.min(addedEnergy, this.resultItem.getMaxEnergyStored(result)));
    if (this.resultItem instanceof ItemJetpack && particleType != null) {
        ((ItemJetpack) this.resultItem).getPack(result).setParticleType(result, particleType);
    }
    if (enderiumUpgrade && this.resultItem instanceof ItemPack) {
        PackBase pack = ((ItemPack) this.resultItem).getPack(result);
        if (pack instanceof JetPlate) {
            ((JetPlate) pack).setEnderiumUpgrade(result, true);
        }
    }
    return result;
}
Also used : ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) JetPlate(tonius.simplyjetpacks.item.meta.JetPlate) PackBase(tonius.simplyjetpacks.item.meta.PackBase) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ParticleType(tonius.simplyjetpacks.setup.ParticleType) ItemPack(tonius.simplyjetpacks.item.ItemPack) ItemStack(net.minecraft.item.ItemStack) IEnergyContainerItem(cofh.api.energy.IEnergyContainerItem)

Example 2 with ItemJetpack

use of tonius.simplyjetpacks.item.ItemPack.ItemJetpack in project SimplyJetpacks by Tonius.

the class EntityInteractHandler method onEntityInteract.

@SubscribeEvent
public void onEntityInteract(EntityInteractEvent evt) {
    if (evt.entityPlayer.isSneaking() && (evt.target instanceof EntityZombie || evt.target instanceof EntitySkeleton)) {
        EntityLiving target = (EntityLiving) evt.target;
        ItemStack heldStack = evt.entityPlayer.getHeldItem();
        if (heldStack != null && heldStack.getItem() instanceof ItemJetpack) {
            if (!target.worldObj.isRemote) {
                target.dropEquipment(true, 3);
            }
            target.setCurrentItemOrArmor(3, heldStack.copy());
            target.equipmentDropChances[3] = 2.0F;
            target.persistenceRequired = true;
            evt.entityPlayer.getHeldItem().stackSize--;
        }
    }
}
Also used : EntityLiving(net.minecraft.entity.EntityLiving) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) EntityZombie(net.minecraft.entity.monster.EntityZombie) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 3 with ItemJetpack

use of tonius.simplyjetpacks.item.ItemPack.ItemJetpack in project SimplyJetpacks by Tonius.

the class LivingTickHandler method mobUseJetpack.

@SubscribeEvent
public void mobUseJetpack(LivingUpdateEvent evt) {
    if (!evt.entityLiving.worldObj.isRemote && evt.entityLiving instanceof EntityMob) {
        ItemStack armor = evt.entityLiving.getEquipmentInSlot(3);
        if (armor != null && armor.getItem() instanceof ItemJetpack) {
            ItemJetpack jetpackItem = (ItemJetpack) armor.getItem();
            Jetpack jetpack = jetpackItem.getPack(armor);
            if (jetpack != null) {
                if (jetpack instanceof JetpackPotato || MathHelper.RANDOM.nextInt(3) == 0) {
                    jetpack.setMobMode(armor);
                    jetpack.flyUser(evt.entityLiving, armor, jetpackItem, false);
                }
            }
            if (evt.entityLiving.posY > evt.entityLiving.worldObj.getActualHeight() + 10) {
                evt.entityLiving.attackEntityFrom(DamageSource.generic, 80);
            }
        }
    }
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) JetpackPotato(tonius.simplyjetpacks.item.meta.JetpackPotato) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) ItemStack(net.minecraft.item.ItemStack) Jetpack(tonius.simplyjetpacks.item.meta.Jetpack) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 4 with ItemJetpack

use of tonius.simplyjetpacks.item.ItemPack.ItemJetpack in project SimplyJetpacks by Tonius.

the class ClientTickHandler method tickStart.

private static void tickStart() {
    if (mc.thePlayer == null) {
        return;
    }
    ParticleType jetpackState = null;
    ItemStack armor = mc.thePlayer.getEquipmentInSlot(3);
    if (armor != null && armor.getItem() instanceof ItemJetpack) {
        Jetpack jetpack = ((ItemJetpack) armor.getItem()).getPack(armor);
        if (jetpack != null) {
            jetpackState = jetpack.getDisplayParticleType(armor, (ItemJetpack) armor.getItem(), mc.thePlayer);
        }
        wearingJetpack = true;
    } else {
        wearingJetpack = false;
    }
    if (jetpackState != lastJetpackState) {
        lastJetpackState = jetpackState;
        SyncHandler.processJetpackUpdate(mc.thePlayer.getEntityId(), jetpackState);
    }
}
Also used : ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) ParticleType(tonius.simplyjetpacks.setup.ParticleType) ItemStack(net.minecraft.item.ItemStack) SoundJetpack(tonius.simplyjetpacks.client.audio.SoundJetpack) Jetpack(tonius.simplyjetpacks.item.meta.Jetpack) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack)

Example 5 with ItemJetpack

use of tonius.simplyjetpacks.item.ItemPack.ItemJetpack in project SimplyJetpacks by Tonius.

the class ModItems method registerItems.

private static void registerItems() {
    SimplyJetpacks.logger.info("Registering items");
    // For compatibility, do not change item IDs until 1.8+
    jetpacksCommon = new ItemJetpack(ModType.SIMPLY_JETPACKS, "jetpacksCommon");
    jetpackPotato = jetpacksCommon.putPack(0, Packs.jetpackPotato, true);
    jetpackCreative = jetpacksCommon.putPack(9001, Packs.jetpackCreative);
    fluxPacksCommon = new ItemFluxPack(ModType.SIMPLY_JETPACKS, "fluxpacksCommon");
    fluxPackCreative = fluxPacksCommon.putPack(9001, Packs.fluxPackCreative);
    if (integrateTE) {
        jetpacksTE = new ItemJetpack(ModType.THERMAL_EXPANSION, "jetpacks");
        jetpackTE1 = jetpacksTE.putPack(1, Packs.jetpackTE1);
        jetpackTE1Armored = jetpacksTE.putPack(101, Packs.jetpackTE1Armored);
        jetpackTE2 = jetpacksTE.putPack(2, Packs.jetpackTE2);
        jetpackTE2Armored = jetpacksTE.putPack(102, Packs.jetpackTE2Armored);
        jetpackTE3 = jetpacksTE.putPack(3, Packs.jetpackTE3);
        jetpackTE3Armored = jetpacksTE.putPack(103, Packs.jetpackTE3Armored);
        jetpackTE4 = jetpacksTE.putPack(4, Packs.jetpackTE4);
        jetpackTE4Armored = jetpacksTE.putPack(104, Packs.jetpackTE4Armored);
        if (integrateRA || Config.addRAItemsIfNotInstalled) {
            jetpackTE5 = jetpacksTE.putPack(5, Packs.jetpackTE5);
        }
        fluxPacksTE = new ItemFluxPack(ModType.THERMAL_EXPANSION, "fluxpacks");
        fluxPackTE1 = fluxPacksTE.putPack(1, Packs.fluxPackTE1);
        fluxPackTE2 = fluxPacksTE.putPack(2, Packs.fluxPackTE2);
        fluxPackTE2Armored = fluxPacksTE.putPack(102, Packs.fluxPackTE2Armored);
        fluxPackTE3 = fluxPacksTE.putPack(3, Packs.fluxPackTE3);
        fluxPackTE3Armored = fluxPacksTE.putPack(103, Packs.fluxPackTE3Armored);
        fluxPackTE4 = fluxPacksTE.putPack(4, Packs.fluxPackTE4);
        fluxPackTE4Armored = fluxPacksTE.putPack(104, Packs.fluxPackTE4Armored);
    }
    if (integrateEIO) {
        jetpacksEIO = new ItemJetpack(ModType.ENDER_IO, "jetpacksEIO");
        jetpackEIO1 = jetpacksEIO.putPack(1, Packs.jetpackEIO1);
        jetpackEIO1Armored = jetpacksEIO.putPack(101, Packs.jetpackEIO1Armored);
        jetpackEIO2 = jetpacksEIO.putPack(2, Packs.jetpackEIO2);
        jetpackEIO2Armored = jetpacksEIO.putPack(102, Packs.jetpackEIO2Armored);
        jetpackEIO3 = jetpacksEIO.putPack(3, Packs.jetpackEIO3);
        jetpackEIO3Armored = jetpacksEIO.putPack(103, Packs.jetpackEIO3Armored);
        jetpackEIO4 = jetpacksEIO.putPack(4, Packs.jetpackEIO4);
        jetpackEIO4Armored = jetpacksEIO.putPack(104, Packs.jetpackEIO4Armored);
        jetpackEIO5 = jetpacksEIO.putPack(5, Packs.jetpackEIO5);
        fluxPacksEIO = new ItemFluxPack(ModType.ENDER_IO, "fluxpacksEIO");
        fluxPackEIO1 = fluxPacksEIO.putPack(1, Packs.fluxPackEIO1);
        fluxPackEIO2 = fluxPacksEIO.putPack(2, Packs.fluxPackEIO2);
        fluxPackEIO2Armored = fluxPacksEIO.putPack(102, Packs.fluxPackEIO2Armored);
        fluxPackEIO3 = fluxPacksEIO.putPack(3, Packs.fluxPackEIO3);
        fluxPackEIO3Armored = fluxPacksEIO.putPack(103, Packs.fluxPackEIO3Armored);
        fluxPackEIO4 = fluxPacksEIO.putPack(4, Packs.fluxPackEIO4);
        fluxPackEIO4Armored = fluxPacksEIO.putPack(104, Packs.fluxPackEIO4Armored);
    }
    if (integrateBC) {
        jetpacksBC = new ItemJetpack(ModType.BUILDCRAFT, "jetpacksBC");
        if (Loader.isModLoaded("BuildCraft|Energy") && Loader.isModLoaded("BuildCraft|Factory")) {
            jetpackBC1 = jetpacksBC.putPack(1, Packs.jetpackBC1);
            jetpackBC1Armored = jetpacksBC.putPack(101, Packs.jetpackBC1Armored);
        }
        jetpackBC2 = jetpacksBC.putPack(2, Packs.jetpackBC2);
        jetpackBC2Armored = jetpacksBC.putPack(102, Packs.jetpackBC2Armored);
    }
    components = new ItemMeta("components");
    armorPlatings = new ItemMeta("armorPlatings");
    particleCustomizers = new ItemMeta("particleCustomizers");
    jetpackFueller = new ItemJetpackFueller("jetpackFueller");
    mysteriousPotato = new ItemMysteriousPotato("mysteriousPotato");
    leatherStrap = components.addMetaItem(0, new MetaItem("leatherStrap", null, EnumRarity.common), true, false);
    jetpackIcon = components.addMetaItem(1, new MetaItem("jetpack.icon", null, EnumRarity.common, false, true), false, false);
    if (integrateTE) {
        thrusterTE1 = components.addMetaItem(11, new MetaItem("thruster.te.1", null, EnumRarity.common), true, false);
        thrusterTE2 = components.addMetaItem(12, new MetaItem("thruster.te.2", null, EnumRarity.common), true, false);
        thrusterTE3 = components.addMetaItem(13, new MetaItem("thruster.te.3", null, EnumRarity.uncommon), true, false);
        thrusterTE4 = components.addMetaItem(14, new MetaItem("thruster.te.4", null, EnumRarity.rare), true, false);
        if (integrateRA || Config.addRAItemsIfNotInstalled) {
            thrusterTE5 = components.addMetaItem(15, new MetaItem("thruster.te.5", null, EnumRarity.epic), true, false);
            unitGlowstoneEmpty = components.addMetaItem(60, new MetaItem("unitGlowstone.empty", null, EnumRarity.common), true, false);
            unitGlowstone = components.addMetaItem(61, new MetaItem("unitGlowstone", null, EnumRarity.uncommon), true, false);
            unitCryotheumEmpty = components.addMetaItem(62, new MetaItem("unitCryotheum.empty", null, EnumRarity.common), true, false);
            unitCryotheum = components.addMetaItem(63, new MetaItem("unitCryotheum", null, EnumRarity.rare), true, false);
        }
        if (!integrateRA && Config.addRAItemsIfNotInstalled) {
            dustElectrumFlux = components.addMetaItem(64, new MetaItem("dustElectrumFlux", "raReplacement", EnumRarity.uncommon), true, true);
            ingotElectrumFlux = components.addMetaItem(65, new MetaItem("ingotElectrumFlux", "raReplacement", EnumRarity.uncommon), true, true);
            nuggetElectrumFlux = components.addMetaItem(66, new MetaItem("nuggetElectrumFlux", "raReplacement", EnumRarity.uncommon), true, true);
            gemCrystalFlux = components.addMetaItem(67, new MetaItem("gemCrystalFlux", "raReplacement", EnumRarity.uncommon), true, true);
            plateFlux = components.addMetaItem(68, new MetaItem("plateFlux", "raReplacement", EnumRarity.uncommon), true, false);
            armorFluxPlate = components.addMetaItem(69, new MetaItem("armorFluxPlate", "raReplacement", EnumRarity.uncommon), true, false);
        }
        if (ModType.REDSTONE_ARMORY.loaded) {
            enderiumUpgrade = components.addMetaItem(59, new MetaItem("enderiumUpgrade", "enderiumUpgrade", EnumRarity.rare), true, false);
        }
        armorPlatingTE1 = armorPlatings.addMetaItem(1, new MetaItem("armorPlating.te.1", null, EnumRarity.common), true, false);
        armorPlatingTE2 = armorPlatings.addMetaItem(2, new MetaItem("armorPlating.te.2", null, EnumRarity.common), true, false);
        armorPlatingTE3 = armorPlatings.addMetaItem(3, new MetaItem("armorPlating.te.3", null, EnumRarity.common), true, false);
        armorPlatingTE4 = armorPlatings.addMetaItem(4, new MetaItem("armorPlating.te.4", null, EnumRarity.rare), true, false);
    }
    if (integrateEIO) {
        thrusterEIO1 = components.addMetaItem(21, new MetaItem("thruster.eio.1", null, EnumRarity.common), true, false);
        thrusterEIO2 = components.addMetaItem(22, new MetaItem("thruster.eio.2", null, EnumRarity.common), true, false);
        thrusterEIO3 = components.addMetaItem(23, new MetaItem("thruster.eio.3", null, EnumRarity.uncommon), true, false);
        thrusterEIO4 = components.addMetaItem(24, new MetaItem("thruster.eio.4", null, EnumRarity.rare), true, false);
        thrusterEIO5 = components.addMetaItem(25, new MetaItem("thruster.eio.5", null, EnumRarity.epic), true, false);
        ingotDarkSoularium = components.addMetaItem(70, new MetaItem("ingotDarkSoularium", null, EnumRarity.uncommon, true, false), true, true);
        reinforcedGliderWing = components.addMetaItem(71, new MetaItem("reinforcedGliderWing", null, EnumRarity.uncommon), true, false);
        unitFlightControlEmpty = components.addMetaItem(72, new MetaItem("unitFlightControl.empty", null, EnumRarity.common), true, false);
        unitFlightControl = components.addMetaItem(73, new MetaItem("unitFlightControl", null, EnumRarity.uncommon), true, false);
        armorPlatingEIO1 = armorPlatings.addMetaItem(11, new MetaItem("armorPlating.eio.1", null, EnumRarity.common), true, false);
        armorPlatingEIO2 = armorPlatings.addMetaItem(12, new MetaItem("armorPlating.eio.2", null, EnumRarity.common), true, false);
        armorPlatingEIO3 = armorPlatings.addMetaItem(13, new MetaItem("armorPlating.eio.3", null, EnumRarity.common), true, false);
        armorPlatingEIO4 = armorPlatings.addMetaItem(14, new MetaItem("armorPlating.eio.4", null, EnumRarity.common), true, false);
    }
    if (integrateBC) {
        if (Loader.isModLoaded("BuildCraft|Energy") && Loader.isModLoaded("BuildCraft|Factory")) {
            thrusterBC1 = components.addMetaItem(31, new MetaItem("thruster.bc.1", null, EnumRarity.common), true, false);
        }
        thrusterBC2 = components.addMetaItem(32, new MetaItem("thruster.bc.2", null, EnumRarity.uncommon), true, false);
        armorPlatingBC1 = armorPlatings.addMetaItem(21, new MetaItem("armorPlating.bc.1", null, EnumRarity.common), true, false);
        armorPlatingBC2 = armorPlatings.addMetaItem(22, new MetaItem("armorPlating.bc.2", null, EnumRarity.uncommon), true, false);
    }
    particleDefault = particleCustomizers.addMetaItem(0, new MetaItem("particle.0", "particleCustomizers", EnumRarity.common), true, false);
    particleNone = particleCustomizers.addMetaItem(1, new MetaItem("particle.1", "particleCustomizers", EnumRarity.common), true, false);
    particleSmoke = particleCustomizers.addMetaItem(2, new MetaItem("particle.2", "particleCustomizers", EnumRarity.common), true, false);
    particleRainbowSmoke = particleCustomizers.addMetaItem(3, new MetaItem("particle.3", "particleCustomizers", EnumRarity.common), true, false);
}
Also used : MetaItem(tonius.simplyjetpacks.item.ItemMeta.MetaItem) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) ItemFluxPack(tonius.simplyjetpacks.item.ItemPack.ItemFluxPack) ItemMeta(tonius.simplyjetpacks.item.ItemMeta) ItemJetpackFueller(tonius.simplyjetpacks.item.ItemJetpackFueller) ItemMysteriousPotato(tonius.simplyjetpacks.item.ItemMysteriousPotato)

Aggregations

ItemJetpack (tonius.simplyjetpacks.item.ItemPack.ItemJetpack)6 ItemStack (net.minecraft.item.ItemStack)5 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)3 Jetpack (tonius.simplyjetpacks.item.meta.Jetpack)3 ParticleType (tonius.simplyjetpacks.setup.ParticleType)3 IEnergyContainerItem (cofh.api.energy.IEnergyContainerItem)1 TargetPoint (cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)1 EntityLiving (net.minecraft.entity.EntityLiving)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 EntitySkeleton (net.minecraft.entity.monster.EntitySkeleton)1 EntityZombie (net.minecraft.entity.monster.EntityZombie)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 SoundJetpack (tonius.simplyjetpacks.client.audio.SoundJetpack)1 ItemJetpackFueller (tonius.simplyjetpacks.item.ItemJetpackFueller)1 ItemMeta (tonius.simplyjetpacks.item.ItemMeta)1 MetaItem (tonius.simplyjetpacks.item.ItemMeta.MetaItem)1 ItemMysteriousPotato (tonius.simplyjetpacks.item.ItemMysteriousPotato)1 ItemPack (tonius.simplyjetpacks.item.ItemPack)1 ItemFluxPack (tonius.simplyjetpacks.item.ItemPack.ItemFluxPack)1 JetPlate (tonius.simplyjetpacks.item.meta.JetPlate)1