Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package nl.SkyWars.Arena.Others.CustomEntities;
- import net.minecraft.server.v1_7_R4.*;
- import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
- import org.bukkit.event.entity.EntityTargetEvent;
- import java.lang.reflect.Field;
- /**
- * Created by Nuno on 07-03-2015.
- */
- public class CGhast extends EntityGhast {
- public CGhast(World w){
- super(w);
- }
- protected void bq()
- {
- Entity target1 = null;
- int explosionpower = 0,br=0;
- Class c = this.getClass();
- try {
- Field f = c.getDeclaredField("target");
- f.setAccessible(true);
- target1 =(Entity) f.get(c);
- Field f2 = c.getDeclaredField("explosionPower");
- f2.setAccessible(true);
- explosionpower = (Integer)f.get(c);
- Field f3 = c.getDeclaredField("br");
- f3.setAccessible(true);
- br=(Integer)f3.get(c);
- }catch(NoSuchFieldException e){
- e.printStackTrace();
- }catch(IllegalAccessException e){
- e.printStackTrace();
- }
- if ((!this.world.isStatic) && (this.world.difficulty == EnumDifficulty.PEACEFUL)) {
- die();
- }
- w();
- this.bo = this.bp;
- double d0 = this.i - this.locX;
- double d1 = this.bm - this.locY;
- double d2 = this.bn - this.locZ;
- double d3 = d0 * d0 + d1 * d1 + d2 * d2;
- if ((d3 < 1.0D) || (d3 > 3600.0D))
- {
- this.i = (this.locX + (this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
- this.bm = (this.locY + (this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
- this.bn = (this.locZ + (this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
- }
- if (this.h-- <= 0)
- {
- this.h += this.random.nextInt(5) + 2;
- d3 = MathHelper.sqrt(d3);
- if (a(this.i, this.bm, this.bn, d3))
- {
- this.motX += d0 / d3 * 0.1D;
- this.motY += d1 / d3 * 0.1D;
- this.motZ += d2 / d3 * 0.1D;
- }
- else
- {
- this.i = this.locX;
- this.bm = this.locY;
- this.bn = this.locZ;
- }
- }
- if ((target1 != null) && (target1.dead))
- {
- EntityTargetEvent event = new EntityTargetEvent(getBukkitEntity(), null, EntityTargetEvent.TargetReason.TARGET_DIED);
- this.world.getServer().getPluginManager().callEvent(event);
- if (!event.isCancelled()) {
- if (event.getTarget() == null) {
- target1 = null;
- } else {
- target1 = ((CraftEntity)event.getTarget()).getHandle();
- }
- }
- }
- if ((target1 == null) || (br-- <= 0))
- {
- Entity target = this.world.findNearbyVulnerablePlayer(this, 100.0D);
- if (target != null)
- {
- EntityTargetEvent event = new EntityTargetEvent(getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
- this.world.getServer().getPluginManager().callEvent(event);
- if (!event.isCancelled()) {
- if (event.getTarget() == null) {
- target1 = null;
- } else {
- target1 = ((CraftEntity)event.getTarget()).getHandle();
- }
- }
- }
- if (target1 != null) {
- br = 20;
- }
- }
- double d4 = 64.0D;
- if ((target1 != null) && (target1.f(this) < d4 * d4))
- {
- double d5 = target1.locX - this.locX;
- double d6 = target1.boundingBox.b + target1.length / 2.0F - (this.locY + this.length / 2.0F);
- double d7 = target1.locZ - this.locZ;
- this.aM = (this.yaw = -(float)Math.atan2(d5, d7) * 180.0F / 3.1415927F);
- if (hasLineOfSight(target1))
- {
- if (this.bp == 10) {
- this.world.a((EntityHuman)null, 1007, (int)this.locX, (int)this.locY, (int)this.locZ, 0);
- }
- this.bp += 1;
- if (this.bp == 20)
- {
- this.world.a((EntityHuman)null, 1008, (int)this.locX, (int)this.locY, (int)this.locZ, 0);
- CFireball entitylargefireball = new CFireball(this.world);
- entitylargefireball.bukkitYield = (entitylargefireball.yield = explosionpower);
- double d8 = 4.0D;
- Vec3D vec3d = j(1.0F);
- entitylargefireball.locX = (this.locX + vec3d.a * d8);
- entitylargefireball.locY = (this.locY + this.length / 2.0F + 0.5D);
- entitylargefireball.locZ = (this.locZ + vec3d.c * d8);
- this.world.addEntity(entitylargefireball);
- this.bp = -40;
- }
- }
- else if (this.bp > 0)
- {
- this.bp -= 1;
- }
- }
- else
- {
- this.aM = (this.yaw = -(float)Math.atan2(this.motX, this.motZ) * 180.0F / 3.1415927F);
- if (this.bp > 0) {
- this.bp -= 1;
- }
- }
- if (!this.world.isStatic)
- {
- byte b0 = this.datawatcher.getByte(16);
- byte b1 = (byte)(this.bp > 10 ? 1 : 0);
- if (b0 != b1) {
- this.datawatcher.watch(16, Byte.valueOf(b1));
- }
- }
- try {
- Field f = c.getDeclaredField("target");
- f.setAccessible(true);
- f.set(c,target1);
- Field f2 = c.getDeclaredField("explosionPower");
- f2.setAccessible(true);
- f2.set(c,explosionpower);
- Field f3 = c.getDeclaredField("br");
- f3.setAccessible(true);
- f3.set(c,br);
- }catch(NoSuchFieldException e){
- e.printStackTrace();
- }catch(IllegalAccessException e){
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement