Search in sources :

Example 1 with Jetpack

use of tonius.simplyjetpacks.item.meta.Jetpack 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 2 with Jetpack

use of tonius.simplyjetpacks.item.meta.Jetpack 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 3 with Jetpack

use of tonius.simplyjetpacks.item.meta.Jetpack in project SimplyJetpacks by Tonius.

the class LivingTickHandler method onLivingTick.

@SubscribeEvent
public void onLivingTick(LivingUpdateEvent evt) {
    if (!evt.entityLiving.worldObj.isRemote) {
        ParticleType jetpackState = null;
        ItemStack armor = evt.entityLiving.getEquipmentInSlot(3);
        Jetpack jetpack = null;
        if (armor != null && armor.getItem() instanceof ItemJetpack) {
            jetpack = ((ItemJetpack) armor.getItem()).getPack(armor);
            if (jetpack != null) {
                jetpackState = jetpack.getDisplayParticleType(armor, (ItemJetpack) armor.getItem(), evt.entityLiving);
            }
        }
        if (jetpackState != lastJetpackState.get(evt.entityLiving.getEntityId())) {
            if (jetpackState == null) {
                lastJetpackState.remove(evt.entityLiving.getEntityId());
            } else {
                lastJetpackState.put(evt.entityLiving.getEntityId(), jetpackState);
            }
            PacketHandler.instance.sendToAllAround(new MessageJetpackSync(evt.entityLiving.getEntityId(), jetpackState != null ? jetpackState.ordinal() : -1), new TargetPoint(evt.entityLiving.dimension, evt.entityLiving.posX, evt.entityLiving.posY, evt.entityLiving.posZ, 256));
        } else if (jetpack != null && evt.entityLiving.worldObj.getTotalWorldTime() % 160L == 0) {
            PacketHandler.instance.sendToAllAround(new MessageJetpackSync(evt.entityLiving.getEntityId(), jetpackState != null ? jetpackState.ordinal() : -1), new TargetPoint(evt.entityLiving.dimension, evt.entityLiving.posX, evt.entityLiving.posY, evt.entityLiving.posZ, 256));
        }
        if (evt.entityLiving.worldObj.getTotalWorldTime() % 200L == 0) {
            Iterator<Integer> itr = lastJetpackState.keySet().iterator();
            while (itr.hasNext()) {
                int entityId = itr.next();
                if (evt.entityLiving.worldObj.getEntityByID(entityId) == null) {
                    itr.remove();
                }
            }
        }
    }
}
Also used : MessageJetpackSync(tonius.simplyjetpacks.network.message.MessageJetpackSync) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) ParticleType(tonius.simplyjetpacks.setup.ParticleType) ItemStack(net.minecraft.item.ItemStack) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint) Jetpack(tonius.simplyjetpacks.item.meta.Jetpack) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 4 with Jetpack

use of tonius.simplyjetpacks.item.meta.Jetpack in project SimplyJetpacks by Tonius.

the class Packs method preInit.

