Advertisement
robin4002

Untitled

Feb 12th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.09 KB | None | 0 0
  1. [code]package dofusMobs.Client;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.lwjgl.opengl.GL11;
  6.  
  7. import net.minecraft.entity.Entity;
  8. import net.minecraft.entity.EntityLivingBase;
  9. import net.minecraft.entity.SharedMonsterAttributes;
  10. import net.minecraft.entity.ai.EntityAISwimming;
  11. import net.minecraft.entity.ai.attributes.AttributeInstance;
  12. import net.minecraft.entity.ai.attributes.AttributeModifier;
  13. import net.minecraft.entity.monster.EntityMob;
  14. import net.minecraft.entity.player.EntityPlayer;
  15. import net.minecraft.nbt.NBTTagCompound;
  16. import net.minecraft.util.DamageSource;
  17. import net.minecraft.world.World;
  18.  
  19. public class EntityBouftonBlanc extends EntityMob
  20. {
  21.     int maxHp = (int) this.getMaxHealth(); //affiche les HP max du mob
  22.     int hp = (int) this.getHealth(); // affiche les PV actuelle du mob (ne s'actualise pas ><)
  23.     int mobLevel; //level du mob)
  24.    
  25.    
  26.     public String mobInfo = "Boufton Blanc"; // affiche le nom
  27.   public String infoHP = experienceValue + "/" + maxHp; // รงa c'est juste pour voire ^^
  28.     public String lvl ="Level "+ mobLevel; // affiche le level
  29.    
  30.    
  31.     public EntityBouftonBlanc(World par1World)
  32.     {
  33.        
  34.         super(par1World);  
  35.         this.tasks.addTask(1, new EntityAISwimming(this));
  36.                 mobLevel = this.worldObj.rand.nextInt(4) + 11; // Dit quelle level est le mob
  37.     }
  38.    
  39.  
  40.    
  41.     @Override
  42.      protected void applyEntityAttributes()
  43.      {
  44.  
  45.    
  46.         super.applyEntityAttributes();
  47.        
  48.          this.getEntityAttribute(SharedMonsterAttributes.followRange).setAttribute(1.0D);
  49.          this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.25D);
  50.         this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setAttribute(10000.0D);
  51.        
  52. if (mobLevel == 11)
  53. {
  54.     this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(8.0D);
  55.     this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(1.0D);
  56. }
  57. if (mobLevel == 12)
  58. {
  59.     this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(12.0D);
  60.     this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(1.5D);
  61. }
  62. if (mobLevel == 13)
  63. {
  64.     this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(14.0D);
  65.     this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(2.0D);
  66. }
  67. if (mobLevel == 14)
  68. {
  69.     this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(16.0D);
  70.     this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(2.0D);
  71. }
  72. if (mobLevel == 15)
  73. {
  74.     this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(18.0D);
  75.     this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(2.0D);
  76. }
  77. }
  78.        
  79.      public void writeEntityToNBT(NBTTagCompound nbtTag)
  80.      {
  81.      super.writeEntityToNBT(nbtTag);
  82.      nbtTag.setInteger("nom", mobLevel);
  83.      }
  84.  
  85.      public void readEntityFromNBT(NBTTagCompound nbtTag)
  86.      {
  87.      super.readEntityFromNBT(nbtTag);
  88.      mobLevel = nbtTag.getInteger("nom");
  89.      }
  90.  
  91.    
  92.      protected void attackEntity(Entity par1Entity, float par2)
  93.         {
  94.             if (this.attackTime <= 0 && par2 < 2.0F && par1Entity.boundingBox.maxY > this.boundingBox.minY && par1Entity.boundingBox.minY < this.boundingBox.maxY)
  95.             {
  96.                 this.attackTime = 30;
  97.                 this.attackEntityAsMob(par1Entity);
  98.             }
  99.         }
  100.    
  101.      public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
  102.    
  103.         {
  104.          
  105.            
  106.             if (this.isEntityInvulnerable())
  107.             {
  108.                 return false;
  109.             }
  110.             else if (super.attackEntityFrom(par1DamageSource, par2))
  111.             {
  112.                 Entity entity = par1DamageSource.getEntity();
  113.  
  114.                
  115.                 if (this.riddenByEntity != entity && this.ridingEntity != entity)
  116.                 {
  117.                     if (entity != this)
  118.                     {
  119.                         this.entityToAttack = entity;
  120.                        
  121.                     }
  122.  
  123.                     return true;
  124.                 }
  125.                 else
  126.                 {
  127.                     return true;
  128.                 }
  129.             }
  130.             else
  131.             {
  132.                  return false;
  133.             }
  134.         }
  135.  
  136.      
  137.      protected Entity findPlayerToAttack()
  138.         {
  139.             EntityPlayer entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, 0.0D);
  140.             return entityplayer != null && this.canEntityBeSeen(entityplayer) ? entityplayer : null;
  141.         }
  142.  
  143.      /**
  144.          * Returns the sound this mob makes while it's alive.
  145.          */
  146.         protected String getLivingSound(World world, int x, int y, int z)
  147.         {
  148.             return "dofusmobs:sound.bouftou_ambiant";  
  149.             }
  150.  
  151.         /**
  152.          * Returns the sound this mob makes when it is hurt.
  153.          */
  154.         protected String getHurtSound(World world, int x, int y, int z)
  155.         {
  156.            
  157.             return "dofusmobs:bouftou_prendcoup";  
  158.         }
  159.  
  160.         /**
  161.          * Returns the sound this mob makes on death.
  162.          * @return
  163.          */
  164.         protected String getDeathSound(World world, EntityPlayer player)
  165.         {
  166.             return "dofusmobs:bouftou_meurt";  
  167.         }
  168.        
  169.         protected String getAttackSound()
  170.         {
  171.        
  172.             return "dofusmobs:bouftou_attaque";  
  173.         }
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement