Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package net.minecraft.server;
2
3import java.util.ArrayList;
4import java.util.Iterator;
5import java.util.List;
6
7public class TileEntityPiston extends TileEntity {
8
9 private int a;
10 private int b;
11 private int c;
12 private boolean i;
13 private boolean j;
14 private float k;
15 private float l;
16 private static List m = new ArrayList();
17
18 public TileEntityPiston() {
19 }
20
21 public TileEntityPiston(int i, int j, int k, boolean flag, boolean flag1) {
22 this.a = i;
23 this.b = j;
24 this.c = k;
25 this.i = flag;
26 this.j = flag1;
27 }
28
29 public int a() {
30 return this.a;
31 }
32
33 public int e() {
34 return this.b;
35 }
36
37 public boolean c() {
38 return this.i;
39 }
40
41 public int d() {
42 return this.c;
43 }
44
45 public float a(float f) {
46 if (f > 1.0F) {
47 f = 1.0F;
48 }
49
50 return this.l + (this.k - this.l) * f;
51 }
52
53 private void a(float f, float f1) {
54 if (!this.i) {
55 --f;
56 } else {
57 f = 1.0F - f;
58 }
59
60 AxisAlignedBB axisalignedbb = Block.PISTON_MOVING.a(this.world, this.x, this.y, this.z, this.a, f, this.c);
61
62 if (axisalignedbb != null) {
63 List list = this.world.b((Entity) null, axisalignedbb);
64
65 if (!list.isEmpty()) {
66 m.addAll(list);
67 Iterator iterator = m.iterator();
68
69 while (iterator.hasNext()) {
70 Entity entity = (Entity) iterator.next();
71
72 entity.move((double) (f1 * (float) PistonBlockTextures.b[this.c]), (double) (f1 * (float) PistonBlockTextures.c[this.c]), (double) (f1 * (float) PistonBlockTextures.d[this.c]));
73 }
74
75 m.clear();
76 }
77 }
78 }
79
80 public void k() {
81 if (this.l < 1.0F) {
82 this.l = this.k = 1.0F;
83 this.world.o(this.x, this.y, this.z);
84 this.h();
85 if (this.world.getTypeId(this.x, this.y, this.z) == Block.PISTON_MOVING.id) {
86 this.world.setTypeIdAndData(this.x, this.y, this.z, this.a, this.b);
87 }
88 }
89 }
90
91 public void g_() {
92 // CraftBukkit
93 if (this.world == null) return;
94 this.l = this.k;
95 if (this.l >= 1.0F) {
96 this.a(1.0F, 0.25F);
97 this.world.o(this.x, this.y, this.z);
98 this.h();
99 if (this.world.getTypeId(this.x, this.y, this.z) == Block.PISTON_MOVING.id) {
100 this.world.setTypeIdAndData(this.x, this.y, this.z, this.a, this.b);
101 }
102 } else {
103 this.k += 0.5F;
104 if (this.k >= 1.0F) {
105 this.k = 1.0F;
106 }
107
108 if (this.i) {
109 this.a(this.k, this.k - this.l + 0.0625F);
110 }
111 }
112 }
113
114 public void a(NBTTagCompound nbttagcompound) {
115 super.a(nbttagcompound);
116 this.a = nbttagcompound.e("blockId");
117 this.b = nbttagcompound.e("blockData");
118 this.c = nbttagcompound.e("facing");
119 this.l = this.k = nbttagcompound.g("progress");
120 this.i = nbttagcompound.m("extending");
121 }
122
123 public void b(NBTTagCompound nbttagcompound) {
124 super.b(nbttagcompound);
125 nbttagcompound.a("blockId", this.a);
126 nbttagcompound.a("blockData", this.b);
127 nbttagcompound.a("facing", this.c);
128 nbttagcompound.a("progress", this.l);
129 nbttagcompound.a("extending", this.i);
130 }
131}