public static void preInit() {
    jetpackPotato = new JetpackPotato(0, EnumRarity.common, "jetpackPotato");
    jetpackCreative = (Jetpack) new JetPlate(9001, EnumRarity.epic, "jetpackCreative").setDefaultParticleType(ParticleType.RAINBOW_SMOKE).setUsesFuel(false).setHasFuelIndicator(false).setShowEmptyInCreativeTab(false);
    fluxPackCreative = (FluxPack) new FluxPack(9001, EnumRarity.epic, "fluxPackCreative").setUsesFuel(false).setHasFuelIndicator(false).setShowEmptyInCreativeTab(false).setIsArmored(true).setShowArmored(false);
    if (ModType.THERMAL_EXPANSION.loaded) {
        jetpackTE1 = new Jetpack(1, EnumRarity.common, "jetpackTE1");
        jetpackTE1Armored = (Jetpack) new Jetpack(1, EnumRarity.common, "jetpackTE1").setIsArmored(true).setPlatingMeta(1);
        jetpackTE2 = new Jetpack(2, EnumRarity.common, "jetpackTE2");
        jetpackTE2Armored = (Jetpack) new Jetpack(2, EnumRarity.common, "jetpackTE2").setIsArmored(true).setPlatingMeta(2);
        jetpackTE3 = new Jetpack(3, EnumRarity.uncommon, "jetpackTE3");
        jetpackTE3Armored = (Jetpack) new Jetpack(3, EnumRarity.uncommon, "jetpackTE3").setIsArmored(true).setPlatingMeta(3);
        jetpackTE4 = new Jetpack(4, EnumRarity.rare, "jetpackTE4");
        jetpackTE4Armored = (Jetpack) new Jetpack(4, EnumRarity.rare, "jetpackTE4").setIsArmored(true).setPlatingMeta(4);
        jetpackTE5 = (Jetpack) new JetPlate(5, EnumRarity.epic, "jetpackTE5").setFluxBased(true);
        fluxPackTE1 = new FluxPack(1, EnumRarity.common, "fluxPackTE1");
        fluxPackTE2 = new FluxPack(2, EnumRarity.common, "fluxPackTE2");
        fluxPackTE2Armored = (FluxPack) new FluxPack(2, EnumRarity.common, "fluxPackTE2").setIsArmored(true).setPlatingMeta(1);
        fluxPackTE3 = new FluxPack(3, EnumRarity.uncommon, "fluxPackTE3");
        fluxPackTE3Armored = (FluxPack) new FluxPack(3, EnumRarity.uncommon, "fluxPackTE3").setIsArmored(true).setPlatingMeta(2);
        fluxPackTE4 = new FluxPack(4, EnumRarity.rare, "fluxPackTE4");
        fluxPackTE4Armored = (FluxPack) new FluxPack(4, EnumRarity.rare, "fluxPackTE4").setIsArmored(true).setPlatingMeta(3);
    }
    if (ModType.ENDER_IO.loaded) {
        jetpackEIO1 = new Jetpack(1, EnumRarity.common, "jetpackEIO1");
        jetpackEIO1Armored = (Jetpack) new Jetpack(1, EnumRarity.common, "jetpackEIO1").setIsArmored(true).setPlatingMeta(11);
        jetpackEIO2 = new Jetpack(2, EnumRarity.common, "jetpackEIO2");
        jetpackEIO2Armored = (Jetpack) new Jetpack(2, EnumRarity.common, "jetpackEIO2").setIsArmored(true).setPlatingMeta(12);
        jetpackEIO3 = new Jetpack(3, EnumRarity.uncommon, "jetpackEIO3");
        jetpackEIO3Armored = (Jetpack) new Jetpack(3, EnumRarity.uncommon, "jetpackEIO3").setIsArmored(true).setPlatingMeta(13);
        jetpackEIO4 = new Jetpack(4, EnumRarity.rare, "jetpackEIO4");
        jetpackEIO4Armored = (Jetpack) new Jetpack(4, EnumRarity.rare, "jetpackEIO4").setIsArmored(true).setPlatingMeta(14);
        jetpackEIO5 = new JetPlate(5, EnumRarity.epic, "jetpackEIO5");
        fluxPackEIO1 = new FluxPack(1, EnumRarity.common, "fluxPackEIO1");
        fluxPackEIO2 = new FluxPack(2, EnumRarity.common, "fluxPackEIO2");
        fluxPackEIO2Armored = (FluxPack) new FluxPack(2, EnumRarity.common, "fluxPackEIO2").setIsArmored(true).setPlatingMeta(11);
        fluxPackEIO3 = new FluxPack(3, EnumRarity.uncommon, "fluxPackEIO3");
        fluxPackEIO3Armored = (FluxPack) new FluxPack(3, EnumRarity.uncommon, "fluxPackEIO3").setIsArmored(true).setPlatingMeta(12);
        fluxPackEIO4 = new FluxPack(4, EnumRarity.rare, "fluxPackEIO4");
        fluxPackEIO4Armored = (FluxPack) new FluxPack(4, EnumRarity.rare, "fluxPackEIO4").setIsArmored(true).setPlatingMeta(13);
    }
    if (ModType.BUILDCRAFT.loaded) {
        boolean energyFactoryLoaded = Loader.isModLoaded("BuildCraft|Energy") && Loader.isModLoaded("BuildCraft|Factory");
        if (energyFactoryLoaded) {
            jetpackBC1 = (Jetpack) new Jetpack(1, EnumRarity.common, "jetpackBC1").setFuelFluid("fuel");
            jetpackBC1Armored = (Jetpack) new Jetpack(1, EnumRarity.common, "jetpackBC1").setFuelFluid("fuel").setIsArmored(true).setPlatingMeta(21);
        }
        jetpackBC2 = (Jetpack) new Jetpack(2, EnumRarity.uncommon, "jetpackBC2").setShowTier(energyFactoryLoaded);
        jetpackBC2Armored = (Jetpack) new Jetpack(2, EnumRarity.uncommon, "jetpackBC2").setIsArmored(true).setPlatingMeta(22).setShowTier(energyFactoryLoaded);
    }
}
Also used : JetpackPotato(tonius.simplyjetpacks.item.meta.JetpackPotato) JetPlate(tonius.simplyjetpacks.item.meta.JetPlate) FluxPack(tonius.simplyjetpacks.item.meta.FluxPack) Jetpack(tonius.simplyjetpacks.item.meta.Jetpack)

Aggregations

Jetpack (tonius.simplyjetpacks.item.meta.Jetpack)4 ItemStack (net.minecraft.item.ItemStack)3 ItemJetpack (tonius.simplyjetpacks.item.ItemPack.ItemJetpack)3 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 JetpackPotato (tonius.simplyjetpacks.item.meta.JetpackPotato)2 ParticleType (tonius.simplyjetpacks.setup.ParticleType)2 TargetPoint (cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 SoundJetpack (tonius.simplyjetpacks.client.audio.SoundJetpack)1 FluxPack (tonius.simplyjetpacks.item.meta.FluxPack)1 JetPlate (tonius.simplyjetpacks.item.meta.JetPlate)1 MessageJetpackSync (tonius.simplyjetpacks.network.message.MessageJetpackSync)1