Guest User

Untitled

a guest
Apr 10th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.93 KB | None | 0 0
  1. package com.turtledove.necropolisofnostalgia.server.entity.Spiral_Draco;
  2.  
  3. import com.turtledove.necropolisofnostalgia.server.entity.NecropolisEntity;
  4. import com.turtledove.necropolisofnostalgia.server.entity.NecropolisMultiPart;
  5. import com.turtledove.necropolisofnostalgia.server.ai.NecropolisPathNavigateGround;
  6. import com.turtledove.necropolisofnostalgia.server.ai.Spiral_DracoChargeTargetAI;
  7.  
  8. import javax.annotation.Nullable;
  9. import net.minecraft.entity.*;
  10. import net.minecraft.entity.ai.*;
  11. import net.minecraft.entity.monster.EntityIronGolem;
  12. import net.minecraft.entity.monster.EntitySpider;
  13. import net.minecraft.entity.player.EntityPlayer;
  14. import net.minecraft.init.SoundEvents;
  15. import net.minecraft.nbt.NBTTagCompound;
  16. import net.minecraft.network.datasync.DataParameter;
  17. import net.minecraft.potion.PotionEffect;
  18. import net.minecraft.util.*;
  19. import net.minecraft.pathfinding.PathNavigate;
  20. import net.minecraft.util.DamageSource;
  21. import net.minecraft.world.World;
  22. import net.minecraft.network.datasync.EntityDataManager;
  23. import net.minecraft.network.datasync.DataSerializers;
  24. import net.minecraft.world.storage.loot.LootTableList;
  25. import org.apache.logging.log4j.LogManager;
  26. import org.apache.logging.log4j.Logger;
  27. import java.util.List;
  28.  
  29. import net.ilexiconn.llibrary.server.entity.multipart.IMultipartEntity;
  30.  
  31.  
  32. public class EntitySpiral_Draco extends EntityCreature implements IMultipartEntity
  33. {
  34. private static final Logger LOGGER = LogManager.getLogger();
  35. /** An array containing all body parts */
  36. public NecropolisMultiPart[] spiral_dracoPartArray;
  37.  
  38. /** The bounding box of the draco */
  39. public NecropolisMultiPart spiral_dracoPartFRLeg = new NecropolisMultiPart(this, 2F, -45, 0.0F, 1F, 4F, 0.5F);
  40. public NecropolisMultiPart spiral_dracoPartFLLeg = new NecropolisMultiPart(this, 2F, 45, 0.0F, 1F, 4F, 0.5F);
  41. public double[][] ringBuffer = new double[64][3];
  42. public int ringBufferIndex = -1;
  43. private boolean isModelDead;
  44. private static final DataParameter<Boolean> MODEL_DEAD = EntityDataManager.createKey(EntitySpiral_Draco.class, DataSerializers.BOOLEAN);
  45.  
  46. public EntitySpiral_Draco(World worldIn)
  47. {
  48. super(worldIn);
  49. this.spiral_dracoPartArray = new NecropolisMultiPart[] {this.spiral_dracoPartFRLeg,this.spiral_dracoPartFLLeg};
  50. this.setHealth(this.getMaxHealth());
  51. this.setSize(0.25F, 0.25F);
  52. this.noClip = false;
  53. this.isImmuneToFire = true;
  54. this.ignoreFrustumCheck = true;
  55. }
  56.  
  57. protected void initEntityAI()
  58. {
  59. this.tasks.addTask(2, new Spiral_DracoChargeTargetAI(this, EntityPlayer.class, 50.0F, 0.4F));
  60. this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0]));
  61. this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
  62. }
  63.  
  64. protected void applyEntityAttributes()
  65. {
  66. super.applyEntityAttributes();
  67. this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(200.0D);
  68. }
  69.  
  70. protected void entityInit()
  71. {
  72. super.entityInit();
  73. }
  74.  
  75. public void onUpdate()
  76. {
  77. super.onUpdate();
  78. updateParts();
  79. if (this.world.isRemote)
  80. {
  81. this.setHealth(this.getHealth());
  82. }
  83. if (this.getHealth() <= 0.0F)
  84. {
  85. float f12 = (this.rand.nextFloat() - 0.5F) * 8.0F;
  86. float f13 = (this.rand.nextFloat() - 0.5F) * 4.0F;
  87. float f15 = (this.rand.nextFloat() - 0.5F) * 8.0F;
  88. this.world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX + (double)f12, this.posY + 2.0D + (double)f13, this.posZ + (double)f15, 0.0D, 0.0D, 0.0D);
  89. }
  90. else
  91. {
  92. if (!this.world.isRemote && this.hurtTime == 0)
  93. {
  94. this.collideWithEntities(this.world.getEntitiesWithinAABBExcludingEntity(this, this.spiral_dracoPartFRLeg.getEntityBoundingBox().grow(1.0D)));
  95. this.collideWithEntities(this.world.getEntitiesWithinAABBExcludingEntity(this, this.spiral_dracoPartFLLeg.getEntityBoundingBox().grow(1.0D)));
  96. }
  97. }
  98. }
  99.  
  100. public void updateParts()
  101. {
  102. if (spiral_dracoPartFRLeg != null)
  103. {
  104. spiral_dracoPartFRLeg.onUpdate();
  105. }
  106. if (spiral_dracoPartFLLeg != null)
  107. {
  108. spiral_dracoPartFLLeg.onUpdate();
  109. }
  110. }
  111.  
  112. /**
  113. * Pushes all entities inside the list away from the enderdragon.
  114. */
  115. private void collideWithEntities(List<Entity> p_70970_1_)
  116. {
  117. double FR_leg_1 = (this.spiral_dracoPartFRLeg.getEntityBoundingBox().minX + this.spiral_dracoPartFRLeg.getEntityBoundingBox().maxX) / 2.0D;
  118. double FR_leg_2 = (this.spiral_dracoPartFRLeg.getEntityBoundingBox().minZ + this.spiral_dracoPartFRLeg.getEntityBoundingBox().maxZ) / 2.0D;
  119.  
  120. double FL_leg_1 = (this.spiral_dracoPartFLLeg.getEntityBoundingBox().minX + this.spiral_dracoPartFLLeg.getEntityBoundingBox().maxX) / 2.0D;
  121. double FL_leg_2 = (this.spiral_dracoPartFLLeg.getEntityBoundingBox().minZ + this.spiral_dracoPartFLLeg.getEntityBoundingBox().maxZ) / 2.0D;
  122.  
  123. for (Entity entity : p_70970_1_)
  124. {
  125. if (entity instanceof EntityLivingBase)
  126. {
  127. double d2 = entity.posX - FR_leg_1;
  128. double d3 = entity.posZ - FR_leg_2;
  129. double d4 = d2 * d2 + d3 * d3;
  130. entity.addVelocity(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D);
  131.  
  132. entity.attackEntityFrom(DamageSource.causeMobDamage(this), 10.0F);
  133. }
  134. }
  135.  
  136. for (Entity entity : p_70970_1_)
  137. {
  138. if (entity instanceof EntityLivingBase)
  139. {
  140. double d2 = entity.posX - FL_leg_1;
  141. double d3 = entity.posZ - FL_leg_2;
  142. double d4 = d2 * d2 + d3 * d3;
  143. entity.addVelocity(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D);
  144. entity.attackEntityFrom(DamageSource.causeMobDamage(this), 5.0F);
  145. }
  146. }
  147. }
  148.  
  149. /**
  150. * Called when the entity is attacked.
  151. */
  152. public boolean attackEntityFrom(DamageSource source, float amount)
  153. {
  154. if (source.getTrueSource() instanceof EntityPlayer)
  155. {
  156. return super.attackEntityFrom(source, amount);
  157. }
  158. return false;
  159. }
  160.  
  161. /**
  162. * Called by the /kill command.
  163. */
  164. public void onKillCommand()
  165. {
  166. this.setDead();
  167. }
  168.  
  169. /**
  170. * (abstract) Protected helper method to write subclass entity data to NBT.
  171. */
  172. public void writeEntityToNBT(NBTTagCompound compound)
  173. {
  174. super.writeEntityToNBT(compound);
  175. }
  176.  
  177. /**
  178. * (abstract) Protected helper method to read subclass entity data from NBT.
  179. */
  180. public void readEntityFromNBT(NBTTagCompound compound)
  181. {
  182. super.readEntityFromNBT(compound);
  183. }
  184.  
  185. /**
  186. * Makes the entity despawn if requirements are reached
  187. */
  188. protected void despawnEntity()
  189. {
  190. }
  191.  
  192. /**
  193. * Return the Entity parts making up this Entity (currently only for dragons)
  194. */
  195. public Entity[] getParts()
  196. {
  197. return this.spiral_dracoPartArray;
  198. }
  199.  
  200. /**
  201. * Returns true if other Entities should be prevented from moving through this Entity.
  202. */
  203. public boolean canBeCollidedWith()
  204. {
  205. return false;
  206. }
  207.  
  208. public World getWorld()
  209. {
  210. return this.world;
  211. }
  212.  
  213. public SoundCategory getSoundCategory()
  214. {
  215. return SoundCategory.HOSTILE;
  216. }
  217.  
  218. protected SoundEvent getAmbientSound()
  219. {
  220. return SoundEvents.ENTITY_ENDERDRAGON_AMBIENT;
  221. }
  222.  
  223. protected SoundEvent getHurtSound(DamageSource damageSourceIn)
  224. {
  225. return SoundEvents.ENTITY_ENDERDRAGON_HURT;
  226. }
  227.  
  228. /**
  229. * Returns the volume for the sounds this mob makes.
  230. */
  231. protected float getSoundVolume()
  232. {
  233. return 5.0F;
  234. }
  235.  
  236. @Nullable
  237. protected ResourceLocation getLootTable()
  238. {
  239. return LootTableList.ENTITIES_ENDER_DRAGON;
  240. }
  241.  
  242. public void notifyDataManagerChange(DataParameter<?> key)
  243. {
  244. super.notifyDataManagerChange(key);
  245. }
  246.  
  247. /**
  248. * adds a PotionEffect to the entity
  249. */
  250. public void addPotionEffect(PotionEffect potioneffectIn)
  251. {
  252. }
  253.  
  254. protected boolean canBeRidden(Entity entityIn)
  255. {
  256. return false;
  257. }
  258.  
  259. /**
  260. * Returns false if this Entity is a boss, true otherwise.
  261. */
  262. public boolean isNonBoss()
  263. {
  264. return false;
  265. }
  266. public boolean isModelDead()
  267. {
  268. if (world.isRemote) {
  269. return this.isModelDead = Boolean.valueOf(this.dataManager.get(MODEL_DEAD).booleanValue());
  270. }
  271. return isModelDead;
  272. }
  273. public float getEyeHeight()
  274. {
  275. return 0.65F;
  276. }
  277. }
Advertisement
Add Comment
Please, Sign In to add comment