Advertisement
Guest User

CGhast

a guest
Mar 7th, 2015
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.11 KB | None | 0 0
  1. package nl.SkyWars.Arena.Others.CustomEntities;
  2.  
  3. import net.minecraft.server.v1_7_R4.*;
  4. import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
  5. import org.bukkit.event.entity.EntityTargetEvent;
  6.  
  7. import java.lang.reflect.Field;
  8.  
  9. /**
  10. * Created by Nuno on 07-03-2015.
  11. */
  12. public class CGhast extends EntityGhast {
  13. public CGhast(World w){
  14. super(w);
  15. }
  16. protected void bq()
  17. {
  18. Entity target1 = null;
  19. int explosionpower = 0,br=0;
  20. Class c = this.getClass();
  21. try {
  22. Field f = c.getDeclaredField("target");
  23. f.setAccessible(true);
  24. target1 =(Entity) f.get(c);
  25. Field f2 = c.getDeclaredField("explosionPower");
  26. f2.setAccessible(true);
  27. explosionpower = (Integer)f.get(c);
  28. Field f3 = c.getDeclaredField("br");
  29. f3.setAccessible(true);
  30. br=(Integer)f3.get(c);
  31. }catch(NoSuchFieldException e){
  32. e.printStackTrace();
  33. }catch(IllegalAccessException e){
  34. e.printStackTrace();
  35. }
  36. if ((!this.world.isStatic) && (this.world.difficulty == EnumDifficulty.PEACEFUL)) {
  37. die();
  38. }
  39. w();
  40. this.bo = this.bp;
  41. double d0 = this.i - this.locX;
  42. double d1 = this.bm - this.locY;
  43. double d2 = this.bn - this.locZ;
  44. double d3 = d0 * d0 + d1 * d1 + d2 * d2;
  45. if ((d3 < 1.0D) || (d3 > 3600.0D))
  46. {
  47. this.i = (this.locX + (this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
  48. this.bm = (this.locY + (this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
  49. this.bn = (this.locZ + (this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
  50. }
  51. if (this.h-- <= 0)
  52. {
  53. this.h += this.random.nextInt(5) + 2;
  54. d3 = MathHelper.sqrt(d3);
  55. if (a(this.i, this.bm, this.bn, d3))
  56. {
  57. this.motX += d0 / d3 * 0.1D;
  58. this.motY += d1 / d3 * 0.1D;
  59. this.motZ += d2 / d3 * 0.1D;
  60. }
  61. else
  62. {
  63. this.i = this.locX;
  64. this.bm = this.locY;
  65. this.bn = this.locZ;
  66. }
  67. }
  68. if ((target1 != null) && (target1.dead))
  69. {
  70. EntityTargetEvent event = new EntityTargetEvent(getBukkitEntity(), null, EntityTargetEvent.TargetReason.TARGET_DIED);
  71. this.world.getServer().getPluginManager().callEvent(event);
  72. if (!event.isCancelled()) {
  73. if (event.getTarget() == null) {
  74. target1 = null;
  75. } else {
  76. target1 = ((CraftEntity)event.getTarget()).getHandle();
  77. }
  78. }
  79. }
  80. if ((target1 == null) || (br-- <= 0))
  81. {
  82. Entity target = this.world.findNearbyVulnerablePlayer(this, 100.0D);
  83. if (target != null)
  84. {
  85. EntityTargetEvent event = new EntityTargetEvent(getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
  86. this.world.getServer().getPluginManager().callEvent(event);
  87. if (!event.isCancelled()) {
  88. if (event.getTarget() == null) {
  89. target1 = null;
  90. } else {
  91. target1 = ((CraftEntity)event.getTarget()).getHandle();
  92. }
  93. }
  94. }
  95. if (target1 != null) {
  96. br = 20;
  97. }
  98. }
  99. double d4 = 64.0D;
  100. if ((target1 != null) && (target1.f(this) < d4 * d4))
  101. {
  102. double d5 = target1.locX - this.locX;
  103. double d6 = target1.boundingBox.b + target1.length / 2.0F - (this.locY + this.length / 2.0F);
  104. double d7 = target1.locZ - this.locZ;
  105.  
  106. this.aM = (this.yaw = -(float)Math.atan2(d5, d7) * 180.0F / 3.1415927F);
  107. if (hasLineOfSight(target1))
  108. {
  109. if (this.bp == 10) {
  110. this.world.a((EntityHuman)null, 1007, (int)this.locX, (int)this.locY, (int)this.locZ, 0);
  111. }
  112. this.bp += 1;
  113. if (this.bp == 20)
  114. {
  115. this.world.a((EntityHuman)null, 1008, (int)this.locX, (int)this.locY, (int)this.locZ, 0);
  116. CFireball entitylargefireball = new CFireball(this.world);
  117.  
  118.  
  119. entitylargefireball.bukkitYield = (entitylargefireball.yield = explosionpower);
  120. double d8 = 4.0D;
  121. Vec3D vec3d = j(1.0F);
  122.  
  123. entitylargefireball.locX = (this.locX + vec3d.a * d8);
  124. entitylargefireball.locY = (this.locY + this.length / 2.0F + 0.5D);
  125. entitylargefireball.locZ = (this.locZ + vec3d.c * d8);
  126. this.world.addEntity(entitylargefireball);
  127. this.bp = -40;
  128. }
  129. }
  130. else if (this.bp > 0)
  131. {
  132. this.bp -= 1;
  133. }
  134. }
  135. else
  136. {
  137. this.aM = (this.yaw = -(float)Math.atan2(this.motX, this.motZ) * 180.0F / 3.1415927F);
  138. if (this.bp > 0) {
  139. this.bp -= 1;
  140. }
  141. }
  142. if (!this.world.isStatic)
  143. {
  144. byte b0 = this.datawatcher.getByte(16);
  145. byte b1 = (byte)(this.bp > 10 ? 1 : 0);
  146. if (b0 != b1) {
  147. this.datawatcher.watch(16, Byte.valueOf(b1));
  148. }
  149. }
  150. try {
  151. Field f = c.getDeclaredField("target");
  152. f.setAccessible(true);
  153. f.set(c,target1);
  154. Field f2 = c.getDeclaredField("explosionPower");
  155. f2.setAccessible(true);
  156. f2.set(c,explosionpower);
  157. Field f3 = c.getDeclaredField("br");
  158. f3.setAccessible(true);
  159. f3.set(c,br);
  160. }catch(NoSuchFieldException e){
  161. e.printStackTrace();
  162. }catch(IllegalAccessException e){
  163. e.printStackTrace();
  164. }
  165. }
  166.  
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement