use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class CompendiumUnlockHandler method onEntityDeath.
/**
* This should handle all mobs and the Astral Barrier
*
* @param event
*/
@SubscribeEvent
public void onEntityDeath(LivingDeathEvent event) {
if (event.entityLiving.worldObj.isRemote && event.source.getSourceOfDamage() instanceof EntityPlayer) {
if (event.entity instanceof EntityEnderman) {
ArcaneCompendium.instance.unlockEntry("blockastralbarrier");
} else {
EntityRegistration reg = EntityRegistry.instance().lookupModSpawn(event.entityLiving.getClass(), true);
if (reg != null && reg.getContainer().matches(AMCore.instance)) {
String id = reg.getEntityName();
ArcaneCompendium.instance.unlockEntry(id);
}
}
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class AMEventHandler method onBucketFill.
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {
ItemStack result = attemptFill(event.world, event.target);
if (result != null) {
event.result = result;
event.setResult(Result.ALLOW);
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class AMEventHandler method onEntityConstructing.
@SubscribeEvent
public void onEntityConstructing(EntityConstructing event) {
if (event.entity instanceof EntityLivingBase) {
event.entity.registerExtendedProperties(ExtendedProperties.identifier, new ExtendedProperties());
((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.maxManaBonus);
((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.maxBurnoutBonus);
((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.xpGainModifier);
((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.burnoutReductionRate);
((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.manaRegenTimeModifier);
if (event.entity instanceof EntityPlayer) {
event.entity.registerExtendedProperties(RiftStorage.identifier, new RiftStorage());
event.entity.registerExtendedProperties(AffinityData.identifier, new AffinityData());
event.entity.registerExtendedProperties(SkillData.identifier, new SkillData((EntityPlayer) event.entity));
}
} else if (event.entity instanceof EntityItemFrame) {
AMCore.proxy.itemFrameWatcher.startWatchingFrame((EntityItemFrame) event.entity);
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class AMEventHandler method onEntityHurt.
@SubscribeEvent
public void onEntityHurt(LivingHurtEvent event) {
if (event.source.isFireDamage() && event.entityLiving instanceof EntityPlayer && ((EntityPlayer) event.entityLiving).inventory.armorInventory[3] != null && ((EntityPlayer) event.entityLiving).inventory.armorInventory[3].getItem() == ItemsCommonProxy.fireEars) {
event.setCanceled(true);
return;
}
if (event.entityLiving.isPotionActive(BuffList.magicShield))
event.ammount *= 0.25f;
if (event.entityLiving.isPotionActive(BuffList.manaShield)) {
float manaToTake = Math.min(ExtendedProperties.For(event.entityLiving).getCurrentMana(), event.ammount * 250f);
event.ammount -= manaToTake / 250f;
ExtendedProperties.For(event.entityLiving).deductMana(manaToTake);
ExtendedProperties.For(event.entityLiving).forceSync();
for (int i = 0; i < Math.min(event.ammount, 5 * AMCore.config.getGFXLevel()); ++i) AMCore.proxy.particleManager.BoltFromPointToPoint(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY + event.entityLiving.worldObj.rand.nextFloat() * event.entityLiving.getEyeHeight(), event.entityLiving.posZ, event.entityLiving.posX - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, event.entityLiving.posY + event.entityLiving.getEyeHeight() - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, event.entityLiving.posZ - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, 6, -1);
event.entityLiving.worldObj.playSoundAtEntity(event.entityLiving, "arsmagica2:misc.event.mana_shield_block", 1.0f, event.entityLiving.worldObj.rand.nextFloat() + 0.5f);
if (event.ammount <= 0) {
event.setCanceled(true);
return;
}
}
Entity entitySource = event.source.getSourceOfDamage();
if (entitySource instanceof EntityPlayer && ((EntityPlayer) entitySource).inventory.armorInventory[2] != null && ((EntityPlayer) entitySource).inventory.armorInventory[2].getItem() == ItemsCommonProxy.earthGuardianArmor && ((EntityPlayer) entitySource).getCurrentEquippedItem() == null) {
event.ammount += 4;
double deltaZ = event.entityLiving.posZ - entitySource.posZ;
double deltaX = event.entityLiving.posX - entitySource.posX;
double angle = Math.atan2(deltaZ, deltaX);
double speed = ((EntityPlayer) entitySource).isSprinting() ? 3 : 2;
double vertSpeed = ((EntityPlayer) entitySource).isSprinting() ? 0.5 : 0.325;
if (event.entityLiving instanceof EntityPlayer) {
AMNetHandler.INSTANCE.sendVelocityAddPacket(event.entityLiving.worldObj, event.entityLiving, speed * Math.cos(angle), vertSpeed, speed * Math.sin(angle));
} else {
event.entityLiving.motionX += (speed * Math.cos(angle));
event.entityLiving.motionZ += (speed * Math.sin(angle));
event.entityLiving.motionY += vertSpeed;
}
event.entityLiving.worldObj.playSoundAtEntity(event.entityLiving, "arsmagica2:spell.cast.earth", 0.4f, event.entityLiving.worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
ExtendedProperties extendedProperties = ExtendedProperties.For(event.entityLiving);
EntityLivingBase ent = event.entityLiving;
if (extendedProperties.getContingencyType() == ContingencyTypes.DAMAGE_TAKEN) {
extendedProperties.procContingency();
}
if (extendedProperties.getContingencyType() == ContingencyTypes.HEALTH_LOW && ent.getHealth() <= ent.getMaxHealth() / 3) {
extendedProperties.procContingency();
}
if (ent.isPotionActive(BuffList.fury.id))
event.ammount /= 2;
if (entitySource instanceof EntityLivingBase && ((EntityLivingBase) entitySource).isPotionActive(BuffList.shrink))
event.ammount /= 2;
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class AMEventHandler method onEntityDeathChrono.
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityDeathChrono(LivingDeathEvent event) {
EntityLivingBase soonToBeDead = event.entityLiving;
if (soonToBeDead.isPotionActive(BuffList.temporalAnchor.id)) {
event.setCanceled(true);
PotionEffect pe = soonToBeDead.getActivePotionEffect(BuffList.temporalAnchor);
if (pe instanceof BuffEffectTemporalAnchor) {
BuffEffectTemporalAnchor buff = (BuffEffectTemporalAnchor) pe;
buff.stopEffect(soonToBeDead);
}
soonToBeDead.removePotionEffect(BuffList.temporalAnchor.id);
return;
}
}
Aggregations