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);
}
}
}
}
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);
}
}
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();
}
}
}
}
}
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);
}
}
Aggregations