2011-07-14 01:49:20 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class TileEntityPiston extends TileEntity {
|
|
|
|
|
|
|
|
private int a;
|
|
|
|
private int b;
|
|
|
|
private int c;
|
2011-09-15 02:23:52 +02:00
|
|
|
private boolean d;
|
|
|
|
private boolean e;
|
|
|
|
private float f;
|
|
|
|
private float g;
|
2012-07-29 09:33:13 +02:00
|
|
|
private List h = new ArrayList();
|
2011-07-14 01:49:20 +02:00
|
|
|
|
|
|
|
public TileEntityPiston() {}
|
|
|
|
|
|
|
|
public TileEntityPiston(int i, int j, int k, boolean flag, boolean flag1) {
|
|
|
|
this.a = i;
|
|
|
|
this.b = j;
|
|
|
|
this.c = k;
|
2011-09-15 02:23:52 +02:00
|
|
|
this.d = flag;
|
|
|
|
this.e = flag1;
|
2011-07-14 01:49:20 +02:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public int a() {
|
2011-07-14 01:49:20 +02:00
|
|
|
return this.a;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public int n() {
|
2011-07-14 01:49:20 +02:00
|
|
|
return this.b;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean b() {
|
2011-09-15 02:23:52 +02:00
|
|
|
return this.d;
|
2011-07-14 01:49:20 +02:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public int c() {
|
2011-07-14 01:49:20 +02:00
|
|
|
return this.c;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float a(float f) {
|
|
|
|
if (f > 1.0F) {
|
|
|
|
f = 1.0F;
|
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
return this.g + (this.f - this.g) * f;
|
2011-07-14 01:49:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void a(float f, float f1) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.d) {
|
2011-07-14 01:49:20 +02:00
|
|
|
f = 1.0F - f;
|
2012-07-29 09:33:13 +02:00
|
|
|
} else {
|
|
|
|
--f;
|
2011-07-14 01:49:20 +02:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
AxisAlignedBB axisalignedbb = Block.PISTON_MOVING.b(this.world, this.x, this.y, this.z, this.a, f, this.c);
|
2011-07-14 01:49:20 +02:00
|
|
|
|
|
|
|
if (axisalignedbb != null) {
|
2012-03-01 11:49:23 +01:00
|
|
|
List list = this.world.getEntities((Entity) null, axisalignedbb);
|
2011-07-14 01:49:20 +02:00
|
|
|
|
|
|
|
if (!list.isEmpty()) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.h.addAll(list);
|
|
|
|
Iterator iterator = this.h.iterator();
|
2011-07-14 01:49:20 +02:00
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
Entity entity = (Entity) iterator.next();
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
entity.move((double) (f1 * (float) Facing.b[this.c]), (double) (f1 * (float) Facing.c[this.c]), (double) (f1 * (float) Facing.d[this.c]));
|
2011-07-14 01:49:20 +02:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.h.clear();
|
2011-07-14 01:49:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void i() {
|
2011-11-20 09:01:14 +01:00
|
|
|
if (this.g < 1.0F && this.world != null) {
|
2011-09-15 02:23:52 +02:00
|
|
|
this.g = this.f = 1.0F;
|
2012-03-01 11:49:23 +01:00
|
|
|
this.world.q(this.x, this.y, this.z);
|
|
|
|
this.j();
|
2011-07-14 01:49:20 +02:00
|
|
|
if (this.world.getTypeId(this.x, this.y, this.z) == Block.PISTON_MOVING.id) {
|
|
|
|
this.world.setTypeIdAndData(this.x, this.y, this.z, this.a, this.b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void g() {
|
2011-09-15 02:23:52 +02:00
|
|
|
if (this.world == null) return; // CraftBukkit
|
|
|
|
|
|
|
|
this.g = this.f;
|
|
|
|
if (this.g >= 1.0F) {
|
2011-07-14 01:49:20 +02:00
|
|
|
this.a(1.0F, 0.25F);
|
2012-03-01 11:49:23 +01:00
|
|
|
this.world.q(this.x, this.y, this.z);
|
|
|
|
this.j();
|
2011-07-14 01:49:20 +02:00
|
|
|
if (this.world.getTypeId(this.x, this.y, this.z) == Block.PISTON_MOVING.id) {
|
|
|
|
this.world.setTypeIdAndData(this.x, this.y, this.z, this.a, this.b);
|
|
|
|
}
|
|
|
|
} else {
|
2011-09-15 02:23:52 +02:00
|
|
|
this.f += 0.5F;
|
|
|
|
if (this.f >= 1.0F) {
|
|
|
|
this.f = 1.0F;
|
2011-07-14 01:49:20 +02:00
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
if (this.d) {
|
|
|
|
this.a(this.f, this.f - this.g + 0.0625F);
|
2011-07-14 01:49:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
2011-11-30 00:17:43 +01:00
|
|
|
this.a = nbttagcompound.getInt("blockId");
|
|
|
|
this.b = nbttagcompound.getInt("blockData");
|
|
|
|
this.c = nbttagcompound.getInt("facing");
|
|
|
|
this.g = this.f = nbttagcompound.getFloat("progress");
|
|
|
|
this.d = nbttagcompound.getBoolean("extending");
|
2011-07-14 01:49:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
2011-11-30 00:17:43 +01:00
|
|
|
nbttagcompound.setInt("blockId", this.a);
|
|
|
|
nbttagcompound.setInt("blockData", this.b);
|
|
|
|
nbttagcompound.setInt("facing", this.c);
|
|
|
|
nbttagcompound.setFloat("progress", this.g);
|
|
|
|
nbttagcompound.setBoolean("extending", this.d);
|
2011-07-14 01:49:20 +02:00
|
|
|
}
|
|
|
|
}
|