2011-09-26 09:07:06 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public class EntityFallingBlock extends Entity {
|
2011-09-26 09:07:06 +02:00
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public int id;
|
2011-09-26 09:07:06 +02:00
|
|
|
public int data; // CraftBukkit
|
|
|
|
public int b = 0;
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public EntityFallingBlock(World world) {
|
2011-09-26 09:07:06 +02:00
|
|
|
super(world);
|
|
|
|
}
|
|
|
|
|
2012-01-12 12:02:39 +01:00
|
|
|
// CraftBukkit - changed method signature
|
2011-11-30 00:17:43 +01:00
|
|
|
public EntityFallingBlock(World world, double d0, double d1, double d2, int i, int data) {
|
2011-09-26 09:07:06 +02:00
|
|
|
super(world);
|
2012-01-14 21:03:48 +01:00
|
|
|
this.id = i;
|
2012-01-12 23:10:13 +01:00
|
|
|
this.bf = true;
|
2011-10-28 02:03:28 +02:00
|
|
|
this.data = data; // CraftBukkit
|
2011-09-26 09:07:06 +02:00
|
|
|
this.b(0.98F, 0.98F);
|
2011-11-30 00:17:43 +01:00
|
|
|
this.height = this.length / 2.0F;
|
2011-09-26 09:07:06 +02:00
|
|
|
this.setPosition(d0, d1, d2);
|
|
|
|
this.motX = 0.0D;
|
|
|
|
this.motY = 0.0D;
|
|
|
|
this.motZ = 0.0D;
|
|
|
|
this.lastX = d0;
|
|
|
|
this.lastY = d1;
|
|
|
|
this.lastZ = d2;
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected boolean g_() {
|
2011-09-26 09:07:06 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void b() {}
|
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
public boolean o_() {
|
2011-09-26 09:07:06 +02:00
|
|
|
return !this.dead;
|
|
|
|
}
|
|
|
|
|
2012-03-22 21:39:39 +01:00
|
|
|
public void F_() {
|
2012-01-14 21:03:48 +01:00
|
|
|
if (this.id == 0) {
|
2011-09-26 09:07:06 +02:00
|
|
|
this.die();
|
|
|
|
} else {
|
|
|
|
this.lastX = this.locX;
|
|
|
|
this.lastY = this.locY;
|
|
|
|
this.lastZ = this.locZ;
|
|
|
|
++this.b;
|
|
|
|
this.motY -= 0.03999999910593033D;
|
|
|
|
this.move(this.motX, this.motY, this.motZ);
|
|
|
|
this.motX *= 0.9800000190734863D;
|
|
|
|
this.motY *= 0.9800000190734863D;
|
|
|
|
this.motZ *= 0.9800000190734863D;
|
|
|
|
int i = MathHelper.floor(this.locX);
|
|
|
|
int j = MathHelper.floor(this.locY);
|
|
|
|
int k = MathHelper.floor(this.locZ);
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
if (this.b == 1 && this.world.getTypeId(i, j, k) == this.id) {
|
2011-09-26 09:07:06 +02:00
|
|
|
this.world.setTypeId(i, j, k, 0);
|
2011-11-20 09:01:14 +01:00
|
|
|
} else if (!this.world.isStatic && this.b == 1) {
|
|
|
|
this.die();
|
2011-09-26 09:07:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.onGround) {
|
|
|
|
this.motX *= 0.699999988079071D;
|
|
|
|
this.motZ *= 0.699999988079071D;
|
|
|
|
this.motY *= -0.5D;
|
2011-11-20 09:01:14 +01:00
|
|
|
if (this.world.getTypeId(i, j, k) != Block.PISTON_MOVING.id) {
|
|
|
|
this.die();
|
2012-01-12 12:02:39 +01:00
|
|
|
// CraftBukkit - setTypeId => setTypeIdAndData
|
2012-01-14 21:03:48 +01:00
|
|
|
if ((!this.world.mayPlace(this.id, i, j, k, true, 1) || BlockSand.canFall(this.world, i, j - 1, k) || !this.world.setTypeIdAndData(i, j, k, this.id, this.data)) && !this.world.isStatic) {
|
|
|
|
this.b(this.id, 1);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-09-26 09:07:06 +02:00
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
} else if (this.b > 100 && !this.world.isStatic && (j < 1 || j > 256) || this.b > 600) {
|
2012-01-14 21:03:48 +01:00
|
|
|
this.b(this.id, 1);
|
2011-09-26 09:07:06 +02:00
|
|
|
this.die();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void b(NBTTagCompound nbttagcompound) {
|
2012-01-14 21:03:48 +01:00
|
|
|
nbttagcompound.setByte("Tile", (byte) this.id);
|
2011-11-30 00:17:43 +01:00
|
|
|
nbttagcompound.setByte("Data", (byte) this.data); // CraftBukkit
|
2011-09-26 09:07:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(NBTTagCompound nbttagcompound) {
|
2012-01-14 21:03:48 +01:00
|
|
|
this.id = nbttagcompound.getByte("Tile") & 255;
|
2011-11-30 00:17:43 +01:00
|
|
|
this.data = nbttagcompound.getByte("Data") & 15; // CraftBukkit
|
2011-09-26 09:07:06 +02:00
|
|
|
}
|
|
|
|
}
|