Run formatter

This commit is contained in:
Nicholas Ignoffo 2017-08-15 21:30:48 -07:00
parent 61c44a831b
commit 08258fd6ef
606 changed files with 13464 additions and 22975 deletions

View file

@ -1,5 +1,9 @@
package WayofTime.bloodmagic.entity.mob;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.gson.Serializers;
import com.google.common.base.Predicate;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.nbt.NBTTagCompound;
@ -8,161 +12,139 @@ import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.gson.Serializers;
import com.google.common.base.Predicate;
import java.util.Locale;
public abstract class EntityAspectedDemonBase extends EntityDemonBase
{
public abstract class EntityAspectedDemonBase extends EntityDemonBase {
protected static final DataParameter<EnumDemonWillType> TYPE = EntityDataManager.<EnumDemonWillType>createKey(EntityAspectedDemonBase.class, Serializers.WILL_TYPE_SERIALIZER);
public EntityAspectedDemonBase(World worldIn)
{
public EntityAspectedDemonBase(World worldIn) {
super(worldIn);
}
@Override
protected void entityInit()
{
protected void entityInit() {
super.entityInit();
this.dataManager.register(TYPE, EnumDemonWillType.DEFAULT);
}
public double getMeleeResist()
{
public double getMeleeResist() {
return 0;
}
public double getProjectileResist()
{
public double getProjectileResist() {
return 0;
}
public double getMagicResist()
{
public double getMagicResist() {
return 0;
}
public double getBaseHP(EnumDemonWillType type)
{
public double getBaseHP(EnumDemonWillType type) {
double baseHP = 40;
switch (type)
{
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
baseHP *= 0.8;
break;
case STEADFAST:
baseHP *= 1.25;
break;
switch (type) {
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
baseHP *= 0.8;
break;
case STEADFAST:
baseHP *= 1.25;
break;
}
return baseHP;
}
public double getBaseMeleeDamage(EnumDemonWillType type)
{
public double getBaseMeleeDamage(EnumDemonWillType type) {
double baseDamage = 8;
switch (type)
{
case DEFAULT:
break;
case CORROSIVE:
baseDamage *= 0.8;
break;
case DESTRUCTIVE:
baseDamage *= 1.5;
break;
case VENGEFUL:
baseDamage *= 0.8;
break;
case STEADFAST:
baseDamage *= 0.6;
break;
switch (type) {
case DEFAULT:
break;
case CORROSIVE:
baseDamage *= 0.8;
break;
case DESTRUCTIVE:
baseDamage *= 1.5;
break;
case VENGEFUL:
baseDamage *= 0.8;
break;
case STEADFAST:
baseDamage *= 0.6;
break;
}
return baseDamage;
}
public double getBaseSpeed(EnumDemonWillType type)
{
public double getBaseSpeed(EnumDemonWillType type) {
double baseSpeed = 0.27;
switch (type)
{
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
baseSpeed *= 1.3;
break;
case STEADFAST:
break;
switch (type) {
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
baseSpeed *= 1.3;
break;
case STEADFAST:
break;
}
return baseSpeed;
}
public double getBaseSprintModifier(EnumDemonWillType type)
{
public double getBaseSprintModifier(EnumDemonWillType type) {
double baseSprint = 1;
switch (type)
{
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
baseSprint *= 1.2;
break;
case STEADFAST:
break;
switch (type) {
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
baseSprint *= 1.2;
break;
case STEADFAST:
break;
}
return baseSprint;
}
public double getBaseKnockbackResist(EnumDemonWillType type)
{
public double getBaseKnockbackResist(EnumDemonWillType type) {
double baseKnockback = 0;
switch (type)
{
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
break;
case STEADFAST:
baseKnockback += 0.35;
break;
switch (type) {
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
break;
case STEADFAST:
baseKnockback += 0.35;
break;
}
return baseKnockback;
}
public void applyEntityAttributes(EnumDemonWillType type)
{
public void applyEntityAttributes(EnumDemonWillType type) {
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(this.getBaseHP(type));
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(this.getBaseSpeed(type));
this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(this.getBaseMeleeDamage(type));
@ -170,24 +152,18 @@ public abstract class EntityAspectedDemonBase extends EntityDemonBase
}
@Override
public boolean attackEntityFrom(DamageSource source, float amount)
{
if (this.isEntityInvulnerable(source))
{
public boolean attackEntityFrom(DamageSource source, float amount) {
if (this.isEntityInvulnerable(source)) {
return false;
} else
{
} else {
float newAmount = amount;
if (source.isProjectile())
{
if (source.isProjectile()) {
newAmount *= MathHelper.clamp(1 - getProjectileResist(), 0, 1);
} else
{
} else {
newAmount *= MathHelper.clamp(1 - getMeleeResist(), 0, 1);
}
if (source.isMagicDamage())
{
if (source.isMagicDamage()) {
newAmount *= MathHelper.clamp(1 - getMagicResist(), 0, 1);
}
@ -195,83 +171,47 @@ public abstract class EntityAspectedDemonBase extends EntityDemonBase
}
}
public EnumDemonWillType getType()
{
public EnumDemonWillType getType() {
return this.dataManager.get(TYPE);
}
public void setType(EnumDemonWillType type)
{
public void setType(EnumDemonWillType type) {
this.dataManager.set(TYPE, type);
this.applyEntityAttributes(type);
this.setCombatTask();
}
@Override
public void writeEntityToNBT(NBTTagCompound tag)
{
public void writeEntityToNBT(NBTTagCompound tag) {
super.writeEntityToNBT(tag);
tag.setString(Constants.NBT.WILL_TYPE, this.getType().toString());
}
@Override
public void readEntityFromNBT(NBTTagCompound tag)
{
public void readEntityFromNBT(NBTTagCompound tag) {
super.readEntityFromNBT(tag);
if (!tag.hasKey(Constants.NBT.WILL_TYPE))
{
if (!tag.hasKey(Constants.NBT.WILL_TYPE)) {
setType(EnumDemonWillType.DEFAULT);
} else
{
} else {
setType(EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH)));
}
}
public class TeamAttackPredicate implements Predicate<EntityLivingBase>
{
private final EntityAspectedDemonBase demon;
public TeamAttackPredicate(EntityAspectedDemonBase demon)
{
this.demon = demon;
}
//Returns true if this mob can attack the inputted mob.
@Override
public boolean apply(EntityLivingBase input)
{
if (input instanceof EntityAspectedDemonBase)
{
if (((EntityAspectedDemonBase) input).getType() == demon.getType())
{
return false;
}
}
return input != null;
}
}
//Returns true if the inputted mob is on the same team.
public static class WillTypePredicate implements Predicate<EntityLivingBase>
{
public static class WillTypePredicate implements Predicate<EntityLivingBase> {
private final EnumDemonWillType type;
public WillTypePredicate(EnumDemonWillType type)
{
public WillTypePredicate(EnumDemonWillType type) {
this.type = type;
}
//Returns true if this mob is the same type.
@Override
public boolean apply(EntityLivingBase input)
{
if (input instanceof EntityAspectedDemonBase)
{
if (((EntityAspectedDemonBase) input).getType() == type)
{
public boolean apply(EntityLivingBase input) {
if (input instanceof EntityAspectedDemonBase) {
if (((EntityAspectedDemonBase) input).getType() == type) {
return true;
}
}
@ -279,4 +219,24 @@ public abstract class EntityAspectedDemonBase extends EntityDemonBase
return false;
}
}
public class TeamAttackPredicate implements Predicate<EntityLivingBase> {
private final EntityAspectedDemonBase demon;
public TeamAttackPredicate(EntityAspectedDemonBase demon) {
this.demon = demon;
}
//Returns true if this mob can attack the inputted mob.
@Override
public boolean apply(EntityLivingBase input) {
if (input instanceof EntityAspectedDemonBase) {
if (((EntityAspectedDemonBase) input).getType() == demon.getType()) {
return false;
}
}
return input != null;
}
}
}

View file

@ -1,13 +1,13 @@
package WayofTime.bloodmagic.entity.mob;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.entity.ai.EntityAIAttackStealthMelee;
import WayofTime.bloodmagic.entity.ai.EntityAIStealthRetreat;
import WayofTime.bloodmagic.entity.ai.EntityAIStealthTowardsTarget;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
@ -19,24 +19,18 @@ import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.entity.ai.EntityAIAttackStealthMelee;
import WayofTime.bloodmagic.entity.ai.EntityAIStealthRetreat;
import WayofTime.bloodmagic.entity.ai.EntityAIStealthTowardsTarget;
public class EntityCorruptedChicken extends EntityAspectedDemonBase
{
private EntityAIAttackStealthMelee aiAttackOnCollide;
public class EntityCorruptedChicken extends EntityAspectedDemonBase {
private final int attackPriority = 3;
public float wingRotation;
public float destPos;
public float oFlapSpeed;
public float oFlap;
public float wingRotDelta = 1.0F;
/** The time until the next egg is spawned. */
/**
* The time until the next egg is spawned.
*/
public int timeUntilNextEgg;
/*
* 0 means the chicken is casting stealth on itself when targeted, running
* to a random location near the target. 1 means the chicken is running
@ -45,14 +39,13 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
* state 0.
*/
public int attackStateMachine = 0;
private EntityAIAttackStealthMelee aiAttackOnCollide;
public EntityCorruptedChicken(World world)
{
public EntityCorruptedChicken(World world) {
this(world, EnumDemonWillType.DEFAULT);
}
public EntityCorruptedChicken(World world, EnumDemonWillType type)
{
public EntityCorruptedChicken(World world, EnumDemonWillType type) {
super(world);
this.setSize(0.4F, 0.7F);
this.timeUntilNextEgg = this.rand.nextInt(600) + 600;
@ -61,8 +54,7 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
this.setType(type);
}
protected void initEntityAI()
{
protected void initEntityAI() {
this.tasks.addTask(0, new EntityAISwimming(this));
// this.tasks.addTask(1, new EntityAIPanic(this, 1.4D));
this.tasks.addTask(attackPriority, new EntityAIStealthTowardsTarget(this, 1));
@ -76,10 +68,8 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
}
@Override
public void setCombatTask()
{
if (aiAttackOnCollide != null)
{
public void setCombatTask() {
if (aiAttackOnCollide != null) {
this.tasks.removeTask(aiAttackOnCollide);
}
@ -87,50 +77,42 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
this.tasks.addTask(attackPriority, aiAttackOnCollide);
}
public void cloak()
{
public void cloak() {
this.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 50, 0, false, false));
}
@Override
public double getBaseHP(EnumDemonWillType type)
{
public double getBaseHP(EnumDemonWillType type) {
return super.getBaseHP(type) * 0.5;
}
@Override
public double getBaseMeleeDamage(EnumDemonWillType type)
{
public double getBaseMeleeDamage(EnumDemonWillType type) {
return super.getBaseMeleeDamage(type) * 2.5;
}
@Override
public double getBaseSpeed(EnumDemonWillType type)
{
public double getBaseSpeed(EnumDemonWillType type) {
return super.getBaseSpeed(type);
}
@Override
public double getBaseSprintModifier(EnumDemonWillType type)
{
public double getBaseSprintModifier(EnumDemonWillType type) {
return super.getBaseSprintModifier(type);
}
@Override
public double getBaseKnockbackResist(EnumDemonWillType type)
{
public double getBaseKnockbackResist(EnumDemonWillType type) {
return super.getBaseKnockbackResist(type);
}
@Override
public float getEyeHeight()
{
public float getEyeHeight() {
return this.height;
}
@Override
public void onLivingUpdate()
{
public void onLivingUpdate() {
super.onLivingUpdate();
// if (!worldObj.isRemote)
@ -141,22 +123,19 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
this.destPos = (float) ((double) this.destPos + (double) (this.onGround ? -1 : 4) * 0.3D);
this.destPos = MathHelper.clamp(this.destPos, 0.0F, 1.0F);
if (!this.onGround && this.wingRotDelta < 1.0F)
{
if (!this.onGround && this.wingRotDelta < 1.0F) {
this.wingRotDelta = 1.0F;
}
this.wingRotDelta = (float) ((double) this.wingRotDelta * 0.9D);
if (!this.onGround && this.motionY < 0.0D)
{
if (!this.onGround && this.motionY < 0.0D) {
this.motionY *= 0.6D;
}
this.wingRotation += this.wingRotDelta * 2.0F;
if (!this.getEntityWorld().isRemote && !this.isChild() && --this.timeUntilNextEgg <= 0)
{
if (!this.getEntityWorld().isRemote && !this.isChild() && --this.timeUntilNextEgg <= 0) {
this.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
this.dropItem(Items.EGG, 1);
this.timeUntilNextEgg = this.rand.nextInt(600) + 600;
@ -164,61 +143,51 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
}
@Override
public void fall(float distance, float damageMultiplier)
{
public void fall(float distance, float damageMultiplier) {
}
@Override
protected SoundEvent getAmbientSound()
{
protected SoundEvent getAmbientSound() {
return SoundEvents.ENTITY_CHICKEN_AMBIENT;
}
@Override
protected SoundEvent getHurtSound()
{
protected SoundEvent getHurtSound() {
return SoundEvents.ENTITY_CHICKEN_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
protected SoundEvent getDeathSound() {
return SoundEvents.ENTITY_CHICKEN_DEATH;
}
@Override
protected float getSoundPitch()
{
protected float getSoundPitch() {
return super.getSoundPitch() * 0.5f;
}
@Override
protected void playStepSound(BlockPos pos, Block blockIn)
{
protected void playStepSound(BlockPos pos, Block blockIn) {
this.playSound(SoundEvents.ENTITY_CHICKEN_STEP, 0.15F, 1.0F);
}
@Override
public void readEntityFromNBT(NBTTagCompound compound)
{
public void readEntityFromNBT(NBTTagCompound compound) {
super.readEntityFromNBT(compound);
if (compound.hasKey("EggLayTime"))
{
if (compound.hasKey("EggLayTime")) {
this.timeUntilNextEgg = compound.getInteger("EggLayTime");
}
}
@Override
public void writeEntityToNBT(NBTTagCompound compound)
{
public void writeEntityToNBT(NBTTagCompound compound) {
super.writeEntityToNBT(compound);
compound.setInteger("EggLayTime", this.timeUntilNextEgg);
}
@Override
public void updatePassenger(Entity passenger)
{
public void updatePassenger(Entity passenger) {
super.updatePassenger(passenger);
float f = MathHelper.sin(this.renderYawOffset * 0.017453292F);
float f1 = MathHelper.cos(this.renderYawOffset * 0.017453292F);
@ -226,8 +195,7 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
float f3 = 0.0F;
passenger.setPosition(this.posX + (double) (0.1F * f), this.posY + (double) (this.height * 0.5F) + passenger.getYOffset() + 0.0D, this.posZ - (double) (0.1F * f1));
if (passenger instanceof EntityLivingBase)
{
if (passenger instanceof EntityLivingBase) {
((EntityLivingBase) passenger).renderYawOffset = this.renderYawOffset;
}
}

View file

@ -1,20 +1,13 @@
package WayofTime.bloodmagic.entity.mob;
import java.util.List;
import java.util.Map;
import java.util.Random;
import javax.annotation.Nullable;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.entity.ai.EntityAIEatAndCorruptBlock;
import WayofTime.bloodmagic.entity.ai.EntityAIProtectAlly;
import com.google.common.collect.Maps;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.MobEffects;
@ -35,53 +28,61 @@ import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.entity.ai.EntityAIEatAndCorruptBlock;
import WayofTime.bloodmagic.entity.ai.EntityAIProtectAlly;
import com.google.common.collect.Maps;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class EntityCorruptedSheep extends EntityAspectedDemonBase implements IShearable
{
public class EntityCorruptedSheep extends EntityAspectedDemonBase implements IShearable {
private static final DataParameter<Byte> DYE_COLOR = EntityDataManager.<Byte>createKey(EntityCorruptedSheep.class, DataSerializers.BYTE);
private static final Map<EnumDyeColor, float[]> DYE_TO_RGB = Maps.newEnumMap(EnumDyeColor.class);
public static int maxProtectionCooldown = 90 * 20; //90 second cooldown
static {
DYE_TO_RGB.put(EnumDyeColor.WHITE, new float[]{1.0F, 1.0F, 1.0F});
DYE_TO_RGB.put(EnumDyeColor.ORANGE, new float[]{0.85F, 0.5F, 0.2F});
DYE_TO_RGB.put(EnumDyeColor.MAGENTA, new float[]{0.7F, 0.3F, 0.85F});
DYE_TO_RGB.put(EnumDyeColor.LIGHT_BLUE, new float[]{0.4F, 0.6F, 0.85F});
DYE_TO_RGB.put(EnumDyeColor.YELLOW, new float[]{0.9F, 0.9F, 0.2F});
DYE_TO_RGB.put(EnumDyeColor.LIME, new float[]{0.5F, 0.8F, 0.1F});
DYE_TO_RGB.put(EnumDyeColor.PINK, new float[]{0.95F, 0.5F, 0.65F});
DYE_TO_RGB.put(EnumDyeColor.GRAY, new float[]{0.3F, 0.3F, 0.3F});
DYE_TO_RGB.put(EnumDyeColor.SILVER, new float[]{0.6F, 0.6F, 0.6F});
DYE_TO_RGB.put(EnumDyeColor.CYAN, new float[]{0.3F, 0.5F, 0.6F});
DYE_TO_RGB.put(EnumDyeColor.PURPLE, new float[]{0.5F, 0.25F, 0.7F});
DYE_TO_RGB.put(EnumDyeColor.BLUE, new float[]{0.2F, 0.3F, 0.7F});
DYE_TO_RGB.put(EnumDyeColor.BROWN, new float[]{0.4F, 0.3F, 0.2F});
DYE_TO_RGB.put(EnumDyeColor.GREEN, new float[]{0.4F, 0.5F, 0.2F});
DYE_TO_RGB.put(EnumDyeColor.RED, new float[]{0.6F, 0.2F, 0.2F});
DYE_TO_RGB.put(EnumDyeColor.BLACK, new float[]{0.1F, 0.1F, 0.1F});
}
private final int attackPriority = 3;
public int protectionCooldown = 0;
/**
* Used to control movement as well as wool regrowth. Set to 40 on
* handleHealthUpdate and counts down with each tick.
*/
private int sheepTimer;
private int castTimer = 0;
private EntityAIEatAndCorruptBlock entityAIEatGrass;
private EntityAIProtectAlly entityAIProtectAlly;
private EntityAIAttackMelee aiAttackOnCollide;
private final int attackPriority = 3;
public int protectionCooldown = 0;
public static int maxProtectionCooldown = 90 * 20; //90 second cooldown
public static float[] getDyeRgb(EnumDyeColor dyeColor)
{
return DYE_TO_RGB.get(dyeColor);
}
public EntityCorruptedSheep(World world)
{
public EntityCorruptedSheep(World world) {
this(world, EnumDemonWillType.DEFAULT);
}
public EntityCorruptedSheep(World world, EnumDemonWillType type)
{
public EntityCorruptedSheep(World world, EnumDemonWillType type) {
super(world);
this.setSize(0.9F, 1.3F);
this.setType(type);
}
protected void initEntityAI()
{
protected void initEntityAI() {
this.entityAIEatGrass = new EntityAIEatAndCorruptBlock(this);
this.entityAIProtectAlly = new EntityAIProtectAlly(this);
@ -97,10 +98,8 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
}
@Override
public void setCombatTask()
{
if (aiAttackOnCollide != null)
{
public void setCombatTask() {
if (aiAttackOnCollide != null) {
this.tasks.removeTask(aiAttackOnCollide);
}
@ -109,22 +108,18 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
}
@Override
protected void updateAITasks()
{
protected void updateAITasks() {
this.sheepTimer = this.entityAIEatGrass.getEatingGrassTimer();
this.castTimer = this.entityAIProtectAlly.getCastTimer();
super.updateAITasks();
}
@Override
public void onLivingUpdate()
{
if (this.getEntityWorld().isRemote)
{
public void onLivingUpdate() {
if (this.getEntityWorld().isRemote) {
this.sheepTimer = Math.max(0, this.sheepTimer - 1);
this.castTimer = Math.max(0, castTimer - 1);
if (this.castTimer == 70)
{
if (this.castTimer == 70) {
this.playSound(this.getHurtSound(), this.getSoundVolume() * 2, this.getSoundPitch());
}
}
@ -134,15 +129,12 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
super.onLivingUpdate();
}
public boolean canProtectAlly(EntityLivingBase entity)
{
public boolean canProtectAlly(EntityLivingBase entity) {
return this.protectionCooldown <= 0 && entity.getHealth() < entity.getMaxHealth() && !entity.isPotionActive(MobEffects.RESISTANCE);
}
public boolean applyProtectionToAlly(EntityLivingBase entity)
{
if (canProtectAlly(entity))
{
public boolean applyProtectionToAlly(EntityLivingBase entity) {
if (canProtectAlly(entity)) {
entity.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 20 * 20, 3));
this.protectionCooldown = maxProtectionCooldown;
}
@ -151,92 +143,75 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
}
@Override
public double getBaseHP(EnumDemonWillType type)
{
public double getBaseHP(EnumDemonWillType type) {
return super.getBaseHP(type) * 0.75;
}
@Override
public double getBaseMeleeDamage(EnumDemonWillType type)
{
public double getBaseMeleeDamage(EnumDemonWillType type) {
return super.getBaseMeleeDamage(type) * 0.75;
}
@Override
public double getBaseSpeed(EnumDemonWillType type)
{
public double getBaseSpeed(EnumDemonWillType type) {
return super.getBaseSpeed(type);
}
@Override
public double getBaseSprintModifier(EnumDemonWillType type)
{
public double getBaseSprintModifier(EnumDemonWillType type) {
return super.getBaseSprintModifier(type);
}
@Override
public double getBaseKnockbackResist(EnumDemonWillType type)
{
public double getBaseKnockbackResist(EnumDemonWillType type) {
return super.getBaseKnockbackResist(type) + 0.2;
}
@Override
public double getMeleeResist()
{
public double getMeleeResist() {
return 0.2;
}
@Override
public double getProjectileResist()
{
public double getProjectileResist() {
return 0.6;
}
@Override
protected void entityInit()
{
protected void entityInit() {
super.entityInit();
this.dataManager.register(DYE_COLOR, Byte.valueOf((byte) 0));
}
@Override
@SideOnly(Side.CLIENT)
public void handleStatusUpdate(byte id)
{
if (id == 10)
{
public void handleStatusUpdate(byte id) {
if (id == 10) {
this.sheepTimer = 40;
} else if (id == 53)
{
} else if (id == 53) {
this.castTimer = 100;
} else
{
} else {
super.handleStatusUpdate(id);
}
}
@SideOnly(Side.CLIENT)
public float getHeadRotationPointY(float partialTick)
{
public float getHeadRotationPointY(float partialTick) {
return this.sheepTimer <= 0 ? 0.0F : (this.sheepTimer >= 4 && this.sheepTimer <= 36 ? 1.0F : (this.sheepTimer < 4 ? ((float) this.sheepTimer - partialTick) / 4.0F : -((float) (this.sheepTimer - 40) - partialTick) / 4.0F));
}
@SideOnly(Side.CLIENT)
public float getHeadRotationAngleX(float partialTick)
{
if (this.sheepTimer > 4 && this.sheepTimer <= 36)
{
public float getHeadRotationAngleX(float partialTick) {
if (this.sheepTimer > 4 && this.sheepTimer <= 36) {
float f = ((float) (this.sheepTimer - 4) - partialTick) / 32.0F;
return ((float) Math.PI / 5F) + ((float) Math.PI * 7F / 100F) * MathHelper.sin(f * 28.7F);
} else
{
} else {
return this.sheepTimer > 0 ? ((float) Math.PI / 5F) : this.rotationPitch * 0.017453292F;
}
}
@Override
public void writeEntityToNBT(NBTTagCompound tag)
{
public void writeEntityToNBT(NBTTagCompound tag) {
super.writeEntityToNBT(tag);
tag.setBoolean("Sheared", this.getSheared());
tag.setByte("Color", (byte) this.getFleeceColor().getMetadata());
@ -244,8 +219,7 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
}
@Override
public void readEntityFromNBT(NBTTagCompound tag)
{
public void readEntityFromNBT(NBTTagCompound tag) {
super.readEntityFromNBT(tag);
this.setSheared(tag.getBoolean("Sheared"));
this.setFleeceColor(EnumDyeColor.byMetadata(tag.getByte("Color")));
@ -253,48 +227,41 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
}
@Override
protected SoundEvent getAmbientSound()
{
protected SoundEvent getAmbientSound() {
return SoundEvents.ENTITY_SHEEP_AMBIENT;
}
@Override
protected SoundEvent getHurtSound()
{
protected SoundEvent getHurtSound() {
return SoundEvents.ENTITY_SHEEP_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
protected SoundEvent getDeathSound() {
return SoundEvents.ENTITY_SHEEP_DEATH;
}
@Override
protected float getSoundPitch()
{
protected float getSoundPitch() {
return super.getSoundPitch() * 0.5f;
}
@Override
protected void playStepSound(BlockPos pos, Block blockIn)
{
protected void playStepSound(BlockPos pos, Block blockIn) {
this.playSound(SoundEvents.ENTITY_SHEEP_STEP, 0.15F, 1.0F);
}
/**
* Gets the wool color of this sheep.
*/
public EnumDyeColor getFleeceColor()
{
public EnumDyeColor getFleeceColor() {
return EnumDyeColor.byMetadata(this.dataManager.get(DYE_COLOR).byteValue() & 15);
}
/**
* Sets the wool color of this sheep
*/
public void setFleeceColor(EnumDyeColor color)
{
public void setFleeceColor(EnumDyeColor color) {
byte b0 = this.dataManager.get(DYE_COLOR).byteValue();
this.dataManager.set(DYE_COLOR, Byte.valueOf((byte) (b0 & 240 | color.getMetadata() & 15)));
}
@ -302,48 +269,33 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
/**
* returns true if a sheeps wool has been sheared
*/
public boolean getSheared()
{
public boolean getSheared() {
return (this.dataManager.get(DYE_COLOR).byteValue() & 16) != 0;
}
/**
* make a sheep sheared if set to true
*/
public void setSheared(boolean sheared)
{
public void setSheared(boolean sheared) {
byte b0 = this.dataManager.get(DYE_COLOR).byteValue();
if (sheared)
{
if (sheared) {
this.dataManager.set(DYE_COLOR, Byte.valueOf((byte) (b0 | 16)));
} else
{
} else {
this.dataManager.set(DYE_COLOR, Byte.valueOf((byte) (b0 & -17)));
}
}
/**
* Chooses a "vanilla" sheep color based on the provided random.
*/
public static EnumDyeColor getRandomSheepColor(Random random)
{
int i = random.nextInt(100);
return i < 5 ? EnumDyeColor.BLACK : (i < 10 ? EnumDyeColor.GRAY : (i < 15 ? EnumDyeColor.SILVER : (i < 18 ? EnumDyeColor.BROWN : (random.nextInt(500) == 0 ? EnumDyeColor.PINK : EnumDyeColor.WHITE))));
}
/**
* This function applies the benefits of growing back wool and faster
* growing up to the acting entity. (This function is used in the
* AIEatGrass)
*/
@Override
public void eatGrassBonus()
{
public void eatGrassBonus() {
this.setSheared(false);
if (this.isChild())
{
if (this.isChild()) {
this.heal(3);
}
}
@ -354,48 +306,24 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
* from nbt. Mainly used for initializing attributes and inventory
*/
@Override
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata)
{
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) {
livingdata = super.onInitialSpawn(difficulty, livingdata);
this.setFleeceColor(getRandomSheepColor(this.getEntityWorld().rand));
return livingdata;
}
@Override
public float getEyeHeight()
{
public float getEyeHeight() {
return 0.95F * this.height;
}
static
{
DYE_TO_RGB.put(EnumDyeColor.WHITE, new float[] { 1.0F, 1.0F, 1.0F });
DYE_TO_RGB.put(EnumDyeColor.ORANGE, new float[] { 0.85F, 0.5F, 0.2F });
DYE_TO_RGB.put(EnumDyeColor.MAGENTA, new float[] { 0.7F, 0.3F, 0.85F });
DYE_TO_RGB.put(EnumDyeColor.LIGHT_BLUE, new float[] { 0.4F, 0.6F, 0.85F });
DYE_TO_RGB.put(EnumDyeColor.YELLOW, new float[] { 0.9F, 0.9F, 0.2F });
DYE_TO_RGB.put(EnumDyeColor.LIME, new float[] { 0.5F, 0.8F, 0.1F });
DYE_TO_RGB.put(EnumDyeColor.PINK, new float[] { 0.95F, 0.5F, 0.65F });
DYE_TO_RGB.put(EnumDyeColor.GRAY, new float[] { 0.3F, 0.3F, 0.3F });
DYE_TO_RGB.put(EnumDyeColor.SILVER, new float[] { 0.6F, 0.6F, 0.6F });
DYE_TO_RGB.put(EnumDyeColor.CYAN, new float[] { 0.3F, 0.5F, 0.6F });
DYE_TO_RGB.put(EnumDyeColor.PURPLE, new float[] { 0.5F, 0.25F, 0.7F });
DYE_TO_RGB.put(EnumDyeColor.BLUE, new float[] { 0.2F, 0.3F, 0.7F });
DYE_TO_RGB.put(EnumDyeColor.BROWN, new float[] { 0.4F, 0.3F, 0.2F });
DYE_TO_RGB.put(EnumDyeColor.GREEN, new float[] { 0.4F, 0.5F, 0.2F });
DYE_TO_RGB.put(EnumDyeColor.RED, new float[] { 0.6F, 0.2F, 0.2F });
DYE_TO_RGB.put(EnumDyeColor.BLACK, new float[] { 0.1F, 0.1F, 0.1F });
}
@Override
public boolean isShearable(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos)
{
public boolean isShearable(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos) {
return !this.getSheared() && !this.isChild();
}
@Override
public List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune)
{
public List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) {
this.setSheared(true);
int i = 1 + this.rand.nextInt(3);
@ -410,4 +338,16 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
public int getCastTimer() {
return castTimer;
}
public static float[] getDyeRgb(EnumDyeColor dyeColor) {
return DYE_TO_RGB.get(dyeColor);
}
/**
* Chooses a "vanilla" sheep color based on the provided random.
*/
public static EnumDyeColor getRandomSheepColor(Random random) {
int i = random.nextInt(100);
return i < 5 ? EnumDyeColor.BLACK : (i < 10 ? EnumDyeColor.GRAY : (i < 15 ? EnumDyeColor.SILVER : (i < 18 ? EnumDyeColor.BROWN : (random.nextInt(500) == 0 ? EnumDyeColor.PINK : EnumDyeColor.WHITE))));
}
}

View file

@ -1,16 +1,11 @@
package WayofTime.bloodmagic.entity.mob;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.entity.ai.EntityAIPickUpAlly;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILeapAtTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
@ -23,28 +18,22 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.entity.ai.EntityAIPickUpAlly;
public class EntityCorruptedSpider extends EntityAspectedDemonBase
{
public class EntityCorruptedSpider extends EntityAspectedDemonBase {
private static final DataParameter<Byte> CLIMBING = EntityDataManager.<Byte>createKey(EntityCorruptedSpider.class, DataSerializers.BYTE);
public EntityCorruptedSpider(World world)
{
public EntityCorruptedSpider(World world) {
this(world, EnumDemonWillType.DEFAULT);
}
public EntityCorruptedSpider(World world, EnumDemonWillType type)
{
public EntityCorruptedSpider(World world, EnumDemonWillType type) {
super(world);
this.setSize(1.4F, 0.9F);
this.setType(type);
}
protected void initEntityAI()
{
protected void initEntityAI() {
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
this.tasks.addTask(3, new EntityAIPickUpAlly(this, 1, true));
@ -59,132 +48,109 @@ public class EntityCorruptedSpider extends EntityAspectedDemonBase
}
@Override
public double getBaseHP(EnumDemonWillType type)
{
public double getBaseHP(EnumDemonWillType type) {
return super.getBaseHP(type);
}
@Override
public double getBaseMeleeDamage(EnumDemonWillType type)
{
public double getBaseMeleeDamage(EnumDemonWillType type) {
return super.getBaseMeleeDamage(type);
}
@Override
public double getBaseSpeed(EnumDemonWillType type)
{
public double getBaseSpeed(EnumDemonWillType type) {
return super.getBaseSpeed(type);
}
@Override
public double getBaseSprintModifier(EnumDemonWillType type)
{
public double getBaseSprintModifier(EnumDemonWillType type) {
return super.getBaseSprintModifier(type);
}
@Override
public double getBaseKnockbackResist(EnumDemonWillType type)
{
public double getBaseKnockbackResist(EnumDemonWillType type) {
return super.getBaseKnockbackResist(type);
}
@Override
public double getMountedYOffset()
{
public double getMountedYOffset() {
return (double) (this.height * 0.5F);
}
@Override
protected PathNavigate createNavigator(World worldIn)
{
protected PathNavigate createNavigator(World worldIn) {
return new PathNavigateClimber(this, worldIn);
}
@Override
protected void entityInit()
{
protected void entityInit() {
super.entityInit();
this.dataManager.register(CLIMBING, (byte) 0);
}
@Override
public void onUpdate()
{
public void onUpdate() {
super.onUpdate();
if (!this.getEntityWorld().isRemote)
{
if (!this.getEntityWorld().isRemote) {
this.setBesideClimbableBlock(this.isCollidedHorizontally);
}
}
@Override
protected SoundEvent getAmbientSound()
{
protected SoundEvent getAmbientSound() {
return SoundEvents.ENTITY_SPIDER_AMBIENT;
}
@Override
protected SoundEvent getHurtSound()
{
protected SoundEvent getHurtSound() {
return SoundEvents.ENTITY_SPIDER_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
protected SoundEvent getDeathSound() {
return SoundEvents.ENTITY_SPIDER_DEATH;
}
@Override
protected float getSoundPitch()
{
protected float getSoundPitch() {
return super.getSoundPitch() * 0.5f;
}
@Override
protected void playStepSound(BlockPos pos, Block blockIn)
{
protected void playStepSound(BlockPos pos, Block blockIn) {
this.playSound(SoundEvents.ENTITY_SPIDER_STEP, 0.15F, 1.0F);
}
@Override
public boolean isOnLadder()
{
public boolean isOnLadder() {
return this.isBesideClimbableBlock();
}
@Override
public void setInWeb()
{
public void setInWeb() {
}
@Override
public EnumCreatureAttribute getCreatureAttribute()
{
public EnumCreatureAttribute getCreatureAttribute() {
return EnumCreatureAttribute.ARTHROPOD;
}
@Override
public boolean isPotionApplicable(PotionEffect potioneffectIn)
{
public boolean isPotionApplicable(PotionEffect potioneffectIn) {
return potioneffectIn.getPotion() != MobEffects.POISON && super.isPotionApplicable(potioneffectIn);
}
public boolean isBesideClimbableBlock()
{
public boolean isBesideClimbableBlock() {
return (this.dataManager.get(CLIMBING) & 1) != 0;
}
public void setBesideClimbableBlock(boolean climbing)
{
public void setBesideClimbableBlock(boolean climbing) {
byte b0 = this.dataManager.get(CLIMBING);
if (climbing)
{
if (climbing) {
b0 = (byte) (b0 | 1);
} else
{
} else {
b0 = (byte) (b0 & -2);
}
@ -192,53 +158,43 @@ public class EntityCorruptedSpider extends EntityAspectedDemonBase
}
@Override
public float getEyeHeight()
{
public float getEyeHeight() {
return 0.65F;
}
static class AISpiderAttack extends EntityAIAttackMelee
{
public AISpiderAttack(EntityCorruptedSpider spider)
{
static class AISpiderAttack extends EntityAIAttackMelee {
public AISpiderAttack(EntityCorruptedSpider spider) {
super(spider, 1.0D, true);
}
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean shouldContinueExecuting()
{
public boolean shouldContinueExecuting() {
float f = this.attacker.getBrightness();
if (f >= 0.5F && this.attacker.getRNG().nextInt(100) == 0)
{
if (f >= 0.5F && this.attacker.getRNG().nextInt(100) == 0) {
this.attacker.setAttackTarget(null);
return false;
} else
{
} else {
return super.shouldContinueExecuting();
}
}
protected double getAttackReachSqr(EntityLivingBase attackTarget)
{
protected double getAttackReachSqr(EntityLivingBase attackTarget) {
return (double) (4.0F + attackTarget.width);
}
}
static class AISpiderTarget<T extends EntityLivingBase> extends EntityAINearestAttackableTarget<T>
{
public AISpiderTarget(EntityCorruptedSpider spider, Class<T> classTarget)
{
static class AISpiderTarget<T extends EntityLivingBase> extends EntityAINearestAttackableTarget<T> {
public AISpiderTarget(EntityCorruptedSpider spider, Class<T> classTarget) {
super(spider, classTarget, true);
}
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
public boolean shouldExecute() {
float f = this.taskOwner.getBrightness();
return !(f >= 0.5F) && super.shouldExecute();
}

View file

@ -1,18 +1,12 @@
package WayofTime.bloodmagic.entity.mob;
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
import WayofTime.bloodmagic.entity.ai.EntityAIAttackRangedBow;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMoveThroughVillage;
import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.monster.EntityIronGolem;
@ -27,18 +21,14 @@ import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
import WayofTime.bloodmagic.entity.ai.EntityAIAttackRangedBow;
public class EntityCorruptedZombie extends EntityAspectedDemonBase
{
public class EntityCorruptedZombie extends EntityAspectedDemonBase {
private final EntityAIAttackRangedBow aiArrowAttack = new EntityAIAttackRangedBow(this, 1.0D, 20, 15.0F);
private final EntityAIAttackMelee aiAttackOnCollide = new EntityAIAttackMelee(this, 1.0D, false);
private final int attackPriority = 3;
public EntityCorruptedZombie(World worldIn)
{
public EntityCorruptedZombie(World worldIn) {
super(worldIn);
this.setSize(0.6F, 1.95F);
// ((PathNavigateGround) getNavigator()).setCanSwim(false);
@ -60,8 +50,7 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase
}
@Override
protected void applyEntityAttributes()
{
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(35.0D);
getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(40.0D);
@ -71,35 +60,29 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase
}
@Override
public void setCombatTask()
{
if (!this.getEntityWorld().isRemote)
{
public void setCombatTask() {
if (!this.getEntityWorld().isRemote) {
this.tasks.removeTask(this.aiAttackOnCollide);
this.tasks.removeTask(this.aiArrowAttack);
ItemStack itemstack = this.getHeldItemMainhand();
if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow)
{
if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow) {
int i = 20;
if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD)
{
if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD) {
i = 40;
}
this.aiArrowAttack.setAttackCooldown(i);
this.tasks.addTask(attackPriority, this.aiArrowAttack);
} else
{
} else {
this.tasks.addTask(attackPriority, this.aiAttackOnCollide);
}
}
}
@Override
public boolean attackEntityFrom(DamageSource source, float amount)
{
public boolean attackEntityFrom(DamageSource source, float amount) {
return !this.isEntityInvulnerable(source) && super.attackEntityFrom(source, amount);
}
@ -107,17 +90,14 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase
* Redone from EntityMob to prevent despawning on peaceful.
*/
@Override
public boolean attackEntityAsMob(Entity attackedEntity)
{
public boolean attackEntityAsMob(Entity attackedEntity) {
boolean flag = super.attackEntityAsMob(attackedEntity);
if (flag)
{
if (flag) {
//EMPTY
return true;
} else
{
} else {
return false;
}
}
@ -126,24 +106,20 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase
* @param toHeal
* @return Amount of Will consumed from the Aura to heal
*/
public double absorbWillFromAuraToHeal(double toHeal)
{
if (getEntityWorld().isRemote)
{
public double absorbWillFromAuraToHeal(double toHeal) {
if (getEntityWorld().isRemote) {
return 0;
}
double healthMissing = this.getMaxHealth() - this.getHealth();
if (healthMissing <= 0)
{
if (healthMissing <= 0) {
return 0;
}
double will = WorldDemonWillHandler.getCurrentWill(getEntityWorld(), getPosition(), getType());
toHeal = Math.min(healthMissing, Math.min(toHeal, will / getWillToHealth()));
if (toHeal > 0)
{
if (toHeal > 0) {
this.heal((float) toHeal);
return WorldDemonWillHandler.drainWill(getEntityWorld(), getPosition(), getType(), toHeal * getWillToHealth(), true);
}
@ -151,21 +127,17 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase
return 0;
}
public double getWillToHealth()
{
public double getWillToHealth() {
return 2;
}
@Override
protected boolean canDespawn()
{
protected boolean canDespawn() {
return !this.isTamed() && super.canDespawn();
}
public void onUpdate()
{
if (!this.getEntityWorld().isRemote && this.ticksExisted % 20 == 0)
{
public void onUpdate() {
if (!this.getEntityWorld().isRemote && this.ticksExisted % 20 == 0) {
absorbWillFromAuraToHeal(2);
}
@ -179,32 +151,27 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase
}
@Override
protected float getSoundPitch()
{
protected float getSoundPitch() {
return super.getSoundPitch() * 0.5f;
}
@Override
protected SoundEvent getAmbientSound()
{
protected SoundEvent getAmbientSound() {
return SoundEvents.ENTITY_ZOMBIE_AMBIENT;
}
@Override
protected SoundEvent getHurtSound()
{
protected SoundEvent getHurtSound() {
return SoundEvents.ENTITY_ZOMBIE_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
protected SoundEvent getDeathSound() {
return SoundEvents.ENTITY_ZOMBIE_DEATH;
}
@Override
protected void playStepSound(BlockPos pos, Block block)
{
protected void playStepSound(BlockPos pos, Block block) {
this.playSound(SoundEvents.ENTITY_ZOMBIE_STEP, 0.15F, 1.0F);
}
@ -212,8 +179,7 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase
* Returns the volume for the sounds this mob makes.
*/
@Override
protected float getSoundVolume()
{
protected float getSoundVolume() {
return 0.4F;
}
}

View file

@ -1,14 +1,10 @@
package WayofTime.bloodmagic.entity.mob;
import java.util.UUID;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import net.minecraft.block.Block;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityOwnable;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.monster.EntityMob;
@ -34,58 +30,48 @@ import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import javax.annotation.Nullable;
import java.util.UUID;
public class EntityDemonBase extends EntityCreature implements IEntityOwnable
{
public class EntityDemonBase extends EntityCreature implements IEntityOwnable {
protected static final DataParameter<Byte> TAMED = EntityDataManager.createKey(EntityDemonBase.class, DataSerializers.BYTE);
protected static final DataParameter<Optional<UUID>> OWNER_UNIQUE_ID = EntityDataManager.createKey(EntityDemonBase.class, DataSerializers.OPTIONAL_UNIQUE_ID);
public EntityDemonBase(World worldIn)
{
public EntityDemonBase(World worldIn) {
super(worldIn);
}
@Override
protected void entityInit()
{
protected void entityInit() {
super.entityInit();
this.dataManager.register(TAMED, (byte) 0);
this.dataManager.register(OWNER_UNIQUE_ID, Optional.<UUID>absent());
}
@Override
protected void applyEntityAttributes()
{
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE);
}
public void setCombatTask()
{
public void setCombatTask() {
}
@Override
public boolean isPotionApplicable(PotionEffect effect)
{
public boolean isPotionApplicable(PotionEffect effect) {
return super.isPotionApplicable(effect);
}
@Override
public void onLivingUpdate()
{
public void onLivingUpdate() {
this.updateArmSwingProgress();
super.onLivingUpdate();
}
@Override
public boolean attackEntityFrom(DamageSource source, float amount)
{
public boolean attackEntityFrom(DamageSource source, float amount) {
return !this.isEntityInvulnerable(source) && super.attackEntityFrom(source, amount);
}
@ -93,23 +79,19 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable
* Redone from EntityMob to prevent despawning on peaceful.
*/
@Override
public boolean attackEntityAsMob(Entity attackedEntity)
{
public boolean attackEntityAsMob(Entity attackedEntity) {
float f = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
int i = 0;
if (attackedEntity instanceof EntityLivingBase)
{
if (attackedEntity instanceof EntityLivingBase) {
f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase) attackedEntity).getCreatureAttribute());
i += EnchantmentHelper.getKnockbackModifier(this);
}
boolean flag = attackedEntity.attackEntityFrom(DamageSource.causeMobDamage(this), f);
if (flag)
{
if (i > 0)
{
if (flag) {
if (i > 0) {
((EntityLivingBase) attackedEntity).knockBack(this, (float) i * 0.5F, (double) MathHelper.sin(this.rotationYaw * 0.017453292F), (double) (-MathHelper.cos(this.rotationYaw * 0.017453292F)));
this.motionX *= 0.6D;
this.motionZ *= 0.6D;
@ -117,23 +99,19 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable
int j = EnchantmentHelper.getFireAspectModifier(this);
if (j > 0)
{
if (j > 0) {
attackedEntity.setFire(j * 4);
}
if (attackedEntity instanceof EntityPlayer)
{
if (attackedEntity instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) attackedEntity;
ItemStack itemstack = this.getHeldItemMainhand();
ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : ItemStack.EMPTY;
if (!itemstack.isEmpty() && !itemstack1.isEmpty() && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD)
{
if (!itemstack.isEmpty() && !itemstack1.isEmpty() && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD) {
float f1 = 0.25F + (float) EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;
if (this.rand.nextFloat() < f1)
{
if (this.rand.nextFloat() < f1) {
entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
this.getEntityWorld().setEntityState(entityplayer, (byte) 30);
}
@ -147,87 +125,70 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable
}
@Override
public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack)
{
public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack) {
super.setItemStackToSlot(slotIn, stack);
if (!this.getEntityWorld().isRemote && slotIn == EntityEquipmentSlot.MAINHAND)
{
if (!this.getEntityWorld().isRemote && slotIn == EntityEquipmentSlot.MAINHAND) {
this.setCombatTask();
}
}
public boolean isStationary()
{
public boolean isStationary() {
return false;
}
public boolean absorbExplosion(Explosion explosion)
{
public boolean absorbExplosion(Explosion explosion) {
return false;
}
public void performEmergencyHeal(double toHeal)
{
public void performEmergencyHeal(double toHeal) {
this.heal((float) toHeal);
if (getEntityWorld() instanceof WorldServer)
{
if (getEntityWorld() instanceof WorldServer) {
WorldServer server = (WorldServer) getEntityWorld();
server.spawnParticle(EnumParticleTypes.HEART, this.posX + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, this.posY + 0.5D + (double) (this.rand.nextFloat() * this.height), this.posZ + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, 7, 0.2, 0.2, 0.2, 0);
}
}
public boolean shouldEmergencyHeal()
{
public boolean shouldEmergencyHeal() {
return this.getHealth() < this.getMaxHealth() * 0.5;
}
@Override
protected boolean canDespawn()
{
protected boolean canDespawn() {
return !this.isTamed() && super.canDespawn();
}
@Override
public void writeEntityToNBT(NBTTagCompound tag)
{
public void writeEntityToNBT(NBTTagCompound tag) {
super.writeEntityToNBT(tag);
if (this.getOwnerId() == null)
{
if (this.getOwnerId() == null) {
tag.setString("OwnerUUID", "");
} else
{
} else {
tag.setString("OwnerUUID", this.getOwnerId().toString());
}
}
@Override
public void readEntityFromNBT(NBTTagCompound tag)
{
public void readEntityFromNBT(NBTTagCompound tag) {
super.readEntityFromNBT(tag);
String s;
if (tag.hasKey("OwnerUUID", 8))
{
if (tag.hasKey("OwnerUUID", 8)) {
s = tag.getString("OwnerUUID");
} else
{
} else {
String s1 = tag.getString("Owner");
s = PreYggdrasilConverter.convertMobOwnerIfNeeded(this.getServer(), s1);
}
if (!s.isEmpty())
{
try
{
if (!s.isEmpty()) {
try {
this.setOwnerId(UUID.fromString(s));
this.setTamed(true);
} catch (Throwable var4)
{
} catch (Throwable var4) {
this.setTamed(false);
}
}
@ -236,46 +197,36 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable
}
//TODO: Change to fit the given AI
public boolean shouldAttackEntity(EntityLivingBase attacker, EntityLivingBase owner)
{
if (!(attacker instanceof EntityCreeper) && !(attacker instanceof EntityGhast))
{
if (attacker instanceof IEntityOwnable)
{
public boolean shouldAttackEntity(EntityLivingBase attacker, EntityLivingBase owner) {
if (!(attacker instanceof EntityCreeper) && !(attacker instanceof EntityGhast)) {
if (attacker instanceof IEntityOwnable) {
IEntityOwnable entityOwnable = (IEntityOwnable) attacker;
if (entityOwnable.getOwner() == owner)
{
if (entityOwnable.getOwner() == owner) {
return false;
}
}
return !(attacker instanceof EntityPlayer && owner instanceof EntityPlayer && !((EntityPlayer) owner).canAttackPlayer((EntityPlayer) attacker)) && (!(attacker instanceof EntityHorse) || !((EntityHorse) attacker).isTame());
} else
{
} else {
return false;
}
}
public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity)
{
public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity) {
}
public boolean isTamed()
{
public boolean isTamed() {
return (this.dataManager.get(TAMED) & 4) != 0;
}
public void setTamed(boolean tamed)
{
public void setTamed(boolean tamed) {
byte b0 = this.dataManager.get(TAMED);
if (tamed)
{
if (tamed) {
this.dataManager.set(TAMED, (byte) (b0 | 4));
} else
{
} else {
this.dataManager.set(TAMED, (byte) (b0 & -5));
}
@ -283,8 +234,7 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable
}
@Override
protected SoundEvent getAmbientSound()
{
protected SoundEvent getAmbientSound() {
return SoundEvents.ENTITY_COW_AMBIENT;
}
@ -294,20 +244,17 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable
return getHurtSound();
}
protected SoundEvent getHurtSound()
{
protected SoundEvent getHurtSound() {
return SoundEvents.ENTITY_COW_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
protected SoundEvent getDeathSound() {
return SoundEvents.ENTITY_COW_DEATH;
}
@Override
protected void playStepSound(BlockPos pos, Block block)
{
protected void playStepSound(BlockPos pos, Block block) {
this.playSound(SoundEvents.ENTITY_COW_STEP, 0.15F, 1.0F);
}
@ -315,52 +262,42 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable
* Returns the volume for the sounds this mob makes.
*/
@Override
protected float getSoundVolume()
{
protected float getSoundVolume() {
return 0.4F;
}
@Override
public UUID getOwnerId()
{
public UUID getOwnerId() {
return (this.dataManager.get(OWNER_UNIQUE_ID)).orNull();
}
public void setOwnerId(UUID uuid)
{
public void setOwnerId(UUID uuid) {
this.dataManager.set(OWNER_UNIQUE_ID, Optional.fromNullable(uuid));
}
@Override
public EntityLivingBase getOwner()
{
try
{
public EntityLivingBase getOwner() {
try {
UUID uuid = this.getOwnerId();
return uuid == null ? null : this.getEntityWorld().getPlayerEntityByUUID(uuid);
} catch (IllegalArgumentException var2)
{
} catch (IllegalArgumentException var2) {
return null;
}
}
public void setOwner(EntityPlayer player)
{
public void setOwner(EntityPlayer player) {
setOwnerId(player.getUniqueID());
}
public class TargetPredicate implements Predicate<EntityMob>
{
public class TargetPredicate implements Predicate<EntityMob> {
EntityDemonBase entity;
public TargetPredicate(EntityDemonBase entity)
{
public TargetPredicate(EntityDemonBase entity) {
this.entity = entity;
}
@Override
public boolean apply(EntityMob input)
{
public boolean apply(EntityMob input) {
return entity.shouldAttackEntity(input, this.entity.getOwner());
}
}

View file

@ -1,19 +1,15 @@
package WayofTime.bloodmagic.entity.mob;
import WayofTime.bloodmagic.block.BlockMimic;
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
import WayofTime.bloodmagic.entity.ai.EntityAIMimicReform;
import WayofTime.bloodmagic.tile.TileMimic;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILeapAtTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityIronGolem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
@ -33,13 +29,8 @@ import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
import WayofTime.bloodmagic.block.BlockMimic;
import WayofTime.bloodmagic.entity.ai.EntityAIMimicReform;
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
import WayofTime.bloodmagic.tile.TileMimic;
public class EntityMimic extends EntityDemonBase
{
public class EntityMimic extends EntityDemonBase {
/**
* Copy of EntitySpider's AI (should be pretty evident...)
*/
@ -50,8 +41,7 @@ public class EntityMimic extends EntityDemonBase
public int metaOfReplacedBlock = 0;
public int playerCheckRadius = 5;
public EntityMimic(World worldIn)
{
public EntityMimic(World worldIn) {
super(worldIn);
this.setSize(0.9F, 0.9F);
@ -70,8 +60,7 @@ public class EntityMimic extends EntityDemonBase
}
@Override
public void writeEntityToNBT(NBTTagCompound tag)
{
public void writeEntityToNBT(NBTTagCompound tag) {
super.writeEntityToNBT(tag);
tag.setBoolean("dropItemsOnBreak", dropItemsOnBreak);
@ -81,8 +70,7 @@ public class EntityMimic extends EntityDemonBase
}
@Override
public void readEntityFromNBT(NBTTagCompound tag)
{
public void readEntityFromNBT(NBTTagCompound tag) {
super.readEntityFromNBT(tag);
dropItemsOnBreak = tag.getBoolean("dropItemsOnBreak");
@ -91,30 +79,24 @@ public class EntityMimic extends EntityDemonBase
playerCheckRadius = tag.getInteger("playerCheckRadius");
}
public ItemStack getMimicItemStack()
{
public ItemStack getMimicItemStack() {
return this.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
}
public void setMimicItemStack(ItemStack stack)
{
public void setMimicItemStack(ItemStack stack) {
this.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack);
}
public boolean spawnHeldBlockOnDeath(World world, BlockPos pos)
{
public boolean spawnHeldBlockOnDeath(World world, BlockPos pos) {
return world.isAirBlock(pos) && TileMimic.replaceMimicWithBlockActual(world, pos, getMimicItemStack(), tileTag, metaOfReplacedBlock);
}
public boolean spawnMimicBlockAtPosition(World world, BlockPos pos)
{
if (world.isAirBlock(pos))
{
public boolean spawnMimicBlockAtPosition(World world, BlockPos pos) {
if (world.isAirBlock(pos)) {
IBlockState mimicState = RegistrarBloodMagicBlocks.MIMIC.getStateFromMeta(BlockMimic.sentientMimicMeta);
world.setBlockState(pos, mimicState, 3);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileMimic)
{
if (tile instanceof TileMimic) {
TileMimic mimic = (TileMimic) tile;
mimic.metaOfReplacedBlock = metaOfReplacedBlock;
mimic.tileTag = tileTag;
@ -129,8 +111,7 @@ public class EntityMimic extends EntityDemonBase
return false;
}
public void initializeMimic(ItemStack heldStack, NBTTagCompound tileTag, boolean dropItemsOnBreak, int metaOfReplacedBlock, int playerCheckRadius, BlockPos homePosition)
{
public void initializeMimic(ItemStack heldStack, NBTTagCompound tileTag, boolean dropItemsOnBreak, int metaOfReplacedBlock, int playerCheckRadius, BlockPos homePosition) {
this.setMimicItemStack(heldStack);
this.tileTag = tileTag;
this.dropItemsOnBreak = dropItemsOnBreak;
@ -139,29 +120,21 @@ public class EntityMimic extends EntityDemonBase
this.setHomePosAndDistance(homePosition, 2); //TODO: Save this.
}
public boolean reformIntoMimicBlock(BlockPos centerPos)
{
public boolean reformIntoMimicBlock(BlockPos centerPos) {
int horizontalRadius = 1;
int verticalRadius = 1;
for (int hR = 0; hR <= horizontalRadius; hR++)
{
for (int vR = 0; vR <= verticalRadius; vR++)
{
for (int i = -hR; i <= hR; i++)
{
for (int k = -hR; k <= hR; k++)
{
for (int j = -vR; j <= vR; j += 2 * vR + (vR > 0 ? 0 : 1))
{
if (!(Math.abs(i) == hR || Math.abs(k) == hR))
{
for (int hR = 0; hR <= horizontalRadius; hR++) {
for (int vR = 0; vR <= verticalRadius; vR++) {
for (int i = -hR; i <= hR; i++) {
for (int k = -hR; k <= hR; k++) {
for (int j = -vR; j <= vR; j += 2 * vR + (vR > 0 ? 0 : 1)) {
if (!(Math.abs(i) == hR || Math.abs(k) == hR)) {
continue;
}
BlockPos newPos = centerPos.add(i, j, k);
if (spawnMimicBlockAtPosition(getEntityWorld(), newPos))
{
if (spawnMimicBlockAtPosition(getEntityWorld(), newPos)) {
return true;
}
}
@ -174,35 +147,26 @@ public class EntityMimic extends EntityDemonBase
}
@Override
public void onDeath(DamageSource cause)
{
public void onDeath(DamageSource cause) {
super.onDeath(cause);
if (!getEntityWorld().isRemote)
{
if (!getEntityWorld().isRemote) {
BlockPos centerPos = this.getPosition();
int horizontalRadius = 1;
int verticalRadius = 1;
for (int hR = 0; hR <= horizontalRadius; hR++)
{
for (int vR = 0; vR <= verticalRadius; vR++)
{
for (int i = -hR; i <= hR; i++)
{
for (int k = -hR; k <= hR; k++)
{
for (int j = -vR; j <= vR; j += 2 * vR + (vR > 0 ? 0 : 1))
{
if (!(Math.abs(i) == hR || Math.abs(k) == hR))
{
for (int hR = 0; hR <= horizontalRadius; hR++) {
for (int vR = 0; vR <= verticalRadius; vR++) {
for (int i = -hR; i <= hR; i++) {
for (int k = -hR; k <= hR; k++) {
for (int j = -vR; j <= vR; j += 2 * vR + (vR > 0 ? 0 : 1)) {
if (!(Math.abs(i) == hR || Math.abs(k) == hR)) {
continue;
}
BlockPos newPos = centerPos.add(i, j, k);
if (spawnHeldBlockOnDeath(getEntityWorld(), newPos))
{
if (spawnHeldBlockOnDeath(getEntityWorld(), newPos)) {
return;
}
}
@ -218,8 +182,7 @@ public class EntityMimic extends EntityDemonBase
* this one.
*/
@Override
public double getMountedYOffset()
{
public double getMountedYOffset() {
return (double) (this.height * 0.5F);
}
@ -227,14 +190,12 @@ public class EntityMimic extends EntityDemonBase
* Returns new PathNavigateGround instance
*/
@Override
protected PathNavigate createNavigator(World worldIn)
{
protected PathNavigate createNavigator(World worldIn) {
return new PathNavigateClimber(this, worldIn);
}
@Override
protected void entityInit()
{
protected void entityInit() {
super.entityInit();
this.dataManager.register(CLIMBING, (byte) 0);
// this.dataManager.register(ITEMSTACK, null);
@ -244,53 +205,44 @@ public class EntityMimic extends EntityDemonBase
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate()
{
if (!this.getEntityWorld().isRemote && this.getEntityWorld().getDifficulty() == EnumDifficulty.PEACEFUL)
{
if (reformIntoMimicBlock(this.getPosition()))
{
public void onUpdate() {
if (!this.getEntityWorld().isRemote && this.getEntityWorld().getDifficulty() == EnumDifficulty.PEACEFUL) {
if (reformIntoMimicBlock(this.getPosition())) {
this.setDead();
}
}
super.onUpdate();
if (!this.getEntityWorld().isRemote)
{
if (!this.getEntityWorld().isRemote) {
this.setBesideClimbableBlock(this.isCollidedHorizontally);
}
}
@Override
protected void applyEntityAttributes()
{
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(16.0D);
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3D);
}
@Override
protected SoundEvent getAmbientSound()
{
protected SoundEvent getAmbientSound() {
return SoundEvents.ENTITY_SPIDER_AMBIENT;
}
@Override
protected SoundEvent getHurtSound()
{
protected SoundEvent getHurtSound() {
return SoundEvents.ENTITY_SPIDER_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
protected SoundEvent getDeathSound() {
return SoundEvents.ENTITY_SPIDER_DEATH;
}
@Override
protected void playStepSound(BlockPos pos, Block blockIn)
{
protected void playStepSound(BlockPos pos, Block blockIn) {
this.playSound(SoundEvents.ENTITY_SPIDER_STEP, 0.15F, 1.0F);
}
@ -298,8 +250,7 @@ public class EntityMimic extends EntityDemonBase
* returns true if this entity is by a ladder, false otherwise
*/
@Override
public boolean isOnLadder()
{
public boolean isOnLadder() {
return this.isBesideClimbableBlock();
}
@ -307,8 +258,7 @@ public class EntityMimic extends EntityDemonBase
* Sets the Entity inside a web block.
*/
@Override
public void setInWeb()
{
public void setInWeb() {
}
@ -316,14 +266,12 @@ public class EntityMimic extends EntityDemonBase
* Get this Entity's EnumCreatureAttribute
*/
@Override
public EnumCreatureAttribute getCreatureAttribute()
{
public EnumCreatureAttribute getCreatureAttribute() {
return EnumCreatureAttribute.ARTHROPOD;
}
@Override
public boolean isPotionApplicable(PotionEffect potioneffectIn)
{
public boolean isPotionApplicable(PotionEffect potioneffectIn) {
return potioneffectIn.getPotion() != MobEffects.POISON && super.isPotionApplicable(potioneffectIn);
}
@ -331,8 +279,7 @@ public class EntityMimic extends EntityDemonBase
* Returns true if the WatchableObject (Byte) is 0x01 otherwise returns
* false. The WatchableObject is updated using setBesideClimableBlock.
*/
public boolean isBesideClimbableBlock()
{
public boolean isBesideClimbableBlock() {
return (this.dataManager.get(CLIMBING) & 1) != 0;
}
@ -340,44 +287,35 @@ public class EntityMimic extends EntityDemonBase
* Updates the WatchableObject (Byte) created in entityInit(), setting it to
* 0x01 if par1 is true or 0x00 if it is false.
*/
public void setBesideClimbableBlock(boolean climbing)
{
public void setBesideClimbableBlock(boolean climbing) {
byte b0 = this.dataManager.get(CLIMBING);
if (climbing)
{
if (climbing) {
b0 = (byte) (b0 | 1);
} else
{
} else {
b0 = (byte) (b0 & -2);
}
this.dataManager.set(CLIMBING, b0);
}
public float getEyeHeight()
{
public float getEyeHeight() {
return 0.65F;
}
static class AISpiderAttack extends EntityAIAttackMelee
{
public AISpiderAttack(EntityMimic spider)
{
static class AISpiderAttack extends EntityAIAttackMelee {
public AISpiderAttack(EntityMimic spider) {
super(spider, 1.0D, true);
}
@Override
protected double getAttackReachSqr(EntityLivingBase attackTarget)
{
protected double getAttackReachSqr(EntityLivingBase attackTarget) {
return (double) (4.0F + attackTarget.width);
}
}
static class AISpiderTarget<T extends EntityLivingBase> extends EntityAINearestAttackableTarget<T>
{
public AISpiderTarget(EntityMimic spider, Class<T> classTarget)
{
static class AISpiderTarget<T extends EntityLivingBase> extends EntityAINearestAttackableTarget<T> {
public AISpiderTarget(EntityMimic spider, Class<T> classTarget) {
super(spider, classTarget, true);
}
}

View file

@ -1,21 +1,22 @@
package WayofTime.bloodmagic.entity.mob;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
import WayofTime.bloodmagic.entity.ai.EntityAIAttackRangedBow;
import WayofTime.bloodmagic.entity.ai.EntityAIFollowOwner;
import WayofTime.bloodmagic.entity.ai.*;
import WayofTime.bloodmagic.entity.ai.EntityAIOwnerHurtByTarget;
import WayofTime.bloodmagic.entity.ai.EntityAIOwnerHurtTarget;
import WayofTime.bloodmagic.item.soul.ItemSentientBow;
import net.minecraft.block.Block;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.player.EntityPlayer;
@ -39,31 +40,19 @@ import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
import WayofTime.bloodmagic.entity.ai.EntityAIAttackRangedBow;
import WayofTime.bloodmagic.entity.ai.EntityAIFollowOwner;
import WayofTime.bloodmagic.entity.ai.EntityAIGrabEffectsFromOwner;
import WayofTime.bloodmagic.entity.ai.EntityAIHurtByTargetIgnoreTamed;
import WayofTime.bloodmagic.entity.ai.EntityAIOwnerHurtByTarget;
import WayofTime.bloodmagic.entity.ai.EntityAIOwnerHurtTarget;
import WayofTime.bloodmagic.entity.ai.EntityAIRetreatToHeal;
import WayofTime.bloodmagic.item.soul.ItemSentientBow;
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
public class EntitySentientSpecter extends EntityDemonBase
{
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class EntitySentientSpecter extends EntityDemonBase {
private final EntityAIAttackRangedBow aiArrowAttack = new EntityAIAttackRangedBow(this, 1.0D, 20, 15.0F);
private final EntityAIAttackMelee aiAttackOnCollide = new EntityAIAttackMelee(this, 1.0D, false);
private final int attackPriority = 3;
protected EnumDemonWillType type = EnumDemonWillType.DESTRUCTIVE;
protected boolean wasGivenSentientArmour = false;
private final EntityAIAttackRangedBow aiArrowAttack = new EntityAIAttackRangedBow(this, 1.0D, 20, 15.0F);
private final EntityAIAttackMelee aiAttackOnCollide = new EntityAIAttackMelee(this, 1.0D, false);
private final int attackPriority = 3;
public EntitySentientSpecter(World worldIn)
{
public EntitySentientSpecter(World worldIn) {
super(worldIn);
this.setSize(0.6F, 1.95F);
// ((PathNavigateGround) getNavigator()).setCanSwim(false);
@ -87,8 +76,7 @@ public class EntitySentientSpecter extends EntityDemonBase
}
@Override
protected void applyEntityAttributes()
{
protected void applyEntityAttributes() {
super.applyEntityAttributes();
getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(40.0D);
getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D);
@ -96,27 +84,22 @@ public class EntitySentientSpecter extends EntityDemonBase
}
@Override
public void setCombatTask()
{
if (!this.getEntityWorld().isRemote)
{
public void setCombatTask() {
if (!this.getEntityWorld().isRemote) {
this.tasks.removeTask(this.aiAttackOnCollide);
this.tasks.removeTask(this.aiArrowAttack);
ItemStack itemstack = this.getHeldItemMainhand();
if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow)
{
if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow) {
int i = 20;
if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD)
{
if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD) {
i = 40;
}
this.aiArrowAttack.setAttackCooldown(i);
this.tasks.addTask(attackPriority, this.aiArrowAttack);
} else
{
} else {
this.tasks.addTask(attackPriority, this.aiAttackOnCollide);
}
}
@ -130,22 +113,17 @@ public class EntitySentientSpecter extends EntityDemonBase
return !(potion == MobEffects.REGENERATION || potion == MobEffects.INSTANT_HEALTH) && super.isPotionApplicable(effect);
}
public boolean canStealEffectFromOwner(EntityLivingBase owner, PotionEffect effect)
{
public boolean canStealEffectFromOwner(EntityLivingBase owner, PotionEffect effect) {
return effect.getPotion().isBadEffect() && this.type == EnumDemonWillType.CORROSIVE;
}
public boolean canStealEffectFromOwner(EntityLivingBase owner)
{
if (this.type != EnumDemonWillType.CORROSIVE)
{
public boolean canStealEffectFromOwner(EntityLivingBase owner) {
if (this.type != EnumDemonWillType.CORROSIVE) {
return false;
}
for (PotionEffect eff : owner.getActivePotionEffects())
{
if (canStealEffectFromOwner(owner, eff))
{
for (PotionEffect eff : owner.getActivePotionEffects()) {
if (canStealEffectFromOwner(owner, eff)) {
return true;
}
}
@ -153,10 +131,8 @@ public class EntitySentientSpecter extends EntityDemonBase
return false;
}
public boolean stealEffectsFromOwner(EntityLivingBase owner)
{
if (this.type != EnumDemonWillType.CORROSIVE)
{
public boolean stealEffectsFromOwner(EntityLivingBase owner) {
if (this.type != EnumDemonWillType.CORROSIVE) {
return false;
}
@ -164,17 +140,14 @@ public class EntitySentientSpecter extends EntityDemonBase
List<PotionEffect> removedEffects = new ArrayList<PotionEffect>();
for (PotionEffect eff : owner.getActivePotionEffects())
{
if (canStealEffectFromOwner(owner, eff))
{
for (PotionEffect eff : owner.getActivePotionEffects()) {
if (canStealEffectFromOwner(owner, eff)) {
removedEffects.add(eff);
hasStolenEffect = true;
}
}
for (PotionEffect eff : removedEffects)
{
for (PotionEffect eff : removedEffects) {
owner.removePotionEffect(eff.getPotion());
this.addPotionEffect(eff);
}
@ -182,23 +155,17 @@ public class EntitySentientSpecter extends EntityDemonBase
return hasStolenEffect;
}
public boolean applyNegativeEffectsToAttacked(EntityLivingBase attackedEntity, float percentTransmitted)
{
public boolean applyNegativeEffectsToAttacked(EntityLivingBase attackedEntity, float percentTransmitted) {
boolean hasProvidedEffect = false;
List<PotionEffect> removedEffects = new ArrayList<PotionEffect>();
for (PotionEffect eff : this.getActivePotionEffects())
{
if (eff.getPotion().isBadEffect() && attackedEntity.isPotionApplicable(eff))
{
if (!attackedEntity.isPotionActive(eff.getPotion()))
{
for (PotionEffect eff : this.getActivePotionEffects()) {
if (eff.getPotion().isBadEffect() && attackedEntity.isPotionApplicable(eff)) {
if (!attackedEntity.isPotionActive(eff.getPotion())) {
removedEffects.add(eff);
hasProvidedEffect = true;
} else
{
} else {
PotionEffect activeEffect = attackedEntity.getActivePotionEffect(eff.getPotion());
if (activeEffect.getAmplifier() < eff.getAmplifier() || activeEffect.getDuration() < eff.getDuration() * percentTransmitted)
{
if (activeEffect.getAmplifier() < eff.getAmplifier() || activeEffect.getDuration() < eff.getDuration() * percentTransmitted) {
removedEffects.add(eff);
hasProvidedEffect = true;
}
@ -206,18 +173,15 @@ public class EntitySentientSpecter extends EntityDemonBase
}
}
for (PotionEffect eff : removedEffects)
{
if (!attackedEntity.isPotionActive(eff.getPotion()))
{
for (PotionEffect eff : removedEffects) {
if (!attackedEntity.isPotionActive(eff.getPotion())) {
PotionEffect newEffect = new PotionEffect(eff.getPotion(), (int) (eff.getDuration() * percentTransmitted), eff.getAmplifier(), eff.getIsAmbient(), eff.doesShowParticles());
attackedEntity.addPotionEffect(newEffect);
PotionEffect newSentientEffect = new PotionEffect(eff.getPotion(), (int) (eff.getDuration() * (1 - percentTransmitted)), eff.getAmplifier(), eff.getIsAmbient(), eff.doesShowParticles());
this.removePotionEffect(eff.getPotion());
this.addPotionEffect(newSentientEffect);
} else
{
} else {
PotionEffect activeEffect = attackedEntity.getActivePotionEffect(eff.getPotion());
PotionEffect newEffect = new PotionEffect(eff.getPotion(), (int) (eff.getDuration() * percentTransmitted), eff.getAmplifier(), activeEffect.getIsAmbient(), activeEffect.doesShowParticles());
@ -232,26 +196,21 @@ public class EntitySentientSpecter extends EntityDemonBase
return hasProvidedEffect;
}
public List<PotionEffect> getPotionEffectsForArrowRemovingDuration(float percentTransmitted)
{
public List<PotionEffect> getPotionEffectsForArrowRemovingDuration(float percentTransmitted) {
List<PotionEffect> arrowEffects = new ArrayList<PotionEffect>();
if (type != EnumDemonWillType.CORROSIVE)
{
if (type != EnumDemonWillType.CORROSIVE) {
return arrowEffects;
}
List<PotionEffect> removedEffects = new ArrayList<PotionEffect>();
for (PotionEffect eff : this.getActivePotionEffects())
{
if (eff.getPotion().isBadEffect())
{
for (PotionEffect eff : this.getActivePotionEffects()) {
if (eff.getPotion().isBadEffect()) {
removedEffects.add(eff);
}
}
for (PotionEffect eff : removedEffects)
{
for (PotionEffect eff : removedEffects) {
PotionEffect newEffect = new PotionEffect(eff.getPotion(), (int) (eff.getDuration() * percentTransmitted), eff.getAmplifier(), eff.getIsAmbient(), eff.doesShowParticles());
arrowEffects.add(newEffect);
@ -264,8 +223,7 @@ public class EntitySentientSpecter extends EntityDemonBase
}
@Override
public boolean attackEntityFrom(DamageSource source, float amount)
{
public boolean attackEntityFrom(DamageSource source, float amount) {
return !this.isEntityInvulnerable(source) && super.attackEntityFrom(source, amount);
}
@ -273,47 +231,38 @@ public class EntitySentientSpecter extends EntityDemonBase
* Redone from EntityMob to prevent despawning on peaceful.
*/
@Override
public boolean attackEntityAsMob(Entity attackedEntity)
{
public boolean attackEntityAsMob(Entity attackedEntity) {
boolean flag = super.attackEntityAsMob(attackedEntity);
if (flag)
{
if (this.type == EnumDemonWillType.CORROSIVE && attackedEntity instanceof EntityLivingBase)
{
if (flag) {
if (this.type == EnumDemonWillType.CORROSIVE && attackedEntity instanceof EntityLivingBase) {
// ((EntityLivingBase) attackedEntity).addPotionEffect(new PotionEffect(MobEffects.WITHER, 200));
applyNegativeEffectsToAttacked((EntityLivingBase) attackedEntity, 1);
}
return true;
} else
{
} else {
return false;
}
}
@Override
public void onDeath(DamageSource cause)
{
public void onDeath(DamageSource cause) {
super.onDeath(cause);
if (!getEntityWorld().isRemote && !getHeldItemMainhand().isEmpty())
{
if (!getEntityWorld().isRemote && !getHeldItemMainhand().isEmpty()) {
this.entityDropItem(getHeldItemMainhand(), 0);
}
}
@Override
public boolean isStationary()
{
public boolean isStationary() {
return false;
}
@Override
public boolean absorbExplosion(Explosion explosion)
{
if (this.type == EnumDemonWillType.DESTRUCTIVE)
{
public boolean absorbExplosion(Explosion explosion) {
if (this.type == EnumDemonWillType.DESTRUCTIVE) {
this.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 600, 1));
explosion.doExplosionB(true);
@ -325,27 +274,21 @@ public class EntitySentientSpecter extends EntityDemonBase
}
@Override
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
public boolean processInteract(EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (this.isTamed() && player.equals(this.getOwner()) && hand == EnumHand.MAIN_HAND)
{
if (this.isTamed() && player.equals(this.getOwner()) && hand == EnumHand.MAIN_HAND) {
if (stack.isEmpty() && player.isSneaking()) //Should return to the entity
{
if (!getEntityWorld().isRemote)
{
if (!getHeldItemMainhand().isEmpty())
{
if (!getEntityWorld().isRemote) {
if (!getHeldItemMainhand().isEmpty()) {
this.entityDropItem(getHeldItemMainhand(), 0);
}
if (!getHeldItemOffhand().isEmpty())
{
if (!getHeldItemOffhand().isEmpty()) {
this.entityDropItem(getHeldItemOffhand(), 0);
}
if (wasGivenSentientArmour)
{
if (wasGivenSentientArmour) {
this.entityDropItem(new ItemStack(RegistrarBloodMagicItems.SENTIENT_ARMOUR_GEM), 0);
}
@ -357,46 +300,38 @@ public class EntitySentientSpecter extends EntityDemonBase
return super.processInteract(player, hand);
}
public boolean isEntityInvulnerable(DamageSource source)
{
public boolean isEntityInvulnerable(DamageSource source) {
return super.isEntityInvulnerable(source) && (this.type == EnumDemonWillType.DESTRUCTIVE && source.isExplosion());
}
@Override
public void performEmergencyHeal(double toHeal)
{
public void performEmergencyHeal(double toHeal) {
this.heal((float) toHeal);
if (getEntityWorld() instanceof WorldServer)
{
if (getEntityWorld() instanceof WorldServer) {
WorldServer server = (WorldServer) getEntityWorld();
server.spawnParticle(EnumParticleTypes.HEART, this.posX + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, this.posY + 0.5D + (double) (this.rand.nextFloat() * this.height), this.posZ + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, 7, 0.2, 0.2, 0.2, 0, new int[0]);
}
}
/**
*
* @param toHeal
* @return Amount of Will consumed from the Aura to heal
*/
public double absorbWillFromAuraToHeal(double toHeal)
{
if (getEntityWorld().isRemote)
{
public double absorbWillFromAuraToHeal(double toHeal) {
if (getEntityWorld().isRemote) {
return 0;
}
double healthMissing = this.getMaxHealth() - this.getHealth();
if (healthMissing <= 0)
{
if (healthMissing <= 0) {
return 0;
}
double will = WorldDemonWillHandler.getCurrentWill(getEntityWorld(), getPosition(), getType());
toHeal = Math.min(healthMissing, Math.min(toHeal, will / getWillToHealth()));
if (toHeal > 0)
{
if (toHeal > 0) {
this.heal((float) toHeal);
return WorldDemonWillHandler.drainWill(getEntityWorld(), getPosition(), getType(), toHeal * getWillToHealth(), true);
}
@ -404,21 +339,17 @@ public class EntitySentientSpecter extends EntityDemonBase
return 0;
}
public double getWillToHealth()
{
public double getWillToHealth() {
return 2;
}
@Override
protected boolean canDespawn()
{
protected boolean canDespawn() {
return !this.isTamed() && super.canDespawn();
}
public void onUpdate()
{
if (!this.getEntityWorld().isRemote && this.ticksExisted % 20 == 0)
{
public void onUpdate() {
if (!this.getEntityWorld().isRemote && this.ticksExisted % 20 == 0) {
absorbWillFromAuraToHeal(2);
}
@ -426,8 +357,7 @@ public class EntitySentientSpecter extends EntityDemonBase
}
@Override
public void writeEntityToNBT(NBTTagCompound tag)
{
public void writeEntityToNBT(NBTTagCompound tag) {
super.writeEntityToNBT(tag);
tag.setString(Constants.NBT.WILL_TYPE, type.toString());
@ -436,15 +366,12 @@ public class EntitySentientSpecter extends EntityDemonBase
}
@Override
public void readEntityFromNBT(NBTTagCompound tag)
{
public void readEntityFromNBT(NBTTagCompound tag) {
super.readEntityFromNBT(tag);
if (!tag.hasKey(Constants.NBT.WILL_TYPE))
{
if (!tag.hasKey(Constants.NBT.WILL_TYPE)) {
type = EnumDemonWillType.DEFAULT;
} else
{
} else {
type = EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
}
@ -455,37 +382,29 @@ public class EntitySentientSpecter extends EntityDemonBase
//TODO: Change to fit the given AI
@Override
public boolean shouldAttackEntity(EntityLivingBase attacker, EntityLivingBase owner)
{
if (!(attacker instanceof EntityCreeper) && !(attacker instanceof EntityGhast))
{
public boolean shouldAttackEntity(EntityLivingBase attacker, EntityLivingBase owner) {
if (!(attacker instanceof EntityCreeper) && !(attacker instanceof EntityGhast)) {
return super.shouldAttackEntity(attacker, owner);
} else
{
} else {
return false;
}
}
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity)
{
public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity) {
ItemStack heldStack = this.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
if (!heldStack.isEmpty() && heldStack.getItem() == RegistrarBloodMagicItems.SENTIENT_BOW)
{
if (!heldStack.isEmpty() && heldStack.getItem() == RegistrarBloodMagicItems.SENTIENT_BOW) {
EntityTippedArrow arrowEntity = ((ItemSentientBow) heldStack.getItem()).getArrowEntity(getEntityWorld(), heldStack, target, this, velocity);
if (arrowEntity != null)
{
if (arrowEntity != null) {
List<PotionEffect> effects = getPotionEffectsForArrowRemovingDuration(0.2f);
for (PotionEffect eff : effects)
{
for (PotionEffect eff : effects) {
arrowEntity.addEffect(eff);
}
this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.getEntityWorld().spawnEntity(arrowEntity);
}
} else
{
} else {
EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.getEntityWorld(), this); //TODO: Change to an arrow created by the Sentient Bow
double d0 = target.posX - this.posX;
double d1 = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - entitytippedarrow.posY;
@ -496,21 +415,18 @@ public class EntitySentientSpecter extends EntityDemonBase
int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this);
entitytippedarrow.setDamage((double) (velocity * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.getEntityWorld().getDifficulty().getDifficultyId() * 0.11F));
if (i > 0)
{
if (i > 0) {
entitytippedarrow.setDamage(entitytippedarrow.getDamage() + (double) i * 0.5D + 0.5D);
}
if (j > 0)
{
if (j > 0) {
entitytippedarrow.setKnockbackStrength(j);
}
boolean burning = this.isBurning();
burning = burning || EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FLAME, this) > 0;
if (burning)
{
if (burning) {
entitytippedarrow.setFire(100);
}
@ -525,26 +441,22 @@ public class EntitySentientSpecter extends EntityDemonBase
}
@Override
protected SoundEvent getAmbientSound()
{
protected SoundEvent getAmbientSound() {
return SoundEvents.ENTITY_COW_AMBIENT;
}
@Override
protected SoundEvent getHurtSound()
{
protected SoundEvent getHurtSound() {
return SoundEvents.ENTITY_COW_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
protected SoundEvent getDeathSound() {
return SoundEvents.ENTITY_COW_DEATH;
}
@Override
protected void playStepSound(BlockPos pos, Block block)
{
protected void playStepSound(BlockPos pos, Block block) {
this.playSound(SoundEvents.ENTITY_COW_STEP, 0.15F, 1.0F);
}
@ -552,8 +464,7 @@ public class EntitySentientSpecter extends EntityDemonBase
* Returns the volume for the sounds this mob makes.
*/
@Override
protected float getSoundVolume()
{
protected float getSoundVolume() {
return 0.4F;
}