use of net.minecraft.entity.EntityLivingBase in project Pearcel-Mod by MiningMark48.
the class EntityEnderPearcel method onImpact.
@Override
protected void onImpact(RayTraceResult result) {
EntityLivingBase entitylivingbase = this.getThrower();
if (result.entityHit != null) {
if (result.entityHit == this.thrower) {
return;
}
result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, entitylivingbase), 0.0F);
}
if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
BlockPos entityplayermp = result.getBlockPos();
TileEntity event = this.world.getTileEntity(entityplayermp);
if (event instanceof TileEntityEndGateway) {
TileEntityEndGateway var9 = (TileEntityEndGateway) event;
if (entitylivingbase != null) {
var9.teleportEntity(entitylivingbase);
this.setDead();
return;
}
var9.teleportEntity(this);
return;
}
}
for (int var6 = 0; var6 < 32; ++var6) {
this.world.spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian(), new int[0]);
}
if (!this.world.isRemote) {
if (entitylivingbase instanceof EntityPlayerMP) {
EntityPlayerMP var7 = (EntityPlayerMP) entitylivingbase;
if (var7.connection.getNetworkManager().isChannelOpen() && var7.world == this.world && !var7.isPlayerSleeping()) {
EnderTeleportEvent var8 = new EnderTeleportEvent(var7, this.posX, this.posY, this.posZ, 5.0F);
if (!MinecraftForge.EVENT_BUS.post(var8)) {
if (this.rand.nextFloat() < 0.05F && this.world.getGameRules().getBoolean("doMobSpawning")) {
EntityEndermite entityendermite = new EntityEndermite(this.world);
entityendermite.setSpawnedByPlayer(true);
entityendermite.setLocationAndAngles(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, entitylivingbase.rotationYaw, entitylivingbase.rotationPitch);
this.world.spawnEntity(entityendermite);
}
if (entitylivingbase.isRiding()) {
this.dismountRidingEntity();
}
entitylivingbase.setPositionAndUpdate(var8.getTargetX(), var8.getTargetY(), var8.getTargetZ());
entitylivingbase.fallDistance = 0.0F;
}
}
} else if (entitylivingbase != null) {
entitylivingbase.setPositionAndUpdate(this.posX, this.posY, this.posZ);
entitylivingbase.fallDistance = 0.0F;
}
this.setDead();
}
}
use of net.minecraft.entity.EntityLivingBase in project Pearcel-Mod by MiningMark48.
the class BlockPearcelSpike method onEntityWalk.
@Override
public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn) {
if (entityIn instanceof EntityLivingBase) {
if (fakePlayer == null) {
if (!worldIn.isRemote) {
fakePlayer = FakePlayerFactory.get((WorldServer) worldIn, new GameProfile(UUID.randomUUID(), ModBlocks.pearcel_spike.getLocalizedName()));
}
}
if (!(entityIn instanceof EntityPlayer)) {
((EntityLivingBase) entityIn).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 20, 1));
entityIn.attackEntityFrom(DamageSource.causePlayerDamage(fakePlayer), spike_damage);
}
}
super.onEntityWalk(worldIn, pos, entityIn);
}
use of net.minecraft.entity.EntityLivingBase in project ArsMagica2 by Mithion.
the class AffinityHelper method onEntityFall.
@SubscribeEvent
public void onEntityFall(LivingFallEvent event) {
EntityLivingBase ent = event.entityLiving;
if (!(ent instanceof EntityPlayer))
return;
AffinityData affinityData = AffinityData.For(ent);
float earthDepth = affinityData.getAffinityDepth(Affinity.EARTH);
if (earthDepth > 0.25f) {
event.distance += 1.25 * (earthDepth);
}
float airDepth = affinityData.getAffinityDepth(Affinity.AIR);
if (airDepth >= 0.5f) {
event.distance -= 2 * (airDepth);
if (event.distance < 0)
event.distance = 0;
}
}
use of net.minecraft.entity.EntityLivingBase 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.EntityLivingBase 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);
}
}
}
Aggregations