-
-
Save Tenyar97/821e2f97207d46af3b43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package assets.betterdefense.entity; | |
import java.util.UUID; | |
import net.minecraft.enchantment.EnchantmentHelper; | |
import net.minecraft.entity.Entity; | |
import net.minecraft.entity.EntityLiving; | |
import net.minecraft.entity.EnumCreatureAttribute; | |
import net.minecraft.entity.SharedMonsterAttributes; | |
import net.minecraft.entity.ai.EntityAIAttackOnCollide; | |
import net.minecraft.entity.ai.EntityAIFleeSun; | |
import net.minecraft.entity.ai.EntityAIHurtByTarget; | |
import net.minecraft.entity.ai.EntityAILookIdle; | |
import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; | |
import net.minecraft.entity.ai.EntityAINearestAttackableTarget; | |
import net.minecraft.entity.ai.EntityAIRestrictSun; | |
import net.minecraft.entity.ai.EntityAISwimming; | |
import net.minecraft.entity.ai.EntityAITempt; | |
import net.minecraft.entity.ai.EntityAIWander; | |
import net.minecraft.entity.ai.EntityAIWatchClosest; | |
import net.minecraft.entity.ai.attributes.AttributeModifier; | |
import net.minecraft.entity.monster.EntityMob; | |
import net.minecraft.entity.passive.EntityVillager; | |
import net.minecraft.entity.player.EntityPlayer; | |
import net.minecraft.item.Item; | |
import net.minecraft.item.ItemStack; | |
import net.minecraft.util.DamageSource; | |
import net.minecraft.util.MathHelper; | |
import net.minecraft.util.ResourceLocation; | |
import net.minecraft.world.World; | |
import assets.betterdefense.common.BetterDefense; | |
public class EntityWalker extends EntityMob | |
{ | |
int tickExisted; | |
public EntityWalker(World par1World) | |
{ | |
super(par1World); | |
this.isImmuneToFire = true; | |
this.canBreatheUnderwater(); | |
this.stepHeight = 3F; | |
this.tasks.addTask(0, new EntityAISwimming(this)); | |
this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1D, false)); | |
this.tasks.addTask(3, new EntityAIAttackOnCollide(this, EntityVillager.class, 1D, true)); | |
this.tasks.addTask(6, new EntityAIWander(this, 1D)); | |
this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 4.0F)); | |
this.tasks.addTask(7, new EntityAILookIdle(this)); | |
this.tasks.addTask(9, new EntityAIMoveTowardsRestriction(this, 1.0D)); | |
this.tasks.addTask(10, new EntityAIRestrictSun(this)); | |
this.tasks.addTask(11, new EntityAIFleeSun(this, 1.0D)); | |
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); | |
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); | |
} | |
protected void applyEntityAttributes() | |
{ | |
super.applyEntityAttributes(); | |
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(20.0D); | |
this.getEntityAttribute(SharedMonsterAttributes.followRange).setAttribute(45.0D); | |
this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setAttribute(0.7D); | |
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.25D); | |
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(3.5D); | |
} | |
public boolean canBreatheUnderwater() | |
{ | |
return true; | |
} | |
public boolean attackEntityFrom(DamageSource par1DamageSource, int par2) | |
{ | |
if (par1DamageSource.isFireDamage()) | |
{ | |
par2 = 0; | |
} | |
if (super.attackEntityFrom(par1DamageSource, par2)) | |
{ | |
if (par1DamageSource.getEntity() != null) | |
{ | |
Entity par1Entity = par1DamageSource.getEntity(); | |
int j = 0; | |
if (par1Entity instanceof EntityLiving) | |
{ | |
j += EnchantmentHelper.getKnockbackModifier((EntityLiving) par1Entity, this); | |
if (j > 0) | |
{ | |
this.motionX /= 0.6D; | |
this.motionZ /= 0.6D; | |
this.addVelocity((double) (MathHelper.sin(par1Entity.rotationYaw * (float) Math.PI / 180.0F) * (float) j * 0.5F), -0.1D, | |
(double) (-MathHelper.cos(par1Entity.rotationYaw * (float) Math.PI / 180.0F) * (float) j * 0.5F)); | |
} | |
} | |
} | |
} | |
return false; | |
} | |
public void initCreature() | |
{ | |
if (this.worldObj.rand.nextInt(100) == 0) | |
{ | |
this.setCurrentItemOrArmor(1, new ItemStack(BetterDefense.Boots)); | |
} | |
for (int i = 0; i < this.equipmentDropChances.length; ++i) | |
{ | |
this.equipmentDropChances[i] = 0F; | |
} | |
} | |
protected boolean isAIEnabled() | |
{ | |
return true; | |
} | |
public void onLivingUpdate() | |
{ | |
super.onLivingUpdate(); | |
} | |
@Override | |
public void onUpdate() | |
{ | |
tickExisted++; | |
if(tickExisted < 6000) | |
{ | |
if (this.rand.nextInt(50000) == 0) | |
{ | |
EntityBabyWalker entitybabywalker = new EntityBabyWalker(this.worldObj); | |
entitybabywalker.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); | |
this.worldObj.spawnEntityInWorld(entitybabywalker); | |
} | |
} | |
} | |
/** | |
* Returns the sound this mob makes while it's alive. | |
*/ | |
protected String getLivingSound() | |
{ | |
return "mob.zombie.say"; | |
} | |
/** | |
* Returns the sound this mob makes when it is hurt. | |
*/ | |
protected String getHurtSound() | |
{ | |
return "mob.zombie.hurt"; | |
} | |
/** | |
* Returns the sound this mob makes on death. | |
*/ | |
protected String getDeathSound() | |
{ | |
return "mob.zombie.death"; | |
} | |
/** | |
* Plays step sound at given x, y, z for the entity | |
*/ | |
protected void playStepSound(int par1, int par2, int par3, int par4) | |
{ | |
this.playSound("mob.zombie.step", 0.15F, 1.0F); | |
} | |
/** | |
* Returns the item ID for the item the mob drops on death. | |
*/ | |
protected int getDropItemId() | |
{ | |
return Item.rottenFlesh.itemID; | |
} | |
/** | |
* Get this Entity's EnumCreatureAttribute | |
*/ | |
public EnumCreatureAttribute getCreatureAttribute() | |
{ | |
return EnumCreatureAttribute.UNDEAD; | |
} | |
protected void dropRareDrop(int par1) | |
{ | |
switch (this.rand.nextInt(3)) | |
{ | |
case 0: | |
this.dropItem(Item.diamond.itemID, 1); | |
break; | |
case 1: | |
this.dropItem(BetterDefense.HISword.itemID, 1); | |
break; | |
case 2: | |
this.dropItem(Item.ingotIron.itemID, 1); | |
} | |
} | |
/* | |
public boolean interact(EntityPlayer par1EntityPlayer) | |
{ | |
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); | |
{ | |
if (itemstack != null && itemstack.itemID == Item.ingotGold.itemID) | |
{ | |
if (!par1EntityPlayer.capabilities.isCreativeMode) | |
{ | |
--itemstack.stackSize; | |
} | |
if (itemstack.stackSize <= 0) | |
{ | |
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null); | |
} | |
if (!this.worldObj.isRemote) | |
{ | |
if (this.rand.nextInt(3) == 0) | |
{ | |
EntityBabyWalker entitybabywalker = new EntityBabyWalker(this.worldObj); | |
entitybabywalker.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); | |
this.worldObj.spawnEntityInWorld(entitybabywalker); | |
} | |
if (this.rand.nextInt(20) == 0) | |
{ | |
EntityWalker entitywalker = new EntityWalker(this.worldObj); | |
entitywalker.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); | |
this.worldObj.spawnEntityInWorld(entitywalker); | |
this.worldObj.spawnEntityInWorld(entitywalker); | |
} | |
} | |
return true; | |
} | |
} | |
return super.interact(par1EntityPlayer); | |
} | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment