Creepinson

EntityCreepino

Apr 11th, 2017
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.10 KB | None | 0 0
  1. public static class EntityCreepino extends EntityMob implements IRangedAttackMob
  2. {
  3.  
  4.  
  5. private static final DataParameter<Integer> SPOT_COLOR = EntityDataManager.<Integer>createKey(EntitysheepGunner.class, DataSerializers.VARINT);
  6. private static final String[] TEXTURES = new String[] {"textures/entity/creepino/creepino_white.png", "textures/entity/creepino/creepino_red.png"};
  7. private final String[] TexturesArray = new String[3];
  8. private String texturePrefix;
  9. private static final String[] TEXTURES_ABBR = new String[] {"cw", "cr"};
  10.  
  11.  
  12. World world = null;
  13. public EntityCreepino(World var1)
  14. {
  15. super(var1);
  16. world = var1;
  17. experienceValue = 5;
  18. this.isImmuneToFire = false;
  19. addRandomArmor();
  20. setNoAI(!true);
  21.  
  22. this.tasks.addTask(0, new EntityAISwimming(this));
  23. this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
  24. this.tasks.addTask(8, new EntityAILookIdle(this));
  25. this.tasks.addTask(2, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
  26. this.tasks.addTask(3, new EntityAIAttackMelee(this, 1.0D, false));
  27. this.tasks.addTask(4, new EntityAILeapAtTarget(this, 0.8F));
  28. this.targetTasks.addTask(4, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
  29. this.targetTasks.addTask(6, new EntityAINearestAttackableTarget(this, EntityChicken.class, true));
  30. this.targetTasks.addTask(5, new EntityAIHurtByTarget(this, false));
  31. this.tasks.addTask(1, new EntityAILookIdle(this));
  32. this.tasks.addTask(1, new EntityAIWander(this, 0.8D));
  33. this.tasks.addTask(1, new EntityAIAttackRanged(this, 1.25D, 20, 10.0F));
  34.  
  35.  
  36. }
  37. public void setSpot(int variant)
  38. {
  39. this.dataManager.set(SPOT_COLOR, Integer.valueOf(variant));
  40. }
  41.  
  42. public int getSpot()
  43. {
  44. return ((Integer)this.dataManager.get(SPOT_COLOR)).intValue();
  45. }
  46.  
  47. protected void entityInit()
  48. {
  49. super.entityInit();
  50. this.dataManager.register(SPOT_COLOR, Integer.valueOf(0));
  51. }
  52. public void writeEntityToNBT(NBTTagCompound compound)
  53. {
  54. super.writeEntityToNBT(compound);
  55. compound.setInteger("Variant", this.getSpot());
  56. }
  57. public void readEntityFromNBT(NBTTagCompound compound)
  58. {
  59. super.readEntityFromNBT(compound);
  60. this.setSpot(compound.getInteger("Variant"));
  61. }
  62.  
  63. private void resetTexturePrefix()
  64. {
  65. this.texturePrefix = null;
  66. }
  67.  
  68. @SideOnly(Side.CLIENT)
  69. private void setTexturePaths()
  70. {
  71. int i = this.getSpot();
  72. int j = (i & 255) % 7;
  73. int k = ((i & 65280) >> 8) % 5;
  74.  
  75. this.TexturesArray[0] = TexturesArray[j];
  76. this.texturePrefix = "creepino/" + TEXTURES_ABBR[j] + TEXTURES[k];
  77.  
  78.  
  79.  
  80. }
  81.  
  82.  
  83. @SideOnly(Side.CLIENT)
  84. public String[] getVariantTexturePaths()
  85. {
  86. if (this.texturePrefix == null)
  87. {
  88. this.setTexturePaths();
  89. }
  90.  
  91. return this.TexturesArray;
  92. }
  93.  
  94. @SideOnly(Side.CLIENT)
  95. public String getTexture()
  96. {
  97. if (this.texturePrefix == null)
  98. {
  99. this.setTexturePaths();
  100. }
  101.  
  102. return this.texturePrefix;
  103. }
  104.  
  105.  
  106.  
  107. protected void applyEntityAttributes(){
  108. super.applyEntityAttributes();
  109. this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.15D);
  110. this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(12D);
  111. if(this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE)!=null)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(1.5D);
  112. }
  113.  
  114.  
  115. protected void addRandomArmor(){
  116.  
  117. }
  118.  
  119. public void onLivingUpdate() {
  120.  
  121. super.onLivingUpdate();
  122. World par1World = this.world;
  123. int par2 = (int) this.posX;
  124. int par3 = (int) this.posY;
  125. int par4 = (int) this.posZ;
  126. Random par5Random = this.rand;
  127. if(true)
  128. for (int l = 0; l < 6; ++l)
  129. {
  130. double d0 = (double)((float)par2 + par5Random.nextFloat());
  131. double d1 = (double)((float)par3 + par5Random.nextFloat());
  132. double d2 = (double)((float)par4 + par5Random.nextFloat());
  133. double d3 = 0.0D;
  134. double d4 = 0.0D;
  135. double d5 = 0.0D;
  136. int i1 = par5Random.nextInt(2) * 2 - 1;
  137. d3 = ((double)par5Random.nextFloat() - 0.5D) * 0.49999999850988386D;
  138. d4 = ((double)par5Random.nextFloat() - 0.5D) * 0.49999999850988386D;
  139. d5 = ((double)par5Random.nextFloat() - 0.5D) * 0.49999999850988386D;
  140. par1World.spawnParticle(EnumParticleTypes.SLIME, d0, d1, d2, d3, d4, d5);
  141. }
  142. }
  143.  
  144. public void attackEntityWithRangedAttack(EntityLivingBase target, float flval){
  145. EntityArrowCustom entityarrow = new EntityArrowCustom(this.world, this);
  146. double d0 = target.posY + (double)target.getEyeHeight() - 1.1;
  147. double d1 = target.posX - this.posX;
  148. double d2 = d0 - entityarrow.posY;
  149. double d3 = target.posZ - this.posZ;
  150. float f = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F;
  151. entityarrow.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F);
  152. this.world.spawnEntity(entityarrow);
  153. }
  154.  
  155.  
  156. @Override
  157. protected Item getDropItem()
  158. {
  159. return new ItemStack(ItemHandler.Essence, 3, 3).getItem();
  160. }
  161.  
  162. @Override
  163. protected net.minecraft.util.SoundEvent getAmbientSound()
  164. {
  165. return (net.minecraft.util.SoundEvent)net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("meepersplus:creepinoScreech"));
  166. }
  167.  
  168. @Override
  169. protected net.minecraft.util.SoundEvent getHurtSound()
  170. {
  171. return (net.minecraft.util.SoundEvent)net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("meepersplus:creepinoHurt"));
  172. }
  173.  
  174. @Override
  175. protected net.minecraft.util.SoundEvent getDeathSound()
  176. {
  177. return (net.minecraft.util.SoundEvent)net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("meepersplus:creepinoDeath"));
  178. }
  179.  
  180. @Override
  181. public void onStruckByLightning(EntityLightningBolt entityLightningBolt){
  182. super.onStruckByLightning(entityLightningBolt);
  183. int i = (int)this.posX;
  184. int j = (int)this.posY;
  185. int k = (int)this.posZ;
  186. Entity entity = this;
  187.  
  188. j += 1;
  189.  
  190. entity.motionY += 0.5;
  191.  
  192. entity.setFire(1);
  193.  
  194.  
  195.  
  196.  
  197. }
  198.  
  199.  
  200. @Override
  201. public void fall(float l, float d){
  202. super.fall(l,d);
  203. int i = (int)this.posX;
  204. int j = (int)this.posY;
  205. int k = (int)this.posZ;
  206. super.fall(l,d);
  207. Entity entity = this;
  208.  
  209. }
  210.  
  211. @Override
  212. public void onDeath(DamageSource source){
  213. super.onDeath(source);
  214. int i = (int)this.posX;
  215. int j = (int)this.posY;
  216. int k = (int)this.posZ;
  217. Entity entity = this;
  218.  
  219.  
  220. }
  221. @Override
  222. protected boolean processInteract(EntityPlayer entity, EnumHand hand) {
  223. super.processInteract(entity,hand);
  224. int i = (int)this.posX;
  225. int j = (int)this.posY;
  226. int k = (int)this.posZ;
  227.  
  228.  
  229. return true;
  230. }
  231.  
  232.  
  233. @Override
  234. protected float getSoundVolume()
  235. {
  236. return 1.0F;
  237. }
  238.  
  239. }
Advertisement
Add Comment
Please, Sign In to add comment