2011-01-03 12:37:41 +01:00
package net.minecraft.server ;
import java.util.List ;
import java.util.Random ;
2013-03-13 23:33:27 +01:00
import java.util.UUID ;
2012-11-06 13:05:28 +01:00
import java.util.concurrent.Callable ;
2011-02-21 23:30:01 +01:00
// CraftBukkit start
2011-04-21 18:29:35 +02:00
import org.bukkit.Bukkit ;
2012-12-22 19:46:24 +01:00
import org.bukkit.Location ;
2012-07-22 08:18:00 +02:00
import org.bukkit.Server ;
2012-12-22 19:46:24 +01:00
import org.bukkit.TravelAgent ;
2011-01-31 23:25:27 +01:00
import org.bukkit.block.BlockFace ;
2011-02-01 11:02:43 +01:00
import org.bukkit.entity.LivingEntity ;
2011-11-29 08:10:05 +01:00
import org.bukkit.entity.Painting ;
2011-01-31 23:25:27 +01:00
import org.bukkit.entity.Vehicle ;
2011-11-29 08:10:05 +01:00
import org.bukkit.event.entity.EntityCombustByEntityEvent ;
import org.bukkit.event.painting.PaintingBreakByEntityEvent ;
2011-01-31 23:25:27 +01:00
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent ;
2011-12-16 21:31:00 +01:00
import org.bukkit.event.vehicle.VehicleEnterEvent ;
2011-02-01 11:02:43 +01:00
import org.bukkit.event.vehicle.VehicleExitEvent ;
2012-07-22 08:18:00 +02:00
import org.bukkit.craftbukkit.CraftWorld ;
2012-12-22 19:46:24 +01:00
import org.bukkit.craftbukkit.entity.CraftEntity ;
2011-04-07 08:18:30 +02:00
import org.bukkit.craftbukkit.entity.CraftPlayer ;
2011-02-21 23:30:01 +01:00
import org.bukkit.event.entity.EntityCombustEvent ;
import org.bukkit.event.entity.EntityDamageByBlockEvent ;
import org.bukkit.event.entity.EntityDamageEvent ;
2012-12-22 19:46:24 +01:00
import org.bukkit.event.entity.EntityPortalEvent ;
2011-11-29 08:10:05 +01:00
import org.bukkit.plugin.PluginManager ;
2011-02-21 23:30:01 +01:00
// CraftBukkit end
2011-01-03 12:37:41 +01:00
public abstract class Entity {
2012-12-11 12:32:05 +01:00
// CraftBukkit start
2012-12-29 03:27:41 +01:00
private static final int CURRENT_LEVEL = 2 ;
2012-12-11 12:32:05 +01:00
static boolean isLevelAtLeast ( NBTTagCompound tag , int level ) {
return tag . hasKey ( " Bukkit.updateLevel " ) & & tag . getInt ( " Bukkit.updateLevel " ) > = level ;
}
// CraftBukkit end
2013-07-01 13:03:00 +02:00
private static int entityCount ;
2013-11-04 14:07:38 +01:00
private int id ;
public double k ;
public boolean l ;
2011-01-29 22:50:29 +01:00
public Entity passenger ;
public Entity vehicle ;
2013-11-04 14:07:38 +01:00
public boolean o ;
2011-01-29 22:50:29 +01:00
public World world ;
public double lastX ;
public double lastY ;
public double lastZ ;
public double locX ;
public double locY ;
public double locZ ;
public double motX ;
public double motY ;
public double motZ ;
public float yaw ;
public float pitch ;
public float lastYaw ;
public float lastPitch ;
public final AxisAlignedBB boundingBox ;
public boolean onGround ;
2011-04-20 19:05:14 +02:00
public boolean positionChanged ;
2013-11-04 14:07:38 +01:00
public boolean G ;
2012-07-29 09:33:13 +02:00
public boolean H ;
2012-01-12 23:10:13 +01:00
public boolean velocityChanged ;
2013-11-04 14:07:38 +01:00
protected boolean J ;
public boolean K ;
2011-01-29 22:50:29 +01:00
public boolean dead ;
public float height ;
public float width ;
2011-11-30 00:17:43 +01:00
public float length ;
2013-11-04 14:07:38 +01:00
public float P ;
2012-07-29 09:33:13 +02:00
public float Q ;
2012-10-25 05:53:23 +02:00
public float R ;
2012-07-29 09:33:13 +02:00
public float fallDistance ;
2013-11-04 14:07:38 +01:00
private int d ;
public double T ;
2012-07-29 09:33:13 +02:00
public double U ;
2012-10-25 05:53:23 +02:00
public double V ;
2013-11-04 14:07:38 +01:00
public float W ;
2012-10-25 05:53:23 +02:00
public float X ;
2013-11-04 14:07:38 +01:00
public boolean Y ;
public float Z ;
2011-01-29 22:50:29 +01:00
protected Random random ;
public int ticksLived ;
public int maxFireTicks ;
2011-11-20 09:01:14 +01:00
public int fireTicks ; // CraftBukkit - private -> public
2013-03-20 21:09:23 +01:00
protected boolean inWater ;
2011-01-29 22:50:29 +01:00
public int noDamageTicks ;
private boolean justCreated ;
2011-06-27 00:25:01 +02:00
protected boolean fireProof ;
2011-01-29 22:50:29 +01:00
protected DataWatcher datawatcher ;
2012-10-25 05:53:23 +02:00
private double g ;
2013-11-04 14:07:38 +01:00
private double h ;
public boolean ah ;
public int ai ;
2012-07-29 09:33:13 +02:00
public int aj ;
2012-10-25 05:53:23 +02:00
public int ak ;
2013-11-04 14:07:38 +01:00
public boolean al ;
2012-10-25 05:53:23 +02:00
public boolean am ;
2012-11-06 13:05:28 +01:00
public int portalCooldown ;
2013-11-04 14:07:38 +01:00
protected boolean ao ;
protected int ap ;
2012-10-25 05:53:23 +02:00
public int dimension ;
2013-11-04 14:07:38 +01:00
protected int ar ;
2012-11-06 13:05:28 +01:00
private boolean invulnerable ;
2013-11-04 14:07:38 +01:00
public UUID uniqueID ; // CraftBukkit - protected -> public
2013-03-13 23:33:27 +01:00
public EnumEntitySize at ;
2013-07-01 13:03:00 +02:00
public boolean valid ; // CraftBukkit
2011-01-03 12:37:41 +01:00
2013-11-04 14:07:38 +01:00
public int getId ( ) {
return this . id ;
}
public void d ( int i ) {
this . id = i ;
}
2011-01-03 12:37:41 +01:00
public Entity ( World world ) {
2011-01-29 22:50:29 +01:00
this . id = entityCount + + ;
2013-11-04 14:07:38 +01:00
this . k = 1 . 0D ;
2011-01-29 22:50:29 +01:00
this . boundingBox = AxisAlignedBB . a ( 0 . 0D , 0 . 0D , 0 . 0D , 0 . 0D , 0 . 0D , 0 . 0D ) ;
2013-11-04 14:07:38 +01:00
this . K = true ;
2011-11-30 00:17:43 +01:00
this . width = 0 . 6F ;
this . length = 1 . 8F ;
2013-11-04 14:07:38 +01:00
this . d = 1 ;
2011-01-29 22:50:29 +01:00
this . random = new Random ( ) ;
this . maxFireTicks = 1 ;
this . justCreated = true ;
2013-03-13 23:33:27 +01:00
this . uniqueID = UUID . randomUUID ( ) ;
this . at = EnumEntitySize . SIZE_2 ;
2011-01-29 22:50:29 +01:00
this . world = world ;
2011-04-20 19:05:14 +02:00
this . setPosition ( 0 . 0D , 0 . 0D , 0 . 0D ) ;
2012-10-25 05:53:23 +02:00
if ( world ! = null ) {
this . dimension = world . worldProvider . dimension ;
}
2013-11-04 14:07:38 +01:00
this . datawatcher = new DataWatcher ( this ) ;
2011-01-29 22:50:29 +01:00
this . datawatcher . a ( 0 , Byte . valueOf ( ( byte ) 0 ) ) ;
2011-11-20 09:01:14 +01:00
this . datawatcher . a ( 1 , Short . valueOf ( ( short ) 300 ) ) ;
2013-11-04 14:07:38 +01:00
this . c ( ) ;
2011-01-14 14:31:10 +01:00
}
2013-11-04 14:07:38 +01:00
protected abstract void c ( ) ;
2011-01-14 14:31:10 +01:00
2011-09-24 23:03:31 +02:00
public DataWatcher getDataWatcher ( ) {
2011-01-29 22:50:29 +01:00
return this . datawatcher ;
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
public boolean equals ( Object object ) {
return object instanceof Entity ? ( ( Entity ) object ) . id = = this . id : false ;
2011-01-03 12:37:41 +01:00
}
public int hashCode ( ) {
2011-01-29 22:50:29 +01:00
return this . id ;
2011-01-03 12:37:41 +01:00
}
2011-04-20 19:05:14 +02:00
public void die ( ) {
2011-01-29 22:50:29 +01:00
this . dead = true ;
2011-01-03 12:37:41 +01:00
}
2012-07-29 09:33:13 +02:00
protected void a ( float f , float f1 ) {
2013-07-09 01:43:37 +02:00
float f2 ;
2013-03-13 23:33:27 +01:00
if ( f ! = this . width | | f1 ! = this . length ) {
2013-07-09 01:43:37 +02:00
f2 = this . width ;
2013-03-13 23:33:27 +01:00
this . width = f ;
this . length = f1 ;
this . boundingBox . d = this . boundingBox . a + ( double ) this . width ;
this . boundingBox . f = this . boundingBox . c + ( double ) this . width ;
this . boundingBox . e = this . boundingBox . b + ( double ) this . length ;
2013-07-09 01:43:37 +02:00
if ( this . width > f2 & & ! this . justCreated & & ! this . world . isStatic ) {
this . move ( ( double ) ( f2 - this . width ) , 0 . 0D , ( double ) ( f2 - this . width ) ) ;
}
2013-03-13 23:33:27 +01:00
}
2013-07-09 01:43:37 +02:00
f2 = f % 2 . 0F ;
2012-07-29 09:33:13 +02:00
if ( ( double ) f2 < 0 . 375D ) {
2013-03-13 23:33:27 +01:00
this . at = EnumEntitySize . SIZE_1 ;
2012-07-29 09:33:13 +02:00
} else if ( ( double ) f2 < 0 . 75D ) {
2013-03-13 23:33:27 +01:00
this . at = EnumEntitySize . SIZE_2 ;
2012-07-29 09:33:13 +02:00
} else if ( ( double ) f2 < 1 . 0D ) {
2013-03-13 23:33:27 +01:00
this . at = EnumEntitySize . SIZE_3 ;
2012-07-29 09:33:13 +02:00
} else if ( ( double ) f2 < 1 . 375D ) {
2013-03-13 23:33:27 +01:00
this . at = EnumEntitySize . SIZE_4 ;
2012-07-29 09:33:13 +02:00
} else if ( ( double ) f2 < 1 . 75D ) {
2013-03-13 23:33:27 +01:00
this . at = EnumEntitySize . SIZE_5 ;
2012-04-20 07:28:30 +02:00
} else {
2013-03-13 23:33:27 +01:00
this . at = EnumEntitySize . SIZE_6 ;
2012-04-20 07:28:30 +02:00
}
2011-01-03 12:37:41 +01:00
}
2012-07-29 09:33:13 +02:00
protected void b ( float f , float f1 ) {
// CraftBukkit start - yaw was sometimes set to NaN, so we need to set it back to 0
2011-04-23 10:18:00 +02:00
if ( Float . isNaN ( f ) ) {
f = 0 ;
}
if ( ( f = = Float . POSITIVE_INFINITY ) | | ( f = = Float . NEGATIVE_INFINITY ) ) {
2011-04-07 08:18:30 +02:00
if ( this instanceof EntityPlayer ) {
2013-03-13 23:33:27 +01:00
this . world . getServer ( ) . getLogger ( ) . warning ( ( ( CraftPlayer ) this . getBukkitEntity ( ) ) . getName ( ) + " was caught trying to crash the server with an invalid yaw " ) ;
2011-04-20 19:05:14 +02:00
( ( CraftPlayer ) this . getBukkitEntity ( ) ) . kickPlayer ( " Nope " ) ;
2011-04-07 08:18:30 +02:00
}
f = 0 ;
}
2011-05-14 16:29:42 +02:00
// pitch was sometimes set to NaN, so we need to set it back to 0.
2011-04-23 10:18:00 +02:00
if ( Float . isNaN ( f1 ) ) {
f1 = 0 ;
}
2011-06-12 00:02:58 +02:00
if ( ( f1 = = Float . POSITIVE_INFINITY ) | | ( f1 = = Float . NEGATIVE_INFINITY ) ) {
2011-04-07 08:18:30 +02:00
if ( this instanceof EntityPlayer ) {
2013-03-13 23:33:27 +01:00
this . world . getServer ( ) . getLogger ( ) . warning ( ( ( CraftPlayer ) this . getBukkitEntity ( ) ) . getName ( ) + " was caught trying to crash the server with an invalid pitch " ) ;
2011-04-20 19:05:14 +02:00
( ( CraftPlayer ) this . getBukkitEntity ( ) ) . kickPlayer ( " Nope " ) ;
2011-04-07 08:18:30 +02:00
}
f1 = 0 ;
}
2011-05-14 16:29:42 +02:00
// CraftBukkit end
2011-04-20 22:47:26 +02:00
this . yaw = f % 360 . 0F ;
this . pitch = f1 % 360 . 0F ;
2011-01-03 12:37:41 +01:00
}
2011-04-20 19:05:14 +02:00
public void setPosition ( double d0 , double d1 , double d2 ) {
2011-01-29 22:50:29 +01:00
this . locX = d0 ;
this . locY = d1 ;
this . locZ = d2 ;
2011-11-30 00:17:43 +01:00
float f = this . width / 2 . 0F ;
float f1 = this . length ;
2011-01-03 12:37:41 +01:00
2013-11-04 14:07:38 +01:00
this . boundingBox . b ( d0 - ( double ) f , d1 - ( double ) this . height + ( double ) this . W , d2 - ( double ) f , d0 + ( double ) f , d1 - ( double ) this . height + ( double ) this . W + ( double ) f1 , d2 + ( double ) f ) ;
2011-01-03 12:37:41 +01:00
}
2013-11-04 14:07:38 +01:00
public void h ( ) {
this . C ( ) ;
2011-01-03 12:37:41 +01:00
}
2013-11-04 14:07:38 +01:00
public void C ( ) {
2012-09-10 06:19:28 +02:00
this . world . methodProfiler . a ( " entityBaseTick " ) ;
2011-01-29 22:50:29 +01:00
if ( this . vehicle ! = null & & this . vehicle . dead ) {
this . vehicle = null ;
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
2013-11-04 14:07:38 +01:00
this . P = this . Q ;
2011-01-29 22:50:29 +01:00
this . lastX = this . locX ;
this . lastY = this . locY ;
this . lastZ = this . locZ ;
this . lastPitch = this . pitch ;
this . lastYaw = this . yaw ;
2011-09-15 02:23:52 +02:00
int i ;
2012-10-25 05:53:23 +02:00
if ( ! this . world . isStatic & & this . world instanceof WorldServer ) {
2012-11-06 13:05:28 +01:00
this . world . methodProfiler . a ( " portal " ) ;
2012-10-25 05:53:23 +02:00
MinecraftServer minecraftserver = ( ( WorldServer ) this . world ) . getMinecraftServer ( ) ;
2013-11-04 14:07:38 +01:00
i = this . D ( ) ;
if ( this . ao ) {
2012-11-06 13:05:28 +01:00
if ( true | | minecraftserver . getAllowNether ( ) ) { // CraftBukkit
2013-11-04 14:07:38 +01:00
if ( this . vehicle = = null & & this . ap + + > = i ) {
this . ap = i ;
this . portalCooldown = this . ai ( ) ;
2012-10-25 05:53:23 +02:00
byte b0 ;
if ( this . world . worldProvider . dimension = = - 1 ) {
b0 = 0 ;
} else {
b0 = - 1 ;
}
2013-07-01 13:03:00 +02:00
this . b ( b0 ) ;
2012-10-25 05:53:23 +02:00
}
2013-11-04 14:07:38 +01:00
this . ao = false ;
2012-10-30 22:09:18 +01:00
}
2012-10-25 05:53:23 +02:00
} else {
2013-11-04 14:07:38 +01:00
if ( this . ap > 0 ) {
this . ap - = 4 ;
2012-10-25 05:53:23 +02:00
}
2013-11-04 14:07:38 +01:00
if ( this . ap < 0 ) {
this . ap = 0 ;
2012-10-25 05:53:23 +02:00
}
}
2012-11-06 13:05:28 +01:00
if ( this . portalCooldown > 0 ) {
- - this . portalCooldown ;
2012-10-25 05:53:23 +02:00
}
2012-11-06 13:05:28 +01:00
this . world . methodProfiler . b ( ) ;
}
2012-10-25 05:53:23 +02:00
2013-11-04 14:07:38 +01:00
if ( this . isSprinting ( ) & & ! this . M ( ) ) {
2012-11-06 13:05:28 +01:00
int j = MathHelper . floor ( this . locX ) ;
2011-09-15 02:23:52 +02:00
2012-10-25 05:53:23 +02:00
i = MathHelper . floor ( this . locY - 0 . 20000000298023224D - ( double ) this . height ) ;
2012-11-06 13:05:28 +01:00
int k = MathHelper . floor ( this . locZ ) ;
2013-11-04 14:07:38 +01:00
Block block = this . world . getType ( j , i , k ) ;
2011-09-15 02:23:52 +02:00
2013-11-04 14:07:38 +01:00
if ( block . getMaterial ( ) ! = Material . AIR ) {
this . world . addParticle ( " blockcrack_ " + Block . b ( block ) + " _ " + this . world . getData ( j , i , k ) , this . locX + ( ( double ) this . random . nextFloat ( ) - 0 . 5D ) * ( double ) this . width , this . boundingBox . b + 0 . 1D , this . locZ + ( ( double ) this . random . nextFloat ( ) - 0 . 5D ) * ( double ) this . width , - this . motX * 4 . 0D , 1 . 5D , - this . motZ * 4 . 0D ) ;
2011-09-15 02:23:52 +02:00
}
}
2013-11-04 14:07:38 +01:00
this . N ( ) ;
2011-01-29 22:50:29 +01:00
if ( this . world . isStatic ) {
this . fireTicks = 0 ;
} else if ( this . fireTicks > 0 ) {
2011-06-27 00:25:01 +02:00
if ( this . fireProof ) {
2011-01-29 22:50:29 +01:00
this . fireTicks - = 4 ;
if ( this . fireTicks < 0 ) {
this . fireTicks = 0 ;
2011-01-03 12:37:41 +01:00
}
} else {
2011-01-29 22:50:29 +01:00
if ( this . fireTicks % 20 = = 0 ) {
2013-07-01 13:03:00 +02:00
this . damageEntity ( DamageSource . BURN , 1 . 0F ) ;
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
- - this . fireTicks ;
2011-01-03 12:37:41 +01:00
}
}
2011-01-29 22:50:29 +01:00
2013-11-04 14:07:38 +01:00
if ( this . P ( ) ) {
this . E ( ) ;
2011-11-20 09:01:14 +01:00
this . fallDistance * = 0 . 5F ;
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
if ( this . locY < - 64 . 0D ) {
2013-11-04 14:07:38 +01:00
this . G ( ) ;
2011-01-14 14:31:10 +01:00
}
2011-01-29 22:50:29 +01:00
if ( ! this . world . isStatic ) {
this . a ( 0 , this . fireTicks > 0 ) ;
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
this . justCreated = false ;
2012-09-10 06:19:28 +02:00
this . world . methodProfiler . b ( ) ;
2011-01-03 12:37:41 +01:00
}
2013-11-04 14:07:38 +01:00
public int D ( ) {
2012-10-25 05:53:23 +02:00
return 0 ;
}
2013-11-04 14:07:38 +01:00
protected void E ( ) {
2011-06-27 00:25:01 +02:00
if ( ! this . fireProof ) {
2013-03-25 05:22:32 +01:00
// CraftBukkit start - Fallen in lava TODO: this event spams!
2011-02-23 13:56:36 +01:00
if ( this instanceof EntityLiving ) {
2012-07-22 08:18:00 +02:00
Server server = this . world . getServer ( ) ;
2011-06-27 00:25:01 +02:00
2011-01-19 09:07:56 +01:00
// TODO: shouldn't be sending null for the block.
2011-02-23 13:56:36 +01:00
org . bukkit . block . Block damager = null ; // ((WorldServer) this.l).getWorld().getBlockAt(i, j, k);
2011-01-18 06:30:01 +01:00
org . bukkit . entity . Entity damagee = this . getBukkitEntity ( ) ;
2011-01-12 06:48:19 +01:00
2013-07-01 13:03:00 +02:00
EntityDamageByBlockEvent event = new EntityDamageByBlockEvent ( damager , damagee , EntityDamageEvent . DamageCause . LAVA , 4D ) ;
2011-01-29 22:50:29 +01:00
server . getPluginManager ( ) . callEvent ( event ) ;
2011-02-23 13:56:36 +01:00
if ( ! event . isCancelled ( ) ) {
2012-07-01 12:04:06 +02:00
damagee . setLastDamageCause ( event ) ;
2013-07-01 13:03:00 +02:00
this . damageEntity ( DamageSource . LAVA , ( float ) event . getDamage ( ) ) ;
2011-01-12 06:48:19 +01:00
}
2011-02-23 13:56:36 +01:00
if ( this . fireTicks < = 0 ) {
2011-01-18 06:30:01 +01:00
// not on fire yet
2012-07-22 08:18:00 +02:00
EntityCombustEvent combustEvent = new org . bukkit . event . entity . EntityCombustByBlockEvent ( damager , damagee , 15 ) ;
2011-01-29 22:50:29 +01:00
server . getPluginManager ( ) . callEvent ( combustEvent ) ;
2011-06-27 00:25:01 +02:00
2011-02-23 13:56:36 +01:00
if ( ! combustEvent . isCancelled ( ) ) {
2011-11-30 00:17:43 +01:00
this . setOnFire ( combustEvent . getDuration ( ) ) ;
2011-01-18 06:30:01 +01:00
}
} else {
2012-07-29 09:33:13 +02:00
// This will be called every single tick the entity is in lava, so don't throw an event
2011-11-30 00:17:43 +01:00
this . setOnFire ( 15 ) ;
2011-01-12 06:48:19 +01:00
}
2011-01-29 22:50:29 +01:00
return ;
2011-01-12 06:48:19 +01:00
}
2011-11-29 08:10:05 +01:00
// CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
2011-01-29 22:50:29 +01:00
2011-09-15 18:36:27 +02:00
this . damageEntity ( DamageSource . LAVA , 4 ) ;
2011-11-30 00:17:43 +01:00
this . setOnFire ( 15 ) ;
2011-11-20 09:01:14 +01:00
}
}
2011-11-30 00:17:43 +01:00
public void setOnFire ( int i ) {
2011-11-20 09:01:14 +01:00
int j = i * 20 ;
2012-12-20 05:03:52 +01:00
j = EnchantmentProtection . a ( this , j ) ;
2011-11-20 09:01:14 +01:00
if ( this . fireTicks < j ) {
this . fireTicks = j ;
2011-01-03 12:37:41 +01:00
}
}
2011-11-30 00:17:43 +01:00
public void extinguish ( ) {
2011-11-20 09:01:14 +01:00
this . fireTicks = 0 ;
}
2013-11-04 14:07:38 +01:00
protected void G ( ) {
2011-04-20 19:05:14 +02:00
this . die ( ) ;
2011-01-03 12:37:41 +01:00
}
2012-07-29 09:33:13 +02:00
public boolean c ( double d0 , double d1 , double d2 ) {
2011-01-29 22:50:29 +01:00
AxisAlignedBB axisalignedbb = this . boundingBox . c ( d0 , d1 , d2 ) ;
2012-02-29 22:31:04 +01:00
List list = this . world . getCubes ( this , axisalignedbb ) ;
2011-01-03 12:37:41 +01:00
2012-07-29 09:33:13 +02:00
return ! list . isEmpty ( ) ? false : ! this . world . containsLiquid ( axisalignedbb ) ;
2011-01-03 12:37:41 +01:00
}
2011-04-20 19:05:14 +02:00
public void move ( double d0 , double d1 , double d2 ) {
2013-04-12 01:11:10 +02:00
// CraftBukkit start - Don't do anything if we aren't moving
2013-11-04 14:07:38 +01:00
// We need to do this regardless of whether or not we are moving thanks to portals
try {
this . I ( ) ;
} catch ( Throwable throwable ) {
CrashReport crashreport = CrashReport . a ( throwable , " Checking entity block collision " ) ;
CrashReportSystemDetails crashreportsystemdetails = crashreport . a ( " Entity being checked for collision " ) ;
this . a ( crashreportsystemdetails ) ;
throw new ReportedException ( crashreport ) ;
}
// Check if we're moving
2013-04-30 08:21:04 +02:00
if ( d0 = = 0 & & d1 = = 0 & & d2 = = 0 & & this . vehicle = = null & & this . passenger = = null ) {
2013-04-12 01:11:10 +02:00
return ;
}
// CraftBukkit end
2013-11-04 14:07:38 +01:00
if ( this . Y ) {
2011-01-29 22:50:29 +01:00
this . boundingBox . d ( d0 , d1 , d2 ) ;
this . locX = ( this . boundingBox . a + this . boundingBox . d ) / 2 . 0D ;
2013-11-04 14:07:38 +01:00
this . locY = this . boundingBox . b + ( double ) this . height - ( double ) this . W ;
2011-01-29 22:50:29 +01:00
this . locZ = ( this . boundingBox . c + this . boundingBox . f ) / 2 . 0D ;
} else {
2012-09-10 06:19:28 +02:00
this . world . methodProfiler . a ( " move " ) ;
2013-11-04 14:07:38 +01:00
this . W * = 0 . 4F ;
2011-01-29 22:50:29 +01:00
double d3 = this . locX ;
2012-10-25 05:53:23 +02:00
double d4 = this . locY ;
double d5 = this . locZ ;
2011-04-20 22:47:26 +02:00
2013-11-04 14:07:38 +01:00
if ( this . J ) {
this . J = false ;
2011-04-20 22:47:26 +02:00
d0 * = 0 . 25D ;
d1 * = 0 . 05000000074505806D ;
d2 * = 0 . 25D ;
this . motX = 0 . 0D ;
this . motY = 0 . 0D ;
this . motZ = 0 . 0D ;
}
2012-10-25 05:53:23 +02:00
double d6 = d0 ;
double d7 = d1 ;
double d8 = d2 ;
2011-04-20 19:05:14 +02:00
AxisAlignedBB axisalignedbb = this . boundingBox . clone ( ) ;
2012-03-01 11:49:23 +01:00
boolean flag = this . onGround & & this . isSneaking ( ) & & this instanceof EntityHuman ;
2011-01-29 22:50:29 +01:00
if ( flag ) {
2012-10-25 05:53:23 +02:00
double d9 ;
2011-01-29 22:50:29 +01:00
2012-10-25 05:53:23 +02:00
for ( d9 = 0 . 05D ; d0 ! = 0 . 0D & & this . world . getCubes ( this , this . boundingBox . c ( d0 , - 1 . 0D , 0 . 0D ) ) . isEmpty ( ) ; d6 = d0 ) {
if ( d0 < d9 & & d0 > = - d9 ) {
2011-01-29 22:50:29 +01:00
d0 = 0 . 0D ;
} else if ( d0 > 0 . 0D ) {
2012-10-25 05:53:23 +02:00
d0 - = d9 ;
2011-01-29 22:50:29 +01:00
} else {
2012-10-25 05:53:23 +02:00
d0 + = d9 ;
2011-01-29 22:50:29 +01:00
}
2011-01-03 12:37:41 +01:00
}
2012-10-25 05:53:23 +02:00
for ( ; d2 ! = 0 . 0D & & this . world . getCubes ( this , this . boundingBox . c ( 0 . 0D , - 1 . 0D , d2 ) ) . isEmpty ( ) ; d8 = d2 ) {
if ( d2 < d9 & & d2 > = - d9 ) {
2011-01-29 22:50:29 +01:00
d2 = 0 . 0D ;
} else if ( d2 > 0 . 0D ) {
2012-10-25 05:53:23 +02:00
d2 - = d9 ;
2011-01-29 22:50:29 +01:00
} else {
2012-10-25 05:53:23 +02:00
d2 + = d9 ;
2011-01-29 22:50:29 +01:00
}
2011-01-03 12:37:41 +01:00
}
2012-03-22 21:39:39 +01:00
2012-07-29 09:33:13 +02:00
while ( d0 ! = 0 . 0D & & d2 ! = 0 . 0D & & this . world . getCubes ( this , this . boundingBox . c ( d0 , - 1 . 0D , d2 ) ) . isEmpty ( ) ) {
2012-10-25 05:53:23 +02:00
if ( d0 < d9 & & d0 > = - d9 ) {
2012-03-22 21:39:39 +01:00
d0 = 0 . 0D ;
} else if ( d0 > 0 . 0D ) {
2012-10-25 05:53:23 +02:00
d0 - = d9 ;
2012-03-22 21:39:39 +01:00
} else {
2012-10-25 05:53:23 +02:00
d0 + = d9 ;
2012-03-22 21:39:39 +01:00
}
2012-10-25 05:53:23 +02:00
if ( d2 < d9 & & d2 > = - d9 ) {
2012-03-22 21:39:39 +01:00
d2 = 0 . 0D ;
} else if ( d2 > 0 . 0D ) {
2012-10-25 05:53:23 +02:00
d2 - = d9 ;
2012-03-22 21:39:39 +01:00
} else {
2012-10-25 05:53:23 +02:00
d2 + = d9 ;
2012-03-22 21:39:39 +01:00
}
2012-10-25 05:53:23 +02:00
d6 = d0 ;
d8 = d2 ;
2012-03-22 21:39:39 +01:00
}
2011-01-03 12:37:41 +01:00
}
2012-02-29 22:31:04 +01:00
List list = this . world . getCubes ( this , this . boundingBox . a ( d0 , d1 , d2 ) ) ;
2011-01-03 12:37:41 +01:00
2012-11-06 13:05:28 +01:00
for ( int i = 0 ; i < list . size ( ) ; + + i ) {
d1 = ( ( AxisAlignedBB ) list . get ( i ) ) . b ( this . boundingBox , d1 ) ;
2011-01-29 22:50:29 +01:00
}
2011-01-03 12:37:41 +01:00
2011-01-29 22:50:29 +01:00
this . boundingBox . d ( 0 . 0D , d1 , 0 . 0D ) ;
2013-11-04 14:07:38 +01:00
if ( ! this . K & & d7 ! = d1 ) {
2011-01-29 22:50:29 +01:00
d2 = 0 . 0D ;
d1 = 0 . 0D ;
d0 = 0 . 0D ;
}
2011-01-03 12:37:41 +01:00
2012-10-25 05:53:23 +02:00
boolean flag1 = this . onGround | | d7 ! = d1 & & d7 < 0 . 0D ;
2011-01-03 12:37:41 +01:00
2012-11-06 13:05:28 +01:00
int j ;
2011-01-03 12:37:41 +01:00
2012-11-06 13:05:28 +01:00
for ( j = 0 ; j < list . size ( ) ; + + j ) {
d0 = ( ( AxisAlignedBB ) list . get ( j ) ) . a ( this . boundingBox , d0 ) ;
2011-01-29 22:50:29 +01:00
}
2011-01-03 12:37:41 +01:00
2011-01-29 22:50:29 +01:00
this . boundingBox . d ( d0 , 0 . 0D , 0 . 0D ) ;
2013-11-04 14:07:38 +01:00
if ( ! this . K & & d6 ! = d0 ) {
2011-01-29 22:50:29 +01:00
d2 = 0 . 0D ;
d1 = 0 . 0D ;
d0 = 0 . 0D ;
2011-01-03 12:37:41 +01:00
}
2012-11-06 13:05:28 +01:00
for ( j = 0 ; j < list . size ( ) ; + + j ) {
d2 = ( ( AxisAlignedBB ) list . get ( j ) ) . c ( this . boundingBox , d2 ) ;
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
this . boundingBox . d ( 0 . 0D , 0 . 0D , d2 ) ;
2013-11-04 14:07:38 +01:00
if ( ! this . K & & d8 ! = d2 ) {
2011-01-29 22:50:29 +01:00
d2 = 0 . 0D ;
d1 = 0 . 0D ;
d0 = 0 . 0D ;
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
double d10 ;
2012-10-25 05:53:23 +02:00
double d11 ;
double d12 ;
2012-11-06 13:05:28 +01:00
int k ;
2012-10-25 05:53:23 +02:00
2013-11-04 14:07:38 +01:00
if ( this . X > 0 . 0F & & flag1 & & ( flag | | this . W < 0 . 05F ) & & ( d6 ! = d0 | | d8 ! = d2 ) ) {
2012-10-25 05:53:23 +02:00
d10 = d0 ;
d11 = d1 ;
d12 = d2 ;
d0 = d6 ;
2013-11-04 14:07:38 +01:00
d1 = ( double ) this . X ;
2012-10-25 05:53:23 +02:00
d2 = d8 ;
2012-11-06 13:05:28 +01:00
AxisAlignedBB axisalignedbb1 = this . boundingBox . clone ( ) ;
2011-01-29 22:50:29 +01:00
2013-07-01 13:03:00 +02:00
this . boundingBox . d ( axisalignedbb ) ;
2012-10-25 05:53:23 +02:00
list = this . world . getCubes ( this , this . boundingBox . a ( d6 , d1 , d8 ) ) ;
2011-01-29 22:50:29 +01:00
2012-11-06 13:05:28 +01:00
for ( k = 0 ; k < list . size ( ) ; + + k ) {
d1 = ( ( AxisAlignedBB ) list . get ( k ) ) . b ( this . boundingBox , d1 ) ;
2011-01-29 22:50:29 +01:00
}
this . boundingBox . d ( 0 . 0D , d1 , 0 . 0D ) ;
2013-11-04 14:07:38 +01:00
if ( ! this . K & & d7 ! = d1 ) {
2011-01-29 22:50:29 +01:00
d2 = 0 . 0D ;
d1 = 0 . 0D ;
d0 = 0 . 0D ;
}
2012-11-06 13:05:28 +01:00
for ( k = 0 ; k < list . size ( ) ; + + k ) {
d0 = ( ( AxisAlignedBB ) list . get ( k ) ) . a ( this . boundingBox , d0 ) ;
2011-01-29 22:50:29 +01:00
}
this . boundingBox . d ( d0 , 0 . 0D , 0 . 0D ) ;
2013-11-04 14:07:38 +01:00
if ( ! this . K & & d6 ! = d0 ) {
2011-01-29 22:50:29 +01:00
d2 = 0 . 0D ;
d1 = 0 . 0D ;
d0 = 0 . 0D ;
}
2012-11-06 13:05:28 +01:00
for ( k = 0 ; k < list . size ( ) ; + + k ) {
d2 = ( ( AxisAlignedBB ) list . get ( k ) ) . c ( this . boundingBox , d2 ) ;
2011-01-29 22:50:29 +01:00
}
this . boundingBox . d ( 0 . 0D , 0 . 0D , d2 ) ;
2013-11-04 14:07:38 +01:00
if ( ! this . K & & d8 ! = d2 ) {
2011-01-29 22:50:29 +01:00
d2 = 0 . 0D ;
d1 = 0 . 0D ;
d0 = 0 . 0D ;
}
2013-11-04 14:07:38 +01:00
if ( ! this . K & & d7 ! = d1 ) {
2011-05-26 14:48:22 +02:00
d2 = 0 . 0D ;
d1 = 0 . 0D ;
d0 = 0 . 0D ;
} else {
2013-11-04 14:07:38 +01:00
d1 = ( double ) ( - this . X ) ;
2011-05-26 14:48:22 +02:00
2012-11-06 13:05:28 +01:00
for ( k = 0 ; k < list . size ( ) ; + + k ) {
d1 = ( ( AxisAlignedBB ) list . get ( k ) ) . b ( this . boundingBox , d1 ) ;
2011-05-26 14:48:22 +02:00
}
this . boundingBox . d ( 0 . 0D , d1 , 0 . 0D ) ;
}
2012-10-25 05:53:23 +02:00
if ( d10 * d10 + d12 * d12 > = d0 * d0 + d2 * d2 ) {
d0 = d10 ;
d1 = d11 ;
d2 = d12 ;
2013-07-01 13:03:00 +02:00
this . boundingBox . d ( axisalignedbb1 ) ;
2011-01-29 22:50:29 +01:00
}
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
2012-09-10 06:19:28 +02:00
this . world . methodProfiler . b ( ) ;
this . world . methodProfiler . a ( " rest " ) ;
2011-01-29 22:50:29 +01:00
this . locX = ( this . boundingBox . a + this . boundingBox . d ) / 2 . 0D ;
2013-11-04 14:07:38 +01:00
this . locY = this . boundingBox . b + ( double ) this . height - ( double ) this . W ;
2011-01-29 22:50:29 +01:00
this . locZ = ( this . boundingBox . c + this . boundingBox . f ) / 2 . 0D ;
2012-10-25 05:53:23 +02:00
this . positionChanged = d6 ! = d0 | | d8 ! = d2 ;
2013-11-04 14:07:38 +01:00
this . G = d7 ! = d1 ;
2012-10-25 05:53:23 +02:00
this . onGround = d7 ! = d1 & & d7 < 0 . 0D ;
2013-11-04 14:07:38 +01:00
this . H = this . positionChanged | | this . G ;
2011-01-29 22:50:29 +01:00
this . a ( d1 , this . onGround ) ;
2012-10-25 05:53:23 +02:00
if ( d6 ! = d0 ) {
2011-01-29 22:50:29 +01:00
this . motX = 0 . 0D ;
2011-01-03 12:37:41 +01:00
}
2012-10-25 05:53:23 +02:00
if ( d7 ! = d1 ) {
2011-01-29 22:50:29 +01:00
this . motY = 0 . 0D ;
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
2012-10-25 05:53:23 +02:00
if ( d8 ! = d2 ) {
2011-01-29 22:50:29 +01:00
this . motZ = 0 . 0D ;
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
2012-10-25 05:53:23 +02:00
d10 = this . locX - d3 ;
d11 = this . locY - d4 ;
d12 = this . locZ - d5 ;
2011-01-29 22:50:29 +01:00
2011-02-23 13:56:36 +01:00
// CraftBukkit start
2011-06-27 00:25:01 +02:00
if ( ( this . positionChanged ) & & ( this . getBukkitEntity ( ) instanceof Vehicle ) ) {
Vehicle vehicle = ( Vehicle ) this . getBukkitEntity ( ) ;
2012-02-08 12:12:15 +01:00
org . bukkit . block . Block block = this . world . getWorld ( ) . getBlockAt ( MathHelper . floor ( this . locX ) , MathHelper . floor ( this . locY - ( double ) this . height ) , MathHelper . floor ( this . locZ ) ) ;
2011-01-31 23:25:27 +01:00
2012-10-25 05:53:23 +02:00
if ( d6 > d0 ) {
2012-12-01 07:22:01 +01:00
block = block . getRelative ( BlockFace . EAST ) ;
2012-10-25 05:53:23 +02:00
} else if ( d6 < d0 ) {
2011-07-17 15:02:32 +02:00
block = block . getRelative ( BlockFace . WEST ) ;
2012-12-01 07:22:01 +01:00
} else if ( d8 > d2 ) {
block = block . getRelative ( BlockFace . SOUTH ) ;
2012-12-01 20:17:29 +01:00
} else if ( d8 < d2 ) {
block = block . getRelative ( BlockFace . NORTH ) ;
2011-01-31 23:25:27 +01:00
}
2011-03-26 22:32:56 +01:00
VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent ( vehicle , block ) ;
2011-06-27 00:25:01 +02:00
this . world . getServer ( ) . getPluginManager ( ) . callEvent ( event ) ;
2011-01-31 23:25:27 +01:00
}
2011-02-23 13:56:36 +01:00
// CraftBukkit end
2011-01-31 23:25:27 +01:00
2013-11-04 14:07:38 +01:00
if ( this . g_ ( ) & & ! flag & & this . vehicle = = null ) {
2012-11-06 13:05:28 +01:00
int l = MathHelper . floor ( this . locX ) ;
k = MathHelper . floor ( this . locY - 0 . 20000000298023224D - ( double ) this . height ) ;
int i1 = MathHelper . floor ( this . locZ ) ;
2013-11-04 14:07:38 +01:00
Block block = this . world . getType ( l , k , i1 ) ;
int j1 = this . world . getType ( l , k - 1 , i1 ) . b ( ) ;
2012-11-06 13:05:28 +01:00
2013-11-04 14:07:38 +01:00
if ( j1 = = 11 | | j1 = = 32 | | j1 = = 21 ) {
block = this . world . getType ( l , k - 1 , i1 ) ;
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
2013-11-04 14:07:38 +01:00
if ( block ! = Blocks . LADDER ) {
2012-10-25 05:53:23 +02:00
d11 = 0 . 0D ;
}
2013-11-04 14:07:38 +01:00
this . Q = ( float ) ( ( double ) this . Q + ( double ) MathHelper . sqrt ( d10 * d10 + d12 * d12 ) * 0 . 6D ) ;
this . R = ( float ) ( ( double ) this . R + ( double ) MathHelper . sqrt ( d10 * d10 + d11 * d11 + d12 * d12 ) * 0 . 6D ) ;
if ( this . R > ( float ) this . d & & block . getMaterial ( ) ! = Material . AIR ) {
this . d = ( int ) this . R + 1 ;
if ( this . M ( ) ) {
2012-10-25 05:53:23 +02:00
float f = MathHelper . sqrt ( this . motX * this . motX * 0 . 20000000298023224D + this . motY * this . motY + this . motZ * this . motZ * 0 . 20000000298023224D ) * 0 . 35F ;
if ( f > 1 . 0F ) {
f = 1 . 0F ;
}
2013-11-04 14:07:38 +01:00
this . makeSound ( this . H ( ) , f , 1 . 0F + ( this . random . nextFloat ( ) - this . random . nextFloat ( ) ) * 0 . 4F ) ;
2012-10-25 05:53:23 +02:00
}
2013-11-04 14:07:38 +01:00
this . a ( l , k , i1 , block ) ;
block . b ( this . world , l , k , i1 , this ) ;
2011-01-03 12:37:41 +01:00
}
}
2011-01-29 22:50:29 +01:00
2013-11-04 14:07:38 +01:00
// CraftBukkit start - Move to the top of the method
/ *
2013-07-01 13:03:00 +02:00
try {
2013-11-04 14:07:38 +01:00
this . I ( ) ;
2013-07-01 13:03:00 +02:00
} catch ( Throwable throwable ) {
2013-11-04 14:07:38 +01:00
CrashReport crashreport = CrashReport . a ( throwable , " Checking entity block collision " ) ;
2013-07-01 13:03:00 +02:00
CrashReportSystemDetails crashreportsystemdetails = crashreport . a ( " Entity being checked for collision " ) ;
this . a ( crashreportsystemdetails ) ;
throw new ReportedException ( crashreport ) ;
}
2013-11-04 14:07:38 +01:00
* /
// CraftBukkit end
boolean flag2 = this . L ( ) ;
2011-01-29 22:50:29 +01:00
2012-07-29 09:33:13 +02:00
if ( this . world . e ( this . boundingBox . shrink ( 0 . 001D , 0 . 001D , 0 . 001D ) ) ) {
2011-06-27 00:25:01 +02:00
this . burn ( 1 ) ;
2011-01-29 22:50:29 +01:00
if ( ! flag2 ) {
+ + this . fireTicks ;
2013-03-25 05:22:32 +01:00
// CraftBukkit start - Not on fire yet
if ( this . fireTicks < = 0 ) { // Only throw events on the first combust, otherwise it spams
2011-11-29 08:10:05 +01:00
EntityCombustEvent event = new EntityCombustEvent ( this . getBukkitEntity ( ) , 8 ) ;
2011-06-27 00:25:01 +02:00
this . world . getServer ( ) . getPluginManager ( ) . callEvent ( event ) ;
2011-01-29 22:50:29 +01:00
2011-02-23 13:56:36 +01:00
if ( ! event . isCancelled ( ) ) {
2011-11-30 00:17:43 +01:00
this . setOnFire ( event . getDuration ( ) ) ;
2011-01-29 22:50:29 +01:00
}
} else {
2011-11-20 09:01:14 +01:00
// CraftBukkit end
2011-11-30 00:17:43 +01:00
this . setOnFire ( 8 ) ;
2011-01-18 06:30:01 +01:00
}
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
} else if ( this . fireTicks < = 0 ) {
this . fireTicks = - this . maxFireTicks ;
}
if ( flag2 & & this . fireTicks > 0 ) {
2012-11-06 13:05:28 +01:00
this . makeSound ( " random.fizz " , 0 . 7F , 1 . 6F + ( this . random . nextFloat ( ) - this . random . nextFloat ( ) ) * 0 . 4F ) ;
2011-01-29 22:50:29 +01:00
this . fireTicks = - this . maxFireTicks ;
2011-01-03 12:37:41 +01:00
}
2011-11-20 09:01:14 +01:00
2012-09-10 06:19:28 +02:00
this . world . methodProfiler . b ( ) ;
2012-07-29 09:33:13 +02:00
}
}
2013-11-04 14:07:38 +01:00
protected String H ( ) {
return " game.neutral.swim " ;
}
protected void I ( ) {
2012-07-29 09:33:13 +02:00
int i = MathHelper . floor ( this . boundingBox . a + 0 . 001D ) ;
int j = MathHelper . floor ( this . boundingBox . b + 0 . 001D ) ;
int k = MathHelper . floor ( this . boundingBox . c + 0 . 001D ) ;
int l = MathHelper . floor ( this . boundingBox . d - 0 . 001D ) ;
int i1 = MathHelper . floor ( this . boundingBox . e - 0 . 001D ) ;
int j1 = MathHelper . floor ( this . boundingBox . f - 0 . 001D ) ;
2013-11-04 14:07:38 +01:00
if ( this . world . b ( i , j , k , l , i1 , j1 ) ) {
2012-07-29 09:33:13 +02:00
for ( int k1 = i ; k1 < = l ; + + k1 ) {
for ( int l1 = j ; l1 < = i1 ; + + l1 ) {
for ( int i2 = k ; i2 < = j1 ; + + i2 ) {
2013-11-04 14:07:38 +01:00
Block block = this . world . getType ( k1 , l1 , i2 ) ;
try {
block . a ( this . world , k1 , l1 , i2 , this ) ;
} catch ( Throwable throwable ) {
CrashReport crashreport = CrashReport . a ( throwable , " Colliding entity with block " ) ;
CrashReportSystemDetails crashreportsystemdetails = crashreport . a ( " Block being collided with " ) ;
CrashReportSystemDetails . a ( crashreportsystemdetails , k1 , l1 , i2 , block , this . world . getData ( k1 , l1 , i2 ) ) ;
throw new ReportedException ( crashreport ) ;
2012-07-29 09:33:13 +02:00
}
}
}
}
2011-11-20 09:01:14 +01:00
}
}
2013-11-04 14:07:38 +01:00
protected void a ( int i , int j , int k , Block block ) {
StepSound stepsound = block . stepSound ;
2011-11-20 09:01:14 +01:00
2013-11-04 14:07:38 +01:00
if ( this . world . getType ( i , j + 1 , k ) = = Blocks . SNOW ) {
stepsound = Blocks . SNOW . stepSound ;
2012-11-06 13:05:28 +01:00
this . makeSound ( stepsound . getStepSound ( ) , stepsound . getVolume1 ( ) * 0 . 15F , stepsound . getVolume2 ( ) ) ;
2013-11-04 14:07:38 +01:00
} else if ( ! block . getMaterial ( ) . isLiquid ( ) ) {
2012-11-06 13:05:28 +01:00
this . makeSound ( stepsound . getStepSound ( ) , stepsound . getVolume1 ( ) * 0 . 15F , stepsound . getVolume2 ( ) ) ;
2011-01-03 12:37:41 +01:00
}
}
2012-12-20 05:03:52 +01:00
public void makeSound ( String s , float f , float f1 ) {
2012-11-06 13:05:28 +01:00
this . world . makeSound ( this , s , f , f1 ) ;
}
2013-11-04 14:07:38 +01:00
protected boolean g_ ( ) {
2011-03-31 22:40:00 +02:00
return true ;
}
2011-01-29 22:50:29 +01:00
protected void a ( double d0 , boolean flag ) {
2011-01-03 12:37:41 +01:00
if ( flag ) {
2011-01-29 22:50:29 +01:00
if ( this . fallDistance > 0 . 0F ) {
2013-07-01 13:03:00 +02:00
this . b ( this . fallDistance ) ;
2011-01-29 22:50:29 +01:00
this . fallDistance = 0 . 0F ;
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
} else if ( d0 < 0 . 0D ) {
this . fallDistance = ( float ) ( ( double ) this . fallDistance - d0 ) ;
2011-01-03 12:37:41 +01:00
}
}
2013-11-04 14:07:38 +01:00
public AxisAlignedBB J ( ) {
2011-01-03 12:37:41 +01:00
return null ;
}
2013-07-01 13:03:00 +02:00
protected void burn ( float i ) { // CraftBukkit - int -> float
2011-06-27 00:25:01 +02:00
if ( ! this . fireProof ) {
2013-07-01 13:03:00 +02:00
this . damageEntity ( DamageSource . FIRE , ( float ) i ) ;
2011-01-03 12:37:41 +01:00
}
}
2011-11-30 00:17:43 +01:00
public final boolean isFireproof ( ) {
2011-11-20 09:01:14 +01:00
return this . fireProof ;
}
2013-07-01 13:03:00 +02:00
protected void b ( float f ) {
2011-05-26 14:48:22 +02:00
if ( this . passenger ! = null ) {
2013-07-01 13:03:00 +02:00
this . passenger . b ( f ) ;
2011-05-26 14:48:22 +02:00
}
2011-04-20 22:47:26 +02:00
}
2013-11-04 14:07:38 +01:00
public boolean L ( ) {
2013-09-19 20:25:08 +02:00
return this . inWater | | this . world . isRainingAt ( MathHelper . floor ( this . locX ) , MathHelper . floor ( this . locY ) , MathHelper . floor ( this . locZ ) ) | | this . world . isRainingAt ( MathHelper . floor ( this . locX ) , MathHelper . floor ( this . locY + ( double ) this . length ) , MathHelper . floor ( this . locZ ) ) ;
2011-05-26 14:48:22 +02:00
}
2013-11-04 14:07:38 +01:00
public boolean M ( ) {
2013-03-20 21:09:23 +01:00
return this . inWater ;
2011-04-20 22:47:26 +02:00
}
2013-11-04 14:07:38 +01:00
public boolean N ( ) {
2012-11-06 13:05:28 +01:00
if ( this . world . a ( this . boundingBox . grow ( 0 . 0D , - 0 . 4000000059604645D , 0 . 0D ) . shrink ( 0 . 001D , 0 . 001D , 0 . 001D ) , Material . WATER , this ) ) {
2013-03-20 21:09:23 +01:00
if ( ! this . inWater & & ! this . justCreated ) {
2012-11-06 13:05:28 +01:00
float f = MathHelper . sqrt ( this . motX * this . motX * 0 . 20000000298023224D + this . motY * this . motY + this . motZ * this . motZ * 0 . 20000000298023224D ) * 0 . 2F ;
if ( f > 1 . 0F ) {
f = 1 . 0F ;
}
2013-11-04 14:07:38 +01:00
this . makeSound ( this . O ( ) , f , 1 . 0F + ( this . random . nextFloat ( ) - this . random . nextFloat ( ) ) * 0 . 4F ) ;
2012-11-06 13:05:28 +01:00
float f1 = ( float ) MathHelper . floor ( this . boundingBox . b ) ;
int i ;
float f2 ;
float f3 ;
for ( i = 0 ; ( float ) i < 1 . 0F + this . width * 20 . 0F ; + + i ) {
f2 = ( this . random . nextFloat ( ) * 2 . 0F - 1 . 0F ) * this . width ;
f3 = ( this . random . nextFloat ( ) * 2 . 0F - 1 . 0F ) * this . width ;
this . world . addParticle ( " bubble " , this . locX + ( double ) f2 , ( double ) ( f1 + 1 . 0F ) , this . locZ + ( double ) f3 , this . motX , this . motY - ( double ) ( this . random . nextFloat ( ) * 0 . 2F ) , this . motZ ) ;
}
for ( i = 0 ; ( float ) i < 1 . 0F + this . width * 20 . 0F ; + + i ) {
f2 = ( this . random . nextFloat ( ) * 2 . 0F - 1 . 0F ) * this . width ;
f3 = ( this . random . nextFloat ( ) * 2 . 0F - 1 . 0F ) * this . width ;
this . world . addParticle ( " splash " , this . locX + ( double ) f2 , ( double ) ( f1 + 1 . 0F ) , this . locZ + ( double ) f3 , this . motX , this . motY , this . motZ ) ;
}
}
this . fallDistance = 0 . 0F ;
2013-03-20 21:09:23 +01:00
this . inWater = true ;
2012-11-06 13:05:28 +01:00
this . fireTicks = 0 ;
} else {
2013-03-20 21:09:23 +01:00
this . inWater = false ;
2012-11-06 13:05:28 +01:00
}
2013-03-20 21:09:23 +01:00
return this . inWater ;
2011-01-03 12:37:41 +01:00
}
2013-11-04 14:07:38 +01:00
protected String O ( ) {
return " game.neutral.swim.splash " ;
}
2011-01-03 12:37:41 +01:00
public boolean a ( Material material ) {
2012-02-29 22:31:04 +01:00
double d0 = this . locY + ( double ) this . getHeadHeight ( ) ;
2011-04-20 19:05:14 +02:00
int i = MathHelper . floor ( this . locX ) ;
int j = MathHelper . d ( ( float ) MathHelper . floor ( d0 ) ) ;
int k = MathHelper . floor ( this . locZ ) ;
2013-11-04 14:07:38 +01:00
Block block = this . world . getType ( i , j , k ) ;
2011-01-03 12:37:41 +01:00
2013-11-04 14:07:38 +01:00
if ( block . getMaterial ( ) = = material ) {
float f = BlockFluids . b ( this . world . getData ( i , j , k ) ) - 0 . 11111111F ;
2011-01-29 22:50:29 +01:00
float f1 = ( float ) ( j + 1 ) - f ;
2011-01-03 12:37:41 +01:00
2011-01-29 22:50:29 +01:00
return d0 < ( double ) f1 ;
2011-01-03 12:37:41 +01:00
} else {
return false ;
}
}
2012-02-29 22:31:04 +01:00
public float getHeadHeight ( ) {
2011-01-03 12:37:41 +01:00
return 0 . 0F ;
}
2013-11-04 14:07:38 +01:00
public boolean P ( ) {
2012-01-12 16:27:39 +01:00
return this . world . a ( this . boundingBox . grow ( - 0 . 10000000149011612D , - 0 . 4000000059604645D , - 0 . 10000000149011612D ) , Material . LAVA ) ;
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
public void a ( float f , float f1 , float f2 ) {
2012-07-29 09:33:13 +02:00
float f3 = f * f + f1 * f1 ;
2011-01-03 12:37:41 +01:00
2012-07-29 09:33:13 +02:00
if ( f3 > = 1 . 0E - 4F ) {
f3 = MathHelper . c ( f3 ) ;
2011-01-29 22:50:29 +01:00
if ( f3 < 1 . 0F ) {
f3 = 1 . 0F ;
}
2011-01-03 12:37:41 +01:00
2011-01-29 22:50:29 +01:00
f3 = f2 / f3 ;
f * = f3 ;
f1 * = f3 ;
2011-04-20 19:05:14 +02:00
float f4 = MathHelper . sin ( this . yaw * 3 . 1415927F / 180 . 0F ) ;
float f5 = MathHelper . cos ( this . yaw * 3 . 1415927F / 180 . 0F ) ;
2011-01-03 12:37:41 +01:00
2011-01-29 22:50:29 +01:00
this . motX + = ( double ) ( f * f5 - f1 * f4 ) ;
this . motZ + = ( double ) ( f1 * f5 + f * f4 ) ;
2011-01-14 14:31:10 +01:00
}
2011-01-03 12:37:41 +01:00
}
2013-07-01 13:03:00 +02:00
public float d ( float f ) {
2011-04-20 19:05:14 +02:00
int i = MathHelper . floor ( this . locX ) ;
2011-09-15 02:23:52 +02:00
int j = MathHelper . floor ( this . locZ ) ;
2011-01-29 22:50:29 +01:00
2012-03-01 11:49:23 +01:00
if ( this . world . isLoaded ( i , 0 , j ) ) {
2011-09-15 02:23:52 +02:00
double d0 = ( this . boundingBox . e - this . boundingBox . b ) * 0 . 66D ;
int k = MathHelper . floor ( this . locY - ( double ) this . height + d0 ) ;
2011-06-30 00:02:25 +02:00
2013-11-04 14:07:38 +01:00
return this . world . n ( i , k , j ) ;
2011-06-30 00:02:25 +02:00
} else {
2011-09-15 02:23:52 +02:00
return 0 . 0F ;
2011-06-30 00:02:25 +02:00
}
2011-05-26 14:48:22 +02:00
}
2011-06-27 00:25:01 +02:00
public void spawnIn ( World world ) {
2011-06-08 19:40:40 +02:00
// CraftBukkit start
2011-06-12 00:02:58 +02:00
if ( world = = null ) {
2011-06-08 19:40:40 +02:00
this . die ( ) ;
2012-07-22 08:18:00 +02:00
this . world = ( ( CraftWorld ) Bukkit . getServer ( ) . getWorlds ( ) . get ( 0 ) ) . getHandle ( ) ;
2011-06-27 00:25:01 +02:00
return ;
2011-06-08 19:40:40 +02:00
}
// CraftBukkit end
2012-07-29 09:33:13 +02:00
2011-06-27 00:25:01 +02:00
this . world = world ;
2011-01-29 22:50:29 +01:00
}
2011-01-03 12:37:41 +01:00
2011-04-20 19:05:14 +02:00
public void setLocation ( double d0 , double d1 , double d2 , float f , float f1 ) {
2011-01-29 22:50:29 +01:00
this . lastX = this . locX = d0 ;
this . lastY = this . locY = d1 ;
this . lastZ = this . locZ = d2 ;
this . lastYaw = this . yaw = f ;
this . lastPitch = this . pitch = f1 ;
2013-11-04 14:07:38 +01:00
this . W = 0 . 0F ;
2011-01-29 22:50:29 +01:00
double d3 = ( double ) ( this . lastYaw - f ) ;
if ( d3 < - 180 . 0D ) {
this . lastYaw + = 360 . 0F ;
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
if ( d3 > = 180 . 0D ) {
this . lastYaw - = 360 . 0F ;
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
2011-04-20 19:05:14 +02:00
this . setPosition ( this . locX , this . locY , this . locZ ) ;
2012-07-29 09:33:13 +02:00
this . b ( f , f1 ) ;
2011-01-03 12:37:41 +01:00
}
2011-04-20 19:05:14 +02:00
public void setPositionRotation ( double d0 , double d1 , double d2 , float f , float f1 ) {
2013-11-04 14:07:38 +01:00
this . T = this . lastX = this . locX = d0 ;
this . U = this . lastY = this . locY = d1 + ( double ) this . height ;
this . V = this . lastZ = this . locZ = d2 ;
2011-01-29 22:50:29 +01:00
this . yaw = f ;
this . pitch = f1 ;
2011-04-20 19:05:14 +02:00
this . setPosition ( this . locX , this . locY , this . locZ ) ;
2011-01-03 12:37:41 +01:00
}
2012-07-29 09:33:13 +02:00
public float d ( Entity entity ) {
2011-01-29 22:50:29 +01:00
float f = ( float ) ( this . locX - entity . locX ) ;
float f1 = ( float ) ( this . locY - entity . locY ) ;
float f2 = ( float ) ( this . locZ - entity . locZ ) ;
2011-01-03 12:37:41 +01:00
2011-01-29 22:50:29 +01:00
return MathHelper . c ( f * f + f1 * f1 + f2 * f2 ) ;
2011-01-03 12:37:41 +01:00
}
2011-07-08 14:25:53 +02:00
public double e ( double d0 , double d1 , double d2 ) {
2011-01-29 22:50:29 +01:00
double d3 = this . locX - d0 ;
double d4 = this . locY - d1 ;
double d5 = this . locZ - d2 ;
2011-01-03 12:37:41 +01:00
2011-01-29 22:50:29 +01:00
return d3 * d3 + d4 * d4 + d5 * d5 ;
2011-01-03 12:37:41 +01:00
}
2011-07-08 14:25:53 +02:00
public double f ( double d0 , double d1 , double d2 ) {
2011-01-29 22:50:29 +01:00
double d3 = this . locX - d0 ;
double d4 = this . locY - d1 ;
double d5 = this . locZ - d2 ;
2011-01-03 12:37:41 +01:00
2012-01-14 21:03:48 +01:00
return ( double ) MathHelper . sqrt ( d3 * d3 + d4 * d4 + d5 * d5 ) ;
2011-01-03 12:37:41 +01:00
}
2012-07-29 09:33:13 +02:00
public double e ( Entity entity ) {
2011-01-29 22:50:29 +01:00
double d0 = this . locX - entity . locX ;
double d1 = this . locY - entity . locY ;
double d2 = this . locZ - entity . locZ ;
2011-01-03 12:37:41 +01:00
2011-01-29 22:50:29 +01:00
return d0 * d0 + d1 * d1 + d2 * d2 ;
2011-01-03 12:37:41 +01:00
}
2013-03-13 23:33:27 +01:00
public void b_ ( EntityHuman entityhuman ) { }
2011-01-03 12:37:41 +01:00
2011-04-20 19:05:14 +02:00
public void collide ( Entity entity ) {
2011-01-29 22:50:29 +01:00
if ( entity . passenger ! = this & & entity . vehicle ! = this ) {
double d0 = entity . locX - this . locX ;
double d1 = entity . locZ - this . locZ ;
double d2 = MathHelper . a ( d0 , d1 ) ;
if ( d2 > = 0 . 009999999776482582D ) {
2012-01-14 21:03:48 +01:00
d2 = ( double ) MathHelper . sqrt ( d2 ) ;
2011-01-29 22:50:29 +01:00
d0 / = d2 ;
d1 / = d2 ;
double d3 = 1 . 0D / d2 ;
if ( d3 > 1 . 0D ) {
d3 = 1 . 0D ;
}
d0 * = d3 ;
d1 * = d3 ;
d0 * = 0 . 05000000074505806D ;
d1 * = 0 . 05000000074505806D ;
2013-11-04 14:07:38 +01:00
d0 * = ( double ) ( 1 . 0F - this . Z ) ;
d1 * = ( double ) ( 1 . 0F - this . Z ) ;
2012-07-29 09:33:13 +02:00
this . g ( - d0 , 0 . 0D , - d1 ) ;
entity . g ( d0 , 0 . 0D , d1 ) ;
2011-01-29 22:50:29 +01:00
}
2011-01-03 12:37:41 +01:00
}
}
2012-07-29 09:33:13 +02:00
public void g ( double d0 , double d1 , double d2 ) {
2011-01-29 22:50:29 +01:00
this . motX + = d0 ;
this . motY + = d1 ;
this . motZ + = d2 ;
2013-11-04 14:07:38 +01:00
this . am = true ;
2011-01-03 12:37:41 +01:00
}
2013-11-04 14:07:38 +01:00
protected void Q ( ) {
2011-04-20 19:05:14 +02:00
this . velocityChanged = true ;
2011-01-03 12:37:41 +01:00
}
2013-07-01 13:03:00 +02:00
public boolean damageEntity ( DamageSource damagesource , float f ) {
2012-11-06 13:05:28 +01:00
if ( this . isInvulnerable ( ) ) {
return false ;
} else {
2013-11-04 14:07:38 +01:00
this . Q ( ) ;
2012-11-06 13:05:28 +01:00
return false ;
}
2011-01-03 12:37:41 +01:00
}
2013-11-04 14:07:38 +01:00
public boolean R ( ) {
2011-01-03 12:37:41 +01:00
return false ;
}
2013-11-04 14:07:38 +01:00
public boolean S ( ) {
2011-01-03 12:37:41 +01:00
return false ;
}
2013-07-01 13:03:00 +02:00
public void b ( Entity entity , int i ) { }
2011-01-03 12:37:41 +01:00
public boolean c ( NBTTagCompound nbttagcompound ) {
2013-11-04 14:07:38 +01:00
String s = this . W ( ) ;
2011-01-03 12:37:41 +01:00
2011-01-29 22:50:29 +01:00
if ( ! this . dead & & s ! = null ) {
2011-04-20 19:05:14 +02:00
nbttagcompound . setString ( " id " , s ) ;
2013-03-13 23:33:27 +01:00
this . e ( nbttagcompound ) ;
2011-01-03 12:37:41 +01:00
return true ;
2011-01-29 22:50:29 +01:00
} else {
return false ;
2011-01-03 12:37:41 +01:00
}
}
2013-03-13 23:33:27 +01:00
public boolean d ( NBTTagCompound nbttagcompound ) {
2013-11-04 14:07:38 +01:00
String s = this . W ( ) ;
2013-03-13 23:33:27 +01:00
if ( ! this . dead & & s ! = null & & this . passenger = = null ) {
nbttagcompound . setString ( " id " , s ) ;
this . e ( nbttagcompound ) ;
return true ;
} else {
return false ;
}
}
public void e ( NBTTagCompound nbttagcompound ) {
2012-11-06 13:05:28 +01:00
try {
2013-11-04 14:07:38 +01:00
nbttagcompound . set ( " Pos " , this . a ( new double [ ] { this . locX , this . locY + ( double ) this . W , this . locZ } ) ) ;
2012-11-06 13:05:28 +01:00
nbttagcompound . set ( " Motion " , this . a ( new double [ ] { this . motX , this . motY , this . motZ } ) ) ;
2013-03-25 05:22:32 +01:00
// CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero
2012-11-06 13:05:28 +01:00
// TODO: make sure this is the best way to address this.
if ( Float . isNaN ( this . yaw ) ) {
this . yaw = 0 ;
}
2011-04-25 02:14:33 +02:00
2012-11-06 13:05:28 +01:00
if ( Float . isNaN ( this . pitch ) ) {
this . pitch = 0 ;
}
// CraftBukkit end
2011-04-25 02:14:33 +02:00
2012-11-06 13:05:28 +01:00
nbttagcompound . set ( " Rotation " , this . a ( new float [ ] { this . yaw , this . pitch } ) ) ;
nbttagcompound . setFloat ( " FallDistance " , this . fallDistance ) ;
nbttagcompound . setShort ( " Fire " , ( short ) this . fireTicks ) ;
nbttagcompound . setShort ( " Air " , ( short ) this . getAirTicks ( ) ) ;
nbttagcompound . setBoolean ( " OnGround " , this . onGround ) ;
nbttagcompound . setInt ( " Dimension " , this . dimension ) ;
nbttagcompound . setBoolean ( " Invulnerable " , this . invulnerable ) ;
nbttagcompound . setInt ( " PortalCooldown " , this . portalCooldown ) ;
2013-11-04 14:07:38 +01:00
nbttagcompound . setLong ( " UUIDMost " , this . getUniqueID ( ) . getMostSignificantBits ( ) ) ;
nbttagcompound . setLong ( " UUIDLeast " , this . getUniqueID ( ) . getLeastSignificantBits ( ) ) ;
2012-11-06 13:05:28 +01:00
// CraftBukkit start
nbttagcompound . setLong ( " WorldUUIDLeast " , this . world . getDataManager ( ) . getUUID ( ) . getLeastSignificantBits ( ) ) ;
nbttagcompound . setLong ( " WorldUUIDMost " , this . world . getDataManager ( ) . getUUID ( ) . getMostSignificantBits ( ) ) ;
2012-12-11 12:32:05 +01:00
nbttagcompound . setInt ( " Bukkit.updateLevel " , CURRENT_LEVEL ) ;
2012-11-06 13:05:28 +01:00
// CraftBukkit end
this . b ( nbttagcompound ) ;
2013-03-13 23:33:27 +01:00
if ( this . vehicle ! = null ) {
2013-11-04 14:07:38 +01:00
NBTTagCompound nbttagcompound1 = new NBTTagCompound ( ) ;
2013-03-13 23:33:27 +01:00
if ( this . vehicle . c ( nbttagcompound1 ) ) {
nbttagcompound . set ( " Riding " , nbttagcompound1 ) ;
}
}
2012-11-06 13:05:28 +01:00
} catch ( Throwable throwable ) {
CrashReport crashreport = CrashReport . a ( throwable , " Saving entity NBT " ) ;
CrashReportSystemDetails crashreportsystemdetails = crashreport . a ( " Entity being saved " ) ;
2011-04-25 02:14:33 +02:00
2012-11-06 13:05:28 +01:00
this . a ( crashreportsystemdetails ) ;
throw new ReportedException ( crashreport ) ;
}
2011-01-03 12:37:41 +01:00
}
2013-03-13 23:33:27 +01:00
public void f ( NBTTagCompound nbttagcompound ) {
2012-11-06 13:05:28 +01:00
try {
2013-11-04 14:07:38 +01:00
NBTTagList nbttaglist = nbttagcompound . getList ( " Pos " , 6 ) ;
NBTTagList nbttaglist1 = nbttagcompound . getList ( " Motion " , 6 ) ;
NBTTagList nbttaglist2 = nbttagcompound . getList ( " Rotation " , 5 ) ;
2012-11-06 13:05:28 +01:00
2013-11-04 14:07:38 +01:00
this . motX = nbttaglist1 . d ( 0 ) ;
this . motY = nbttaglist1 . d ( 1 ) ;
this . motZ = nbttaglist1 . d ( 2 ) ;
2013-03-25 05:22:32 +01:00
/ * CraftBukkit start - Moved section down
2011-05-24 04:42:30 +02:00
if ( Math . abs ( this . motX ) > 10 . 0D ) {
this . motX = 0 . 0D ;
}
if ( Math . abs ( this . motY ) > 10 . 0D ) {
this . motY = 0 . 0D ;
}
if ( Math . abs ( this . motZ ) > 10 . 0D ) {
this . motZ = 0 . 0D ;
}
2012-11-06 13:05:28 +01:00
// CraftBukkit end */
2013-11-04 14:07:38 +01:00
this . lastX = this . T = this . locX = nbttaglist . d ( 0 ) ;
this . lastY = this . U = this . locY = nbttaglist . d ( 1 ) ;
this . lastZ = this . V = this . locZ = nbttaglist . d ( 2 ) ;
this . lastYaw = this . yaw = nbttaglist2 . e ( 0 ) ;
this . lastPitch = this . pitch = nbttaglist2 . e ( 1 ) ;
2012-11-06 13:05:28 +01:00
this . fallDistance = nbttagcompound . getFloat ( " FallDistance " ) ;
this . fireTicks = nbttagcompound . getShort ( " Fire " ) ;
this . setAirTicks ( nbttagcompound . getShort ( " Air " ) ) ;
this . onGround = nbttagcompound . getBoolean ( " OnGround " ) ;
this . dimension = nbttagcompound . getInt ( " Dimension " ) ;
this . invulnerable = nbttagcompound . getBoolean ( " Invulnerable " ) ;
this . portalCooldown = nbttagcompound . getInt ( " PortalCooldown " ) ;
2013-11-04 14:07:38 +01:00
if ( nbttagcompound . hasKeyOfType ( " UUIDMost " , 4 ) & & nbttagcompound . hasKeyOfType ( " UUIDLeast " , 4 ) ) {
2013-03-13 23:33:27 +01:00
this . uniqueID = new UUID ( nbttagcompound . getLong ( " UUIDMost " ) , nbttagcompound . getLong ( " UUIDLeast " ) ) ;
2012-11-06 13:05:28 +01:00
}
2011-06-27 00:25:01 +02:00
2013-03-13 23:33:27 +01:00
this . setPosition ( this . locX , this . locY , this . locZ ) ;
2012-11-06 13:05:28 +01:00
this . b ( this . yaw , this . pitch ) ;
this . a ( nbttagcompound ) ;
2013-11-04 14:07:38 +01:00
if ( this . V ( ) ) {
2013-07-09 01:43:37 +02:00
this . setPosition ( this . locX , this . locY , this . locZ ) ;
}
2011-06-27 00:25:01 +02:00
2012-12-27 02:07:47 +01:00
// CraftBukkit start
if ( this instanceof EntityLiving ) {
EntityLiving entity = ( EntityLiving ) this ;
2012-12-29 03:27:41 +01:00
// Reset the persistence for tamed animals
if ( entity instanceof EntityTameableAnimal & & ! isLevelAtLeast ( nbttagcompound , 2 ) & & ! nbttagcompound . getBoolean ( " PersistenceRequired " ) ) {
2013-07-01 13:03:00 +02:00
EntityInsentient entityinsentient = ( EntityInsentient ) entity ;
entityinsentient . persistent = ! entityinsentient . isTypeNotPersistent ( ) ;
2012-12-29 03:27:41 +01:00
}
2012-12-27 02:07:47 +01:00
}
// CraftBukkit end
2013-03-25 05:22:32 +01:00
// CraftBukkit start - Exempt Vehicles from notch's sanity check
2012-11-06 13:05:28 +01:00
if ( ! ( this . getBukkitEntity ( ) instanceof Vehicle ) ) {
if ( Math . abs ( this . motX ) > 10 . 0D ) {
this . motX = 0 . 0D ;
}
if ( Math . abs ( this . motY ) > 10 . 0D ) {
this . motY = 0 . 0D ;
}
if ( Math . abs ( this . motZ ) > 10 . 0D ) {
this . motZ = 0 . 0D ;
}
2011-07-13 07:16:59 +02:00
}
2012-11-06 13:05:28 +01:00
// CraftBukkit end
2013-03-25 05:22:32 +01:00
// CraftBukkit start - Reset world
2012-11-06 13:05:28 +01:00
if ( this instanceof EntityPlayer ) {
Server server = Bukkit . getServer ( ) ;
org . bukkit . World bworld = null ;
// TODO: Remove World related checks, replaced with WorldUID.
String worldName = nbttagcompound . getString ( " World " ) ;
if ( nbttagcompound . hasKey ( " WorldUUIDMost " ) & & nbttagcompound . hasKey ( " WorldUUIDLeast " ) ) {
UUID uid = new UUID ( nbttagcompound . getLong ( " WorldUUIDMost " ) , nbttagcompound . getLong ( " WorldUUIDLeast " ) ) ;
bworld = server . getWorld ( uid ) ;
} else {
bworld = server . getWorld ( worldName ) ;
}
if ( bworld = = null ) {
EntityPlayer entityPlayer = ( EntityPlayer ) this ;
bworld = ( ( org . bukkit . craftbukkit . CraftServer ) server ) . getServer ( ) . getWorldServer ( entityPlayer . dimension ) . getWorld ( ) ;
}
2012-07-29 09:33:13 +02:00
2012-11-06 13:05:28 +01:00
this . spawnIn ( bworld = = null ? null : ( ( CraftWorld ) bworld ) . getHandle ( ) ) ;
2011-07-13 07:16:59 +02:00
}
2012-11-06 13:05:28 +01:00
// CraftBukkit end
} catch ( Throwable throwable ) {
CrashReport crashreport = CrashReport . a ( throwable , " Loading entity NBT " ) ;
CrashReportSystemDetails crashreportsystemdetails = crashreport . a ( " Entity being loaded " ) ;
2011-06-16 05:24:31 +02:00
2012-11-06 13:05:28 +01:00
this . a ( crashreportsystemdetails ) ;
throw new ReportedException ( crashreport ) ;
2011-07-13 07:16:59 +02:00
}
2011-01-03 12:37:41 +01:00
}
2013-11-04 14:07:38 +01:00
protected boolean V ( ) {
2013-07-09 01:43:37 +02:00
return true ;
}
2013-11-04 14:07:38 +01:00
protected final String W ( ) {
2011-01-29 22:50:29 +01:00
return EntityTypes . b ( this ) ;
2011-01-03 12:37:41 +01:00
}
protected abstract void a ( NBTTagCompound nbttagcompound ) ;
2011-04-20 22:47:26 +02:00
protected abstract void b ( NBTTagCompound nbttagcompound ) ;
2013-11-04 14:07:38 +01:00
public void X ( ) { }
2013-07-01 13:03:00 +02:00
2011-01-29 22:50:29 +01:00
protected NBTTagList a ( double . . . adouble ) {
2011-01-03 12:37:41 +01:00
NBTTagList nbttaglist = new NBTTagList ( ) ;
2011-01-29 22:50:29 +01:00
double [ ] adouble1 = adouble ;
int i = adouble . length ;
2011-01-03 12:37:41 +01:00
2011-01-29 22:50:29 +01:00
for ( int j = 0 ; j < i ; + + j ) {
double d0 = adouble1 [ j ] ;
2011-01-03 12:37:41 +01:00
2013-11-04 14:07:38 +01:00
nbttaglist . add ( new NBTTagDouble ( d0 ) ) ;
2011-01-03 12:37:41 +01:00
}
return nbttaglist ;
}
2011-01-29 22:50:29 +01:00
protected NBTTagList a ( float . . . afloat ) {
2011-01-03 12:37:41 +01:00
NBTTagList nbttaglist = new NBTTagList ( ) ;
2011-01-29 22:50:29 +01:00
float [ ] afloat1 = afloat ;
int i = afloat . length ;
2011-01-03 12:37:41 +01:00
2011-01-29 22:50:29 +01:00
for ( int j = 0 ; j < i ; + + j ) {
float f = afloat1 [ j ] ;
2011-01-03 12:37:41 +01:00
2013-11-04 14:07:38 +01:00
nbttaglist . add ( new NBTTagFloat ( f ) ) ;
2011-01-03 12:37:41 +01:00
}
return nbttaglist ;
}
2013-11-04 14:07:38 +01:00
public EntityItem a ( Item item , int i ) {
return this . a ( item , i , 0 . 0F ) ;
2011-01-03 12:37:41 +01:00
}
2013-11-04 14:07:38 +01:00
public EntityItem a ( Item item , int i , float f ) {
return this . a ( new ItemStack ( item , i , 0 ) , f ) ;
2011-01-14 14:31:10 +01:00
}
2011-01-29 22:50:29 +01:00
public EntityItem a ( ItemStack itemstack , float f ) {
2013-11-04 14:07:38 +01:00
if ( itemstack . count ! = 0 & & itemstack . getItem ( ) ! = null ) {
2013-07-01 13:03:00 +02:00
EntityItem entityitem = new EntityItem ( this . world , this . locX , this . locY + ( double ) f , this . locZ , itemstack ) ;
2011-01-03 12:37:41 +01:00
2013-07-01 13:03:00 +02:00
entityitem . pickupDelay = 10 ;
this . world . addEntity ( entityitem ) ;
return entityitem ;
2013-11-04 14:07:38 +01:00
} else {
return null ;
2013-07-01 13:03:00 +02:00
}
2011-01-03 12:37:41 +01:00
}
2011-11-30 00:17:43 +01:00
public boolean isAlive ( ) {
2011-01-29 22:50:29 +01:00
return ! this . dead ;
2011-01-03 12:37:41 +01:00
}
2012-01-14 21:03:48 +01:00
public boolean inBlock ( ) {
2011-05-26 14:48:22 +02:00
for ( int i = 0 ; i < 8 ; + + i ) {
2011-11-30 00:17:43 +01:00
float f = ( ( float ) ( ( i > > 0 ) % 2 ) - 0 . 5F ) * this . width * 0 . 8F ;
2011-05-26 14:48:22 +02:00
float f1 = ( ( float ) ( ( i > > 1 ) % 2 ) - 0 . 5F ) * 0 . 1F ;
2011-11-30 00:17:43 +01:00
float f2 = ( ( float ) ( ( i > > 2 ) % 2 ) - 0 . 5F ) * this . width * 0 . 8F ;
2011-05-26 14:48:22 +02:00
int j = MathHelper . floor ( this . locX + ( double ) f ) ;
2012-02-29 22:31:04 +01:00
int k = MathHelper . floor ( this . locY + ( double ) this . getHeadHeight ( ) + ( double ) f1 ) ;
2011-05-26 14:48:22 +02:00
int l = MathHelper . floor ( this . locZ + ( double ) f2 ) ;
2013-11-04 14:07:38 +01:00
if ( this . world . getType ( j , k , l ) . r ( ) ) {
2011-05-26 14:48:22 +02:00
return true ;
}
}
2011-01-03 12:37:41 +01:00
2011-05-26 14:48:22 +02:00
return false ;
2011-01-03 12:37:41 +01:00
}
2013-07-01 13:03:00 +02:00
public boolean c ( EntityHuman entityhuman ) {
2011-01-03 12:37:41 +01:00
return false ;
}
2012-07-29 09:33:13 +02:00
public AxisAlignedBB g ( Entity entity ) {
2011-01-03 12:37:41 +01:00
return null ;
}
2013-11-04 14:07:38 +01:00
public void ab ( ) {
2011-01-29 22:50:29 +01:00
if ( this . vehicle . dead ) {
this . vehicle = null ;
} else {
this . motX = 0 . 0D ;
this . motY = 0 . 0D ;
this . motZ = 0 . 0D ;
2013-11-04 14:07:38 +01:00
this . h ( ) ;
2011-05-26 14:48:22 +02:00
if ( this . vehicle ! = null ) {
2013-11-04 14:07:38 +01:00
this . vehicle . ac ( ) ;
this . h + = ( double ) ( this . vehicle . yaw - this . vehicle . lastYaw ) ;
2011-01-29 22:50:29 +01:00
2013-11-04 14:07:38 +01:00
for ( this . g + = ( double ) ( this . vehicle . pitch - this . vehicle . lastPitch ) ; this . h > = 180 . 0D ; this . h - = 360 . 0D ) {
2011-05-26 14:48:22 +02:00
;
}
2011-01-03 12:37:41 +01:00
2013-11-04 14:07:38 +01:00
while ( this . h < - 180 . 0D ) {
this . h + = 360 . 0D ;
2011-05-26 14:48:22 +02:00
}
2011-01-29 22:50:29 +01:00
2013-11-04 14:07:38 +01:00
while ( this . g > = 180 . 0D ) {
this . g - = 360 . 0D ;
2011-05-26 14:48:22 +02:00
}
2011-01-29 22:50:29 +01:00
2013-11-04 14:07:38 +01:00
while ( this . g < - 180 . 0D ) {
this . g + = 360 . 0D ;
2011-05-26 14:48:22 +02:00
}
2011-01-29 22:50:29 +01:00
2013-11-04 14:07:38 +01:00
double d0 = this . h * 0 . 5D ;
double d1 = this . g * 0 . 5D ;
2011-05-26 14:48:22 +02:00
float f = 10 . 0F ;
2011-01-29 22:50:29 +01:00
2011-05-26 14:48:22 +02:00
if ( d0 > ( double ) f ) {
d0 = ( double ) f ;
}
2011-01-29 22:50:29 +01:00
2011-05-26 14:48:22 +02:00
if ( d0 < ( double ) ( - f ) ) {
d0 = ( double ) ( - f ) ;
}
2011-01-29 22:50:29 +01:00
2011-05-26 14:48:22 +02:00
if ( d1 > ( double ) f ) {
d1 = ( double ) f ;
}
2011-01-29 22:50:29 +01:00
2011-05-26 14:48:22 +02:00
if ( d1 < ( double ) ( - f ) ) {
d1 = ( double ) ( - f ) ;
}
2011-01-29 22:50:29 +01:00
2013-11-04 14:07:38 +01:00
this . h - = d0 ;
this . g - = d1 ;
2011-05-26 14:48:22 +02:00
}
2011-01-03 12:37:41 +01:00
}
}
2013-11-04 14:07:38 +01:00
public void ac ( ) {
2013-03-13 23:33:27 +01:00
if ( this . passenger ! = null ) {
2013-11-04 14:07:38 +01:00
this . passenger . setPosition ( this . locX , this . locY + this . ae ( ) + this . passenger . ad ( ) , this . locZ ) ;
2013-03-13 23:33:27 +01:00
}
2011-01-03 12:37:41 +01:00
}
2013-11-04 14:07:38 +01:00
public double ad ( ) {
2011-01-29 22:50:29 +01:00
return ( double ) this . height ;
2011-01-03 12:37:41 +01:00
}
2013-11-04 14:07:38 +01:00
public double ae ( ) {
2011-11-30 00:17:43 +01:00
return ( double ) this . length * 0 . 75D ;
2011-01-03 12:37:41 +01:00
}
2011-04-20 19:05:14 +02:00
public void mount ( Entity entity ) {
2011-01-11 09:25:13 +01:00
// CraftBukkit start
2011-06-27 00:25:01 +02:00
this . setPassengerOf ( entity ) ;
2011-01-11 09:25:13 +01:00
}
2012-12-22 19:46:24 +01:00
protected CraftEntity bukkitEntity ;
2011-01-30 16:15:17 +01:00
2012-12-22 19:46:24 +01:00
public CraftEntity getBukkitEntity ( ) {
2011-06-27 00:25:01 +02:00
if ( this . bukkitEntity = = null ) {
2013-03-25 05:22:32 +01:00
this . bukkitEntity = CraftEntity . getEntity ( this . world . getServer ( ) , this ) ;
2011-01-30 16:15:17 +01:00
}
2011-06-27 00:25:01 +02:00
return this . bukkitEntity ;
2011-01-29 22:50:29 +01:00
}
2011-01-08 01:26:08 +01:00
public void setPassengerOf ( Entity entity ) {
2011-02-23 03:37:56 +01:00
// b(null) doesn't really fly for overloaded methods,
2011-01-08 01:26:08 +01:00
// so this method is needed
2011-01-11 09:25:13 +01:00
2013-07-13 00:45:42 +02:00
Entity originalVehicle = this . vehicle ;
Entity originalPassenger = this . vehicle = = null ? null : this . vehicle . passenger ;
2011-12-19 08:32:35 +01:00
PluginManager pluginManager = Bukkit . getPluginManager ( ) ;
this . getBukkitEntity ( ) ; // make sure bukkitEntity is initialised
2011-01-21 06:54:30 +01:00
// CraftBukkit end
2012-10-25 05:53:23 +02:00
this . g = 0 . 0D ;
2013-11-04 14:07:38 +01:00
this . h = 0 . 0D ;
2011-01-03 12:37:41 +01:00
if ( entity = = null ) {
2011-01-29 22:50:29 +01:00
if ( this . vehicle ! = null ) {
2011-02-23 13:56:36 +01:00
// CraftBukkit start
2011-12-19 08:32:35 +01:00
if ( ( this . bukkitEntity instanceof LivingEntity ) & & ( this . vehicle . getBukkitEntity ( ) instanceof Vehicle ) ) {
VehicleExitEvent event = new VehicleExitEvent ( ( Vehicle ) this . vehicle . getBukkitEntity ( ) , ( LivingEntity ) this . bukkitEntity ) ;
pluginManager . callEvent ( event ) ;
2013-07-13 00:45:42 +02:00
if ( event . isCancelled ( ) | | this . vehicle ! = originalVehicle ) {
return ;
}
2011-02-01 11:02:43 +01:00
}
2011-02-23 13:56:36 +01:00
// CraftBukkit end
2011-02-01 11:02:43 +01:00
2011-11-30 00:17:43 +01:00
this . setPositionRotation ( this . vehicle . locX , this . vehicle . boundingBox . b + ( double ) this . vehicle . length , this . vehicle . locZ , this . yaw , this . pitch ) ;
2011-01-29 22:50:29 +01:00
this . vehicle . passenger = null ;
2011-01-03 12:37:41 +01:00
}
2011-01-29 22:50:29 +01:00
this . vehicle = null ;
} else {
2011-12-16 21:31:00 +01:00
// CraftBukkit start
2013-03-22 10:13:32 +01:00
if ( ( this . bukkitEntity instanceof LivingEntity ) & & ( entity . getBukkitEntity ( ) instanceof Vehicle ) & & entity . world . isChunkLoaded ( ( int ) entity . locX > > 4 , ( int ) entity . locZ > > 4 ) ) {
2013-07-13 00:45:42 +02:00
// It's possible to move from one vehicle to another. We need to check if they're already in a vehicle, and fire an exit event if they are.
VehicleExitEvent exitEvent = null ;
2013-09-08 00:01:45 +02:00
if ( this . vehicle ! = null & & this . vehicle . getBukkitEntity ( ) instanceof Vehicle ) {
2013-07-13 00:45:42 +02:00
exitEvent = new VehicleExitEvent ( ( Vehicle ) this . vehicle . getBukkitEntity ( ) , ( LivingEntity ) this . bukkitEntity ) ;
pluginManager . callEvent ( exitEvent ) ;
if ( exitEvent . isCancelled ( ) | | this . vehicle ! = originalVehicle | | ( this . vehicle ! = null & & this . vehicle . passenger ! = originalPassenger ) ) {
return ;
}
}
2011-12-19 08:32:35 +01:00
VehicleEnterEvent event = new VehicleEnterEvent ( ( Vehicle ) entity . getBukkitEntity ( ) , this . bukkitEntity ) ;
pluginManager . callEvent ( event ) ;
2013-07-13 00:45:42 +02:00
// If a plugin messes with the vehicle or the vehicle's passenger
if ( event . isCancelled ( ) | | this . vehicle ! = originalVehicle | | ( this . vehicle ! = null & & this . vehicle . passenger ! = originalPassenger ) ) {
// If we only cancelled the enterevent then we need to put the player in a decent position.
if ( exitEvent ! = null & & this . vehicle = = originalVehicle & & this . vehicle ! = null & & this . vehicle . passenger = = originalPassenger ) {
this . setPositionRotation ( this . vehicle . locX , this . vehicle . boundingBox . b + ( double ) this . vehicle . length , this . vehicle . locZ , this . yaw , this . pitch ) ;
this . vehicle . passenger = null ;
this . vehicle = null ;
}
2011-12-16 21:31:00 +01:00
return ;
}
}
// CraftBukkit end
2011-01-29 22:50:29 +01:00
if ( this . vehicle ! = null ) {
this . vehicle . passenger = null ;
}
this . vehicle = entity ;
entity . passenger = this ;
2011-01-03 12:37:41 +01:00
}
}
2013-11-04 14:07:38 +01:00
public float af ( ) {
2011-11-20 09:01:14 +01:00
return 0 . 1F ;
}
2013-11-04 14:07:38 +01:00
public Vec3D ag ( ) {
2011-01-03 12:37:41 +01:00
return null ;
}
2013-11-04 14:07:38 +01:00
public void ah ( ) {
2012-11-06 13:05:28 +01:00
if ( this . portalCooldown > 0 ) {
2013-11-04 14:07:38 +01:00
this . portalCooldown = this . ai ( ) ;
2012-10-25 05:53:23 +02:00
} else {
double d0 = this . lastX - this . locX ;
double d1 = this . lastZ - this . locZ ;
2013-11-04 14:07:38 +01:00
if ( ! this . world . isStatic & & ! this . ao ) {
this . ar = Direction . a ( d0 , d1 ) ;
2012-10-25 05:53:23 +02:00
}
2013-11-04 14:07:38 +01:00
this . ao = true ;
2012-10-25 05:53:23 +02:00
}
}
2013-11-04 14:07:38 +01:00
public int ai ( ) {
return 300 ;
2012-10-25 05:53:23 +02:00
}
2011-01-03 12:37:41 +01:00
2011-04-20 19:05:14 +02:00
public ItemStack [ ] getEquipment ( ) {
2011-01-03 12:37:41 +01:00
return null ;
}
2011-01-14 14:31:10 +01:00
2012-10-25 05:53:23 +02:00
public void setEquipment ( int i , ItemStack itemstack ) { }
2012-01-14 21:03:48 +01:00
public boolean isBurning ( ) {
2013-11-04 14:07:38 +01:00
boolean flag = this . world ! = null & & this . world . isStatic ;
return ! this . fireProof & & ( this . fireTicks > 0 | | flag & & this . g ( 0 ) ) ;
2012-10-25 05:53:23 +02:00
}
2013-11-04 14:07:38 +01:00
public boolean am ( ) {
2013-07-01 13:03:00 +02:00
return this . vehicle ! = null ;
2011-11-20 09:01:14 +01:00
}
2011-04-20 19:05:14 +02:00
public boolean isSneaking ( ) {
2013-11-04 14:07:38 +01:00
return this . g ( 1 ) ;
2011-01-14 14:31:10 +01:00
}
2012-07-29 09:33:13 +02:00
public void setSneaking ( boolean flag ) {
2011-01-29 22:50:29 +01:00
this . a ( 1 , flag ) ;
2011-01-14 14:31:10 +01:00
}
2011-09-24 23:03:31 +02:00
public boolean isSprinting ( ) {
2013-11-04 14:07:38 +01:00
return this . g ( 3 ) ;
2011-09-15 02:23:52 +02:00
}
2011-09-24 23:03:31 +02:00
public void setSprinting ( boolean flag ) {
2011-09-15 02:23:52 +02:00
this . a ( 3 , flag ) ;
}
2012-10-25 05:53:23 +02:00
public boolean isInvisible ( ) {
2013-11-04 14:07:38 +01:00
return this . g ( 5 ) ;
2012-10-25 05:53:23 +02:00
}
public void setInvisible ( boolean flag ) {
this . a ( 5 , flag ) ;
}
2013-03-13 23:33:27 +01:00
public void e ( boolean flag ) {
2011-09-15 02:23:52 +02:00
this . a ( 4 , flag ) ;
}
2013-11-04 14:07:38 +01:00
protected boolean g ( int i ) {
2011-09-24 23:03:31 +02:00
return ( this . datawatcher . getByte ( 0 ) & 1 < < i ) ! = 0 ;
2011-01-14 14:31:10 +01:00
}
2011-01-29 22:50:29 +01:00
protected void a ( int i , boolean flag ) {
2011-09-24 23:03:31 +02:00
byte b0 = this . datawatcher . getByte ( 0 ) ;
2011-01-14 14:31:10 +01:00
if ( flag ) {
2011-06-27 00:25:01 +02:00
this . datawatcher . watch ( 0 , Byte . valueOf ( ( byte ) ( b0 | 1 < < i ) ) ) ;
2011-01-14 14:31:10 +01:00
} else {
2011-06-27 00:25:01 +02:00
this . datawatcher . watch ( 0 , Byte . valueOf ( ( byte ) ( b0 & ~ ( 1 < < i ) ) ) ) ;
2011-01-14 14:31:10 +01:00
}
}
2011-04-20 22:47:26 +02:00
2011-11-20 09:01:14 +01:00
public int getAirTicks ( ) {
2012-07-29 09:33:13 +02:00
return this . datawatcher . getShort ( 1 ) ;
2011-11-20 09:01:14 +01:00
}
public void setAirTicks ( int i ) {
this . datawatcher . watch ( 1 , Short . valueOf ( ( short ) i ) ) ;
}
2012-07-29 09:33:13 +02:00
public void a ( EntityLightning entitylightning ) {
2011-05-14 16:29:42 +02:00
// CraftBukkit start
2011-11-29 08:10:05 +01:00
final org . bukkit . entity . Entity thisBukkitEntity = this . getBukkitEntity ( ) ;
2012-07-29 09:33:13 +02:00
final org . bukkit . entity . Entity stormBukkitEntity = entitylightning . getBukkitEntity ( ) ;
2011-12-05 09:13:10 +01:00
final PluginManager pluginManager = Bukkit . getPluginManager ( ) ;
2011-11-29 08:10:05 +01:00
if ( thisBukkitEntity instanceof Painting ) {
2012-03-27 17:37:00 +02:00
PaintingBreakByEntityEvent event = new PaintingBreakByEntityEvent ( ( Painting ) thisBukkitEntity , stormBukkitEntity ) ;
2011-11-29 08:10:05 +01:00
pluginManager . callEvent ( event ) ;
if ( event . isCancelled ( ) ) {
return ;
}
}
2013-07-01 13:03:00 +02:00
EntityDamageEvent event = org . bukkit . craftbukkit . event . CraftEventFactory . callEntityDamageEvent ( entitylightning , this , EntityDamageEvent . DamageCause . LIGHTNING , 5D ) ;
2011-04-21 18:29:35 +02:00
if ( event . isCancelled ( ) ) {
return ;
}
2011-05-14 16:29:42 +02:00
2013-07-01 13:03:00 +02:00
this . burn ( ( float ) event . getDamage ( ) ) ;
2011-05-14 16:29:42 +02:00
// CraftBukkit end
2011-04-20 22:47:26 +02:00
+ + this . fireTicks ;
if ( this . fireTicks = = 0 ) {
2013-03-25 05:22:32 +01:00
// CraftBukkit start - Call a combust event when lightning strikes
2011-11-29 08:10:05 +01:00
EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent ( stormBukkitEntity , thisBukkitEntity , 8 ) ;
pluginManager . callEvent ( entityCombustEvent ) ;
if ( ! entityCombustEvent . isCancelled ( ) ) {
2011-11-30 00:17:43 +01:00
this . setOnFire ( entityCombustEvent . getDuration ( ) ) ;
2011-11-29 08:10:05 +01:00
}
// CraftBukkit end
2011-04-20 22:47:26 +02:00
}
}
2012-07-29 09:33:13 +02:00
public void a ( EntityLiving entityliving ) { }
2011-05-26 14:48:22 +02:00
2013-11-04 14:07:38 +01:00
protected boolean j ( double d0 , double d1 , double d2 ) {
2011-05-26 14:48:22 +02:00
int i = MathHelper . floor ( d0 ) ;
int j = MathHelper . floor ( d1 ) ;
int k = MathHelper . floor ( d2 ) ;
double d3 = d0 - ( double ) i ;
double d4 = d1 - ( double ) j ;
double d5 = d2 - ( double ) k ;
2012-11-06 13:05:28 +01:00
List list = this . world . a ( this . boundingBox ) ;
2011-05-26 14:48:22 +02:00
2013-11-04 14:07:38 +01:00
if ( list . isEmpty ( ) & & ! this . world . q ( i , j , k ) ) {
2012-11-06 13:05:28 +01:00
return false ;
} else {
2013-11-04 14:07:38 +01:00
boolean flag = ! this . world . q ( i - 1 , j , k ) ;
boolean flag1 = ! this . world . q ( i + 1 , j , k ) ;
boolean flag2 = ! this . world . q ( i , j - 1 , k ) ;
boolean flag3 = ! this . world . q ( i , j + 1 , k ) ;
boolean flag4 = ! this . world . q ( i , j , k - 1 ) ;
boolean flag5 = ! this . world . q ( i , j , k + 1 ) ;
2012-11-06 13:05:28 +01:00
byte b0 = 3 ;
2011-05-26 14:48:22 +02:00
double d6 = 9999 . 0D ;
if ( flag & & d3 < d6 ) {
d6 = d3 ;
b0 = 0 ;
}
if ( flag1 & & 1 . 0D - d3 < d6 ) {
d6 = 1 . 0D - d3 ;
b0 = 1 ;
}
if ( flag3 & & 1 . 0D - d4 < d6 ) {
d6 = 1 . 0D - d4 ;
b0 = 3 ;
}
if ( flag4 & & d5 < d6 ) {
d6 = d5 ;
b0 = 4 ;
}
if ( flag5 & & 1 . 0D - d5 < d6 ) {
d6 = 1 . 0D - d5 ;
b0 = 5 ;
}
float f = this . random . nextFloat ( ) * 0 . 2F + 0 . 1F ;
if ( b0 = = 0 ) {
this . motX = ( double ) ( - f ) ;
}
if ( b0 = = 1 ) {
this . motX = ( double ) f ;
}
if ( b0 = = 2 ) {
this . motY = ( double ) ( - f ) ;
}
if ( b0 = = 3 ) {
this . motY = ( double ) f ;
}
if ( b0 = = 4 ) {
this . motZ = ( double ) ( - f ) ;
}
if ( b0 = = 5 ) {
this . motZ = ( double ) f ;
}
2011-11-20 09:01:14 +01:00
return true ;
}
2011-05-26 14:48:22 +02:00
}
2011-09-15 02:23:52 +02:00
2013-11-04 14:07:38 +01:00
public void as ( ) {
this . J = true ;
2012-01-12 23:10:13 +01:00
this . fallDistance = 0 . 0F ;
2011-09-15 02:23:52 +02:00
}
2013-11-04 14:07:38 +01:00
public String getName ( ) {
2011-09-15 02:23:52 +02:00
String s = EntityTypes . b ( this ) ;
if ( s = = null ) {
s = " generic " ;
}
2012-02-29 22:31:04 +01:00
return LocaleI18n . get ( " entity. " + s + " .name " ) ;
2011-09-15 02:23:52 +02:00
}
2011-11-20 09:01:14 +01:00
2013-11-04 14:07:38 +01:00
public Entity [ ] at ( ) {
2011-11-20 09:01:14 +01:00
return null ;
}
2013-07-01 13:03:00 +02:00
public boolean h ( Entity entity ) {
2011-11-20 09:01:14 +01:00
return this = = entity ;
}
2012-03-01 11:49:23 +01:00
2013-04-27 11:40:05 +02:00
public float getHeadRotation ( ) {
2012-03-01 11:49:23 +01:00
return 0 . 0F ;
}
2013-11-04 14:07:38 +01:00
public boolean av ( ) {
2012-03-01 11:49:23 +01:00
return true ;
}
2012-07-29 09:33:13 +02:00
2013-07-01 13:03:00 +02:00
public boolean i ( Entity entity ) {
2012-11-06 13:05:28 +01:00
return false ;
}
2012-07-29 09:33:13 +02:00
public String toString ( ) {
2013-11-04 14:07:38 +01:00
return String . format ( " %s[ \ '%s \ '/%d, l= \ '%s \ ', x=%.2f, y=%.2f, z=%.2f] " , new Object [ ] { this . getClass ( ) . getSimpleName ( ) , this . getName ( ) , Integer . valueOf ( this . id ) , this . world = = null ? " ~NULL~ " : this . world . getWorldData ( ) . getName ( ) , Double . valueOf ( this . locX ) , Double . valueOf ( this . locY ) , Double . valueOf ( this . locZ ) } ) ;
2012-07-29 09:33:13 +02:00
}
2012-10-25 05:53:23 +02:00
2012-11-06 13:05:28 +01:00
public boolean isInvulnerable ( ) {
return this . invulnerable ;
}
2013-07-01 13:03:00 +02:00
public void j ( Entity entity ) {
2012-10-25 05:53:23 +02:00
this . setPositionRotation ( entity . locX , entity . locY , entity . locZ , entity . yaw , entity . pitch ) ;
}
public void a ( Entity entity , boolean flag ) {
NBTTagCompound nbttagcompound = new NBTTagCompound ( ) ;
2013-03-13 23:33:27 +01:00
entity . e ( nbttagcompound ) ;
this . f ( nbttagcompound ) ;
2012-11-06 13:05:28 +01:00
this . portalCooldown = entity . portalCooldown ;
2013-11-04 14:07:38 +01:00
this . ar = entity . ar ;
2012-10-25 05:53:23 +02:00
}
2013-07-01 13:03:00 +02:00
public void b ( int i ) {
2012-12-22 19:46:24 +01:00
if ( ! this . world . isStatic & & ! this . dead ) {
2012-11-06 13:05:28 +01:00
this . world . methodProfiler . a ( " changeDimension " ) ;
2012-10-25 05:53:23 +02:00
MinecraftServer minecraftserver = MinecraftServer . getServer ( ) ;
2013-03-25 05:22:32 +01:00
// CraftBukkit start - Move logic into new function "teleportToLocation"
2012-12-22 19:46:24 +01:00
// int j = this.dimension;
2013-01-23 02:36:03 +01:00
WorldServer exitWorld = null ;
2013-03-25 05:22:32 +01:00
if ( this . dimension < CraftWorld . CUSTOM_DIMENSION_OFFSET ) { // Plugins must specify exit from custom Bukkit worlds
// Only target existing worlds (compensate for allow-nether/allow-end as false)
2013-01-23 02:36:03 +01:00
for ( WorldServer world : minecraftserver . worlds ) {
if ( world . dimension = = i ) {
exitWorld = world ;
}
}
}
2012-12-22 19:46:24 +01:00
Location enter = this . getBukkitEntity ( ) . getLocation ( ) ;
2013-01-23 02:36:03 +01:00
Location exit = exitWorld ! = null ? minecraftserver . getPlayerList ( ) . calculateTarget ( enter , minecraftserver . getWorldServer ( i ) ) : null ;
2013-01-25 01:37:01 +01:00
boolean useTravelAgent = exitWorld ! = null & & ! ( this . dimension = = 1 & & exitWorld . dimension = = 1 ) ; // don't use agent for custom worlds or return from THE_END
2012-12-22 19:46:24 +01:00
2013-04-27 11:40:05 +02:00
TravelAgent agent = exit ! = null ? ( TravelAgent ) ( ( CraftWorld ) exit . getWorld ( ) ) . getHandle ( ) . t ( ) : org . bukkit . craftbukkit . CraftTravelAgent . DEFAULT ; // return arbitrary TA to compensate for implementation dependent plugins
2012-12-22 19:46:24 +01:00
EntityPortalEvent event = new EntityPortalEvent ( this . getBukkitEntity ( ) , enter , exit , agent ) ;
2013-01-25 01:37:01 +01:00
event . useTravelAgent ( useTravelAgent ) ;
2012-12-22 19:46:24 +01:00
event . getEntity ( ) . getServer ( ) . getPluginManager ( ) . callEvent ( event ) ;
2013-12-15 00:23:34 +01:00
if ( event . isCancelled ( ) | | event . getTo ( ) = = null | | event . getTo ( ) . getWorld ( ) = = null | | ! this . isAlive ( ) ) {
2012-12-22 19:46:24 +01:00
return ;
}
2013-02-02 13:34:14 +01:00
exit = event . useTravelAgent ( ) ? event . getPortalTravelAgent ( ) . findOrCreate ( event . getTo ( ) ) : event . getTo ( ) ;
2012-12-22 19:46:24 +01:00
this . teleportTo ( exit , true ) ;
}
}
public void teleportTo ( Location exit , boolean portal ) {
if ( true ) {
WorldServer worldserver = ( ( CraftWorld ) this . getBukkitEntity ( ) . getLocation ( ) . getWorld ( ) ) . getHandle ( ) ;
WorldServer worldserver1 = ( ( CraftWorld ) exit . getWorld ( ) ) . getHandle ( ) ;
int i = worldserver1 . dimension ;
// CraftBukkit end
2012-10-25 05:53:23 +02:00
this . dimension = i ;
2013-07-01 13:03:00 +02:00
/ * CraftBukkit start - TODO : Check if we need this
if ( j = = 1 & & i = = 1 ) {
worldserver1 = minecraftserver . getWorldServer ( 0 ) ;
this . dimension = 0 ;
}
// CraftBukkit end */
2012-10-25 05:53:23 +02:00
this . world . kill ( this ) ;
this . dead = false ;
2012-11-06 13:05:28 +01:00
this . world . methodProfiler . a ( " reposition " ) ;
2013-03-25 05:22:32 +01:00
// CraftBukkit start - Ensure chunks are loaded in case TravelAgent is not used which would initially cause chunks to load during find/create
2012-12-22 19:46:24 +01:00
// minecraftserver.getPlayerList().a(this, j, worldserver, worldserver1);
boolean before = worldserver1 . chunkProviderServer . forceChunkLoad ;
worldserver1 . chunkProviderServer . forceChunkLoad = true ;
worldserver1 . getMinecraftServer ( ) . getPlayerList ( ) . repositionEntity ( this , exit , portal ) ;
worldserver1 . chunkProviderServer . forceChunkLoad = before ;
// CraftBukkit end
2012-11-06 13:05:28 +01:00
this . world . methodProfiler . c ( " reloading " ) ;
2012-10-25 05:53:23 +02:00
Entity entity = EntityTypes . createEntityByName ( EntityTypes . b ( this ) , worldserver1 ) ;
if ( entity ! = null ) {
entity . a ( this , true ) ;
2013-07-01 13:03:00 +02:00
/ * CraftBukkit start - We need to do this . . .
if ( j = = 1 & & i = = 1 ) {
ChunkCoordinates chunkcoordinates = worldserver1 . getSpawn ( ) ;
chunkcoordinates . y = this . world . i ( chunkcoordinates . x , chunkcoordinates . z ) ;
entity . setPositionRotation ( ( double ) chunkcoordinates . x , ( double ) chunkcoordinates . y , ( double ) chunkcoordinates . z , entity . yaw , entity . pitch ) ;
}
// CraftBukkit end */
2012-10-25 05:53:23 +02:00
worldserver1 . addEntity ( entity ) ;
2013-03-25 05:22:32 +01:00
// CraftBukkit start - Forward the CraftEntity to the new entity
2012-12-22 19:46:24 +01:00
this . getBukkitEntity ( ) . setHandle ( entity ) ;
entity . bukkitEntity = this . getBukkitEntity ( ) ;
// CraftBukkit end
2012-10-25 05:53:23 +02:00
}
this . dead = true ;
2012-11-06 13:05:28 +01:00
this . world . methodProfiler . b ( ) ;
2012-10-25 05:53:23 +02:00
worldserver . i ( ) ;
worldserver1 . i ( ) ;
2012-11-06 13:05:28 +01:00
this . world . methodProfiler . b ( ) ;
2012-10-25 05:53:23 +02:00
}
}
2013-03-13 23:33:27 +01:00
public float a ( Explosion explosion , World world , int i , int j , int k , Block block ) {
2012-10-25 05:53:23 +02:00
return block . a ( this ) ;
}
2013-11-04 14:07:38 +01:00
public boolean a ( Explosion explosion , World world , int i , int j , int k , Block block , float f ) {
2013-03-13 23:33:27 +01:00
return true ;
}
2013-11-04 14:07:38 +01:00
public int ax ( ) {
2012-10-25 05:53:23 +02:00
return 3 ;
}
2013-11-04 14:07:38 +01:00
public int ay ( ) {
return this . ar ;
2012-10-25 05:53:23 +02:00
}
2013-11-04 14:07:38 +01:00
public boolean az ( ) {
2012-10-25 05:53:23 +02:00
return false ;
}
2012-11-06 13:05:28 +01:00
public void a ( CrashReportSystemDetails crashreportsystemdetails ) {
crashreportsystemdetails . a ( " Entity Type " , ( Callable ) ( new CrashReportEntityType ( this ) ) ) ;
crashreportsystemdetails . a ( " Entity ID " , Integer . valueOf ( this . id ) ) ;
2013-03-13 23:33:27 +01:00
crashreportsystemdetails . a ( " Entity Name " , ( Callable ) ( new CrashReportEntityName ( this ) ) ) ;
crashreportsystemdetails . a ( " Entity \ 's Exact location " , String . format ( " %.2f, %.2f, %.2f " , new Object [ ] { Double . valueOf ( this . locX ) , Double . valueOf ( this . locY ) , Double . valueOf ( this . locZ ) } ) ) ;
crashreportsystemdetails . a ( " Entity \ 's Block location " , CrashReportSystemDetails . a ( MathHelper . floor ( this . locX ) , MathHelper . floor ( this . locY ) , MathHelper . floor ( this . locZ ) ) ) ;
crashreportsystemdetails . a ( " Entity \ 's Momentum " , String . format ( " %.2f, %.2f, %.2f " , new Object [ ] { Double . valueOf ( this . motX ) , Double . valueOf ( this . motY ) , Double . valueOf ( this . motZ ) } ) ) ;
}
2013-07-01 13:03:00 +02:00
public UUID getUniqueID ( ) {
return this . uniqueID ;
}
2013-11-04 14:07:38 +01:00
public boolean aC ( ) {
2013-03-13 23:33:27 +01:00
return true ;
}
2013-11-04 14:07:38 +01:00
public IChatBaseComponent getScoreboardDisplayName ( ) {
return new ChatComponentText ( this . getName ( ) ) ;
2012-11-06 13:05:28 +01:00
}
2013-11-04 14:07:38 +01:00
public void i ( int i ) { }
2011-01-03 12:37:41 +01:00
}