Advertisement
Guest User

Untitled

a guest
May 5th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.53 KB | None | 0 0
  1. package dpmod3rdimpact;
  2.  
  3. import net.minecraft.entity.Entity;
  4. import net.minecraft.entity.EntityLiving;
  5. import net.minecraft.entity.EnumCreatureAttribute;
  6. import net.minecraft.entity.ai.EntityAIAttackOnCollide;
  7. import net.minecraft.entity.ai.EntityAIBreakDoor;
  8. import net.minecraft.entity.ai.EntityAIHurtByTarget;
  9. import net.minecraft.entity.ai.EntityAILookIdle;
  10. import net.minecraft.entity.ai.EntityAIMoveThroughVillage;
  11. import net.minecraft.entity.ai.EntityAIMoveTwardsRestriction;
  12. import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
  13. import net.minecraft.entity.ai.EntityAISwimming;
  14. import net.minecraft.entity.ai.EntityAIWander;
  15. import net.minecraft.entity.ai.EntityAIWatchClosest;
  16. import net.minecraft.entity.boss.IBossDisplayData;
  17. import net.minecraft.entity.item.EntityXPOrb;
  18. import net.minecraft.entity.monster.EntityCreeper;
  19. import net.minecraft.entity.monster.EntityMob;
  20. import net.minecraft.entity.passive.EntityVillager;
  21. import net.minecraft.entity.player.EntityPlayer;
  22. import net.minecraft.item.Item;
  23. import net.minecraft.potion.Potion;
  24. import net.minecraft.potion.PotionEffect;
  25. import net.minecraft.src.ModLoader;
  26. import net.minecraft.util.MathHelper;
  27. import net.minecraft.world.World;
  28.  
  29. public class EntityMobName extends EntityMob
  30. {
  31.     public EntityMobName(World par1World)
  32.     {
  33.         super(par1World);
  34.         this.texture = "/MobName.png";
  35.         this.moveSpeed = 0.30F;
  36.         this.experienceValue = 1000;  
  37.         this.isImmuneToFire = true;
  38.         this.setSize(this.width * 3.0F, this.height * 3.0F);
  39.         this.getNavigator().setBreakDoors(true);
  40.         this.tasks.addTask(0, new EntityAISwimming(this));
  41.         this.tasks.addTask(1, new EntityAIBreakDoor(this));
  42.         this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, this.moveSpeed, false));
  43.         this.tasks.addTask(3, new EntityAIAttackOnCollide(this, EntityVillager.class, this.moveSpeed, true));
  44.         this.tasks.addTask(4, new EntityAIMoveTwardsRestriction(this, this.moveSpeed));
  45.         this.tasks.addTask(5, new EntityAIMoveThroughVillage(this, this.moveSpeed, false));
  46.         this.tasks.addTask(6, new EntityAIWander(this, this.moveSpeed));
  47.         this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
  48.         this.tasks.addTask(7, new EntityAILookIdle(this));
  49.         this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
  50.         this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 16.0F, 0, true));
  51.         this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, 16.0F, 0, false));
  52.         this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityCreeper.class, 16.0F, 0, false));
  53.     }
  54.  
  55.     public int getMaxHealth()
  56.     {
  57.         return 800;
  58.     }
  59.  
  60.     protected void onDeathUpdate(EntityPlayer EntityPlayer)
  61.     {      
  62.     ModLoader.openGUI(EntityPlayer, new GuiDefeatMobName());
  63.     this.setDead();
  64.     }
  65.    
  66.     /**
  67.      * Returns the current armor value as determined by a call to InventoryPlayer.getTotalArmorValue
  68.      */
  69.     public int getTotalArmorValue()
  70.     {
  71.         return 2;
  72.     }
  73.     /**
  74.      * Returns true if the newer Entity AI code should be run
  75.      */
  76.     protected boolean isAIEnabled()
  77.     {
  78.         return true;
  79.     }
  80.  
  81.     /**
  82.      * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
  83.      * use this to react to sunlight and start to burn.
  84.  
  85.     /**
  86.      * Returns the sound this mob makes while it's alive.
  87.      */
  88.     protected String getLivingSound()
  89.     {
  90.         return "";
  91.     }
  92.  
  93.     /**
  94.      * Returns the sound this mob makes when it is hurt.
  95.      */
  96.     protected String getHurtSound()
  97.     {
  98.         return "";
  99.     }
  100.  
  101.     /**
  102.      * Returns the sound this mob makes on death.
  103.      */
  104.     protected String getDeathSound()
  105.     {
  106.         return "";
  107.     }
  108.     @Override
  109.     public void onLivingUpdate()
  110.     {
  111.         if (this.health == 0)
  112.         {
  113.             ModLoader.openGUI(attackingPlayer, new GuiDefeatMobName());
  114.         }  
  115.    
  116.     }
  117.  
  118.     /**
  119.      * Returns the item ID for the item the mob drops on death.
  120.      */
  121.     /**
  122.      * Get this Entity's EnumCreatureAttribute
  123.      */
  124.     public EnumCreatureAttribute getCreatureAttribute()
  125.     {
  126.         return EnumCreatureAttribute.UNDEAD;
  127.     }
  128.     public int getAttackStrength(Entity par1Entity)
  129.     {
  130.         return 8;
  131.     }
  132.     public int getDragonHealth() {
  133.         return this.dataWatcher.getWatchableObjectInt(16);
  134.     }
  135.     public String getEntityName()
  136.     {
  137.       return "MobName";
  138.     }
  139.      public boolean attackEntityAsMob(Entity entity)
  140.         {
  141.             if (super.attackEntityAsMob(entity))
  142.             {
  143.                 if (entity instanceof EntityLiving)
  144.                 {
  145.                     byte byte0 = 0;
  146.  
  147.                     if (worldObj.difficultySetting > 1)
  148.                     {
  149.                         if (worldObj.difficultySetting == 2)
  150.                         {
  151.                             byte0 = 7;
  152.                         }
  153.                         else if (worldObj.difficultySetting == 3)
  154.                         {
  155.                             byte0 = 15;
  156.                         }
  157.                     }
  158.  
  159.                     if (byte0 > 0)
  160.                     {
  161.                         ((EntityLiving)entity).addPotionEffect(new PotionEffect(Potion.weakness.id, byte0 * 20, 0));
  162.                     }
  163.                 }
  164.  
  165.                 return true;
  166.             }
  167.             else
  168.             {
  169.                 return false;
  170.             }
  171.         }
  172.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement