use of net.minecraft.entity.monster.EntityEnderman in project ArsMagica2 by Mithion.
the class AffinityHelper method onEntityHurt.
@SubscribeEvent
public void onEntityHurt(LivingHurtEvent event) {
EntityLivingBase ent = event.entityLiving;
AffinityData affinityData = AffinityData.For(ent);
if (event.source.getSourceOfDamage() instanceof EntityPlayer) {
float attackerFireDepth = AffinityData.For((EntityLivingBase) event.source.getSourceOfDamage()).getAffinityDepth(Affinity.FIRE);
if (attackerFireDepth > 0.8f && ((EntityPlayer) event.source.getSourceOfDamage()).getCurrentEquippedItem() == null) {
ent.setFire(4);
event.ammount += 3;
}
float attackerLightningDepth = AffinityData.For((EntityLivingBase) event.source.getSourceOfDamage()).getAffinityDepth(Affinity.LIGHTNING);
if (attackerLightningDepth > 0.75f && !ent.worldObj.isRemote && ((EntityPlayer) event.source.getSourceOfDamage()).getCurrentEquippedItem() == null) {
EntityLightningBolt elb = new EntityLightningBolt(ent.worldObj, ent.posX, ent.posY, ent.posZ);
elb.setPosition(ent.posX, ent.posY, ent.posZ);
ent.worldObj.addWeatherEffect(elb);
}
}
if (!(ent instanceof EntityPlayer))
return;
float earthDepth = affinityData.getAffinityDepth(Affinity.EARTH);
if (earthDepth > 0.25f) {
float reduction = 0.1f * earthDepth;
event.ammount -= event.ammount * reduction;
}
float arcaneDepth = affinityData.getAffinityDepth(Affinity.ARCANE);
if (arcaneDepth > 0.25f) {
event.ammount *= 1.1f;
}
float waterDepth = affinityData.getAffinityDepth(Affinity.WATER);
if (waterDepth > 0.9f && event.source.getSourceOfDamage() instanceof EntityEnderman) {
event.source.getSourceOfDamage().attackEntityFrom(DamageSource.drown, 2);
}
float fireDepth = affinityData.getAffinityDepth(Affinity.FIRE);
if (event.source.isFireDamage()) {
float reduction = 1 - (0.6f * fireDepth);
event.ammount = event.ammount * reduction;
}
float enderDepth = affinityData.getAffinityDepth(Affinity.ENDER);
if (event.source == DamageSource.magic || event.source == DamageSource.wither) {
float reduction = 1 - (0.75f * enderDepth);
event.ammount = event.ammount * reduction;
}
if (event.source.getSourceOfDamage() instanceof EntityLivingBase) {
float natureDepth = affinityData.getAffinityDepth(Affinity.NATURE);
if (natureDepth == 1.0f) {
((EntityLivingBase) event.source.getSourceOfDamage()).attackEntityFrom(DamageSource.cactus, 3);
} else if (natureDepth >= 0.75f) {
((EntityLivingBase) event.source.getSourceOfDamage()).attackEntityFrom(DamageSource.cactus, 2);
} else if (natureDepth >= 0.5f) {
((EntityLivingBase) event.source.getSourceOfDamage()).attackEntityFrom(DamageSource.cactus, 1);
}
float iceDepth = affinityData.getAffinityDepth(Affinity.ICE);
BuffEffectFrostSlowed effect = null;
if (iceDepth == 1.0f) {
effect = new BuffEffectFrostSlowed(200, 2);
} else if (iceDepth >= 0.75f) {
effect = new BuffEffectFrostSlowed(160, 1);
} else if (iceDepth >= 0.5f) {
effect = new BuffEffectFrostSlowed(100, 0);
}
if (effect != null) {
((EntityLivingBase) event.source.getSourceOfDamage()).addPotionEffect(effect);
}
}
if (event.ammount == 0)
event.setCanceled(true);
}
use of net.minecraft.entity.monster.EntityEnderman in project ArsMagica2 by Mithion.
the class AffinityHelper method onEntityLivingBase.
@SubscribeEvent
public void onEntityLivingBase(LivingUpdateEvent event) {
EntityLivingBase ent = event.entityLiving;
if (ent instanceof EntityEnderman) {
if (ent.getLastAttacker() != ent.getAITarget() && ent.getAITarget() instanceof EntityPlayer) {
AffinityData affinityData = AffinityData.For(ent.getAITarget());
float enderDepth = affinityData.getAffinityDepth(Affinity.ENDER);
if (enderDepth == 1.0f) {
ent.setRevengeTarget(null);
}
}
}
if (!(ent instanceof EntityPlayer))
return;
AffinityData affinityData = AffinityData.For(ent);
affinityData.tickDiminishingReturns();
float waterDepth = affinityData.getAffinityDepth(Affinity.WATER);
float fireDepth = affinityData.getAffinityDepth(Affinity.FIRE);
float natureDepth = affinityData.getAffinityDepth(Affinity.NATURE);
float iceDepth = affinityData.getAffinityDepth(Affinity.ICE);
float lifeDepth = affinityData.getAffinityDepth(Affinity.LIFE);
float enderDepth = affinityData.getAffinityDepth(Affinity.ENDER);
float lightningDepth = affinityData.getAffinityDepth(Affinity.LIGHTNING);
AffinityModifiers.instance.applySpeedModifiersBasedOnDepth((EntityPlayer) ent, natureDepth, iceDepth, lightningDepth);
AffinityModifiers.instance.applyHealthModifiers((EntityPlayer) ent, enderDepth, waterDepth, fireDepth, lightningDepth);
applyFulmintion((EntityPlayer) ent, lightningDepth);
if (lightningDepth >= 0.5f) {
ent.stepHeight = 1.014f;
} else if (ent.stepHeight == 1.014f) {
ent.stepHeight = 0.5f;
}
affinityData.accumulatedLifeRegen += 0.025 * lifeDepth;
if (affinityData.accumulatedLifeRegen > 1.0f) {
affinityData.accumulatedLifeRegen -= 1.0f;
ent.heal(1);
}
if (natureDepth == 1.0f) {
if (ent.worldObj.canBlockSeeTheSky((int) ent.posX, (int) ent.posY, (int) ent.posZ) && ent.worldObj.isDaytime()) {
affinityData.accumulatedHungerRegen += 0.02f;
if (affinityData.accumulatedHungerRegen > 1.0f) {
((EntityPlayer) ent).getFoodStats().addStats(1, 0.025f);
affinityData.accumulatedHungerRegen -= 1;
}
} else {
((EntityPlayer) ent).addExhaustion(0.025f);
}
if (ent.isCollidedHorizontally) {
if (!ent.isSneaking()) {
float movement = ExtendedProperties.For(ent).getIsFlipped() ? -0.25f : 0.25f;
ent.moveEntity(0, movement, 0);
ent.motionY = 0;
} else {
ent.motionY *= 0.79999999;
}
ent.fallDistance = 0;
}
}
//Ender Affinity
if (enderDepth >= 0.75f && affinityData.hasActivatedNightVision()) {
if (!ent.worldObj.isRemote && (!ent.isPotionActive(Potion.nightVision.id) || ent.getActivePotionEffect(Potion.nightVision).getDuration() <= 220)) {
ent.addPotionEffect(new PotionEffect(Potion.nightVision.id, 300, 1));
}
}
if (ent.onGround)
affinityData.setLastGroundPosition(new AMVector3(ent));
affinityData.tickCooldown();
if (ent.isInWater()) {
float earthDepth = affinityData.getAffinityDepth(Affinity.EARTH);
if (earthDepth > 0.25f && ent.motionY > -0.3f) {
ent.addVelocity(0, -0.01f * earthDepth, 0);
}
if (waterDepth > 0.5f) {
if (!ent.isPotionActive(BuffList.swiftSwim.id) || ent.getActivePotionEffect(BuffList.swiftSwim).getDuration() < 10) {
ent.addPotionEffect(new BuffEffectSwiftSwim(100, waterDepth > 0.75f ? 2 : 1));
}
}
if (waterDepth > 0.4 && ent.worldObj.rand.nextInt(20) < 4)
ent.setAir(ent.getAir() + 1);
if (!ent.worldObj.isRemote && ent.worldObj.rand.nextInt(100) < 5) {
ent.setAir(ent.getAir() + 1);
byte[] data = new AMDataWriter().add(ent.getEntityId()).add(ent.getAir()).generate();
AMNetHandler.INSTANCE.sendPacketToClientPlayer((EntityPlayerMP) ent, AMPacketIDs.SYNC_AIR_CHANGE, data);
}
boolean waterMovementFlag = false;
if ((ent instanceof EntityPlayer && ((EntityPlayer) ent).inventory.armorInventory[1] != null && ((EntityPlayer) ent).inventory.armorInventory[1].getItem() == ItemsCommonProxy.waterGuardianOrbs)) {
waterMovementFlag = true;
if (!ent.worldObj.isRemote && (!ent.isPotionActive(BuffList.waterBreathing) || ent.getActivePotionEffect(BuffList.waterBreathing).getDuration() <= 200))
ent.addPotionEffect(new BuffEffectWaterBreathing(400, 2));
}
if (waterDepth > 0.5f || waterMovementFlag) {
applyReverseWaterMovement(ent);
}
}
if (ent.worldObj.isRaining() && !ent.worldObj.isRemote && ent.worldObj.getBiomeGenForCoords((int) Math.floor(ent.posX), (int) Math.floor(ent.posZ)).canSpawnLightningBolt()) {
float airDepth = affinityData.getAffinityDepth(Affinity.AIR);
if (airDepth > 0.5f && airDepth < 0.85f && !ent.worldObj.isRemote && ent.worldObj.rand.nextInt(100) < 10) {
if (!ent.isSneaking() && !ent.isPotionActive(BuffList.gravityWell) && !ent.isInsideOfMaterial(Material.water) && ent.isWet()) {
double velX = ent.worldObj.rand.nextDouble() - 0.5;
double velY = ent.worldObj.rand.nextDouble() - 0.5;
double velZ = ent.worldObj.rand.nextDouble() - 0.5;
ent.addVelocity(velX, velY, velZ);
AMNetHandler.INSTANCE.sendVelocityAddPacket(ent.worldObj, ent, velX, velY, velZ);
}
}
}
if (ent.isSneaking()) {
if (iceDepth >= 0.5f) {
makeIceBridge((EntityPlayer) ent, iceDepth);
}
}
}
use of net.minecraft.entity.monster.EntityEnderman in project BluePower by Qmunity.
the class BPEventHandler method onEntityAttack.
@SubscribeEvent
public void onEntityAttack(LivingAttackEvent event) {
if (!isAttacking && event.source instanceof EntityDamageSource) {
// this event will be trigger recursively by EntityLiving#attackEntityFrom,
// so we need to stop the loop.
EntityDamageSource entitySource = (EntityDamageSource) event.source;
if (entitySource.getEntity() instanceof EntityPlayer) {
EntityPlayer killer = (EntityPlayer) entitySource.getEntity();
if (killer.inventory.getCurrentItem() != null) {
if (EnchantmentHelper.getEnchantments(killer.inventory.getCurrentItem()).containsKey(BPEnchantments.disjunction.effectId)) {
if (event.entityLiving instanceof EntityEnderman || event.entityLiving instanceof EntityDragon) {
int level = EnchantmentHelper.getEnchantmentLevel(BPEnchantments.disjunction.effectId, killer.inventory.getCurrentItem());
isAttacking = true;
event.entityLiving.attackEntityFrom(event.source, event.ammount * (level * 0.5F + 1));
isAttacking = false;
event.setCanceled(true);
}
}
}
}
}
}
use of net.minecraft.entity.monster.EntityEnderman in project ICBM-Classic by BuiltBrokenModding.
the class BlastEnderman method doPostExplode.
@Override
public void doPostExplode() {
super.doPostExplode();
if (!this.world().isRemote) {
for (int i = 0; i < 8; i++) {
EntityEnderman enderman = new EntityEnderman(world());
enderman.setPosition(this.position.x(), this.position.y(), this.position.z());
this.world().spawnEntityInWorld(enderman);
}
}
}
use of net.minecraft.entity.monster.EntityEnderman in project ArsMagica2 by Mithion.
the class AMEventHandler method onEndermanTeleport.
@SubscribeEvent
public void onEndermanTeleport(EnderTeleportEvent event) {
EntityLivingBase ent = event.entityLiving;
ArrayList<Long> keystoneKeys = KeystoneUtilities.instance.GetKeysInInvenory(ent);
TileEntityAstralBarrier blockingBarrier = DimensionUtilities.GetBlockingAstralBarrier(event.entityLiving.worldObj, (int) event.targetX, (int) event.targetY, (int) event.targetZ, keystoneKeys);
if (ent.isPotionActive(BuffList.astralDistortion.id) || blockingBarrier != null) {
event.setCanceled(true);
if (blockingBarrier != null) {
blockingBarrier.onEntityBlocked(ent);
}
return;
}
if (!ent.worldObj.isRemote && ent instanceof EntityEnderman && ent.worldObj.rand.nextDouble() < 0.01f) {
EntityFlicker flicker = new EntityFlicker(ent.worldObj);
flicker.setPosition(ent.posX, ent.posY, ent.posZ);
flicker.setFlickerType(Affinity.ENDER);
ent.worldObj.spawnEntityInWorld(flicker);
}
}
Aggregations