Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.64 KB | None | 0 0
  1. public class EntityDataSwordman extends EntityDataGeneric {
  2.  
  3.     public EntityDataSwordman(World world) {
  4.         super(world);
  5.        
  6.         Minecraft.getMinecraft().thePlayer.sendChatMessage("Constructing swordman at World#isRemote:" + world.isRemote);
  7.        
  8.         // this.tasks.addTask(0, new EntityAISwimming(this));
  9.         this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityMob.class, 1, true));
  10.         this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 1.0D, true));
  11.         // this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
  12.         // this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityMob.class, 8.0F));
  13.         // this.tasks.addTask(8, new EntityAILookIdle(this));
  14.        
  15.         this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
  16.         this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityMob.class, 0, true));
  17.        
  18.         this.setCurrentItemOrArmor(0, new ItemStack(Items.iron_sword));
  19.        
  20.         this.setCustomNameTag("Data Swordsman");
  21.         this.setAlwaysRenderNameTag(true);
  22.        
  23.         this.getNavigator().setAvoidsWater(true);
  24.        
  25.         this.setEntityProperties();
  26.     }
  27.    
  28.     @Override
  29.     protected void setEntityProperties() {
  30.        
  31.     }
  32.    
  33.     @Override
  34.     public void applyEntityAttributes() {
  35.         super.applyEntityAttributes();
  36.        
  37.         this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
  38.         this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
  39.         this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(5);
  40.         this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20);
  41.         this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1);
  42.     }
  43.    
  44.     @Override
  45.     public void entityInit() {
  46.         super.entityInit();
  47.     }
  48.    
  49.     @Override
  50.     public void readEntityFromNBT(NBTTagCompound p_70037_1_) {
  51.         // TODO Auto-generated method stub
  52.         super.readEntityFromNBT(p_70037_1_);
  53.     }
  54.  
  55.     @Override
  56.     public void writeEntityToNBT(NBTTagCompound p_70014_1_) {
  57.         // TODO Auto-generated method stub
  58.         super.writeEntityToNBT(p_70014_1_);
  59.     }
  60.    
  61.     @Override
  62.     public boolean attackEntityAsMob(Entity entityTarget) {
  63.         float attackDamage = EntityProperties.getEntityAttackDamage(this);
  64.         int knockbackModifier = 0;
  65.         boolean isTargetHurt = false;
  66.         EntityLivingBase entity;
  67.        
  68.         this.worldObj.setEntityState(this, (byte) 4);
  69.        
  70.         if (entityTarget instanceof EntityLivingBase) {
  71.             entity = (EntityLivingBase) entityTarget;
  72.             attackDamage += EnchantmentHelper.getEnchantmentModifierLiving(this, entity);
  73.             knockbackModifier  += EnchantmentHelper.getKnockbackModifier(this, entity);
  74.             EnchantmentHelper.func_151384_a(entity, this);
  75.            
  76.             isTargetHurt = entityTarget.attackEntityFrom(DamageSource.causeMobDamage(this), attackDamage);
  77.            
  78.             if (isTargetHurt) {
  79.                 if (knockbackModifier  > 0) {
  80.                     entityTarget.addVelocity((double)(-MathHelper.sin(rotationYaw *
  81.                           (float)Math.PI / 180.0F) * (float)knockbackModifier  * 0.5F),
  82.                            0.1D, (double)(MathHelper.cos(rotationYaw *
  83.                           (float)Math.PI / 180.0F) * (float)knockbackModifier  * 0.5F));
  84.                     motionX *= 0.6D;
  85.                     motionZ *= 0.6D;
  86.                 }
  87.  
  88.                 int fireModifier = EnchantmentHelper.getFireAspectModifier(this);
  89.  
  90.                 if (fireModifier > 0)
  91.                 {
  92.                     entityTarget.setFire(fireModifier * 4);
  93.                 }
  94.  
  95.                 EnchantmentHelper.func_151385_b(this, entityTarget);
  96.             }
  97.            
  98.         }
  99.         return isTargetHurt;
  100.     }
  101.    
  102.     @Override
  103.     public boolean canDespawn() {
  104.         return false;
  105.     }
  106.  
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement