33import cn .nukkit .block .Block ;
44import cn .nukkit .block .BlockAir ;
55import cn .nukkit .block .BlockID ;
6+ import cn .nukkit .level .Level ;
67import cn .nukkit .level .format .FullChunk ;
78import cn .nukkit .math .BlockFace ;
8- import cn .nukkit .math .Vector3 ;
9+ import cn .nukkit .math .BlockVector3 ;
910import cn .nukkit .nbt .tag .CompoundTag ;
1011import cn .nukkit .nbt .tag .IntTag ;
1112import cn .nukkit .nbt .tag .ListTag ;
@@ -28,7 +29,7 @@ public class BlockEntityPistonArm extends BlockEntitySpawnable {
2829 public boolean sticky ;
2930 public int state ;
3031 public int newState = 1 ;
31- public List <Vector3 > attachedBlocks ;
32+ public List <BlockVector3 > attachedBlocks ;
3233 public boolean powered ;
3334
3435 public BlockEntityPistonArm (FullChunk chunk , CompoundTag nbt ) {
@@ -66,7 +67,7 @@ protected void initBlockEntity() {
6667 ListTag blocks = namedTag .getList ("AttachedBlocks" , IntTag .class );
6768 if (blocks != null && blocks .size () > 0 ) {
6869 for (int i = 0 ; i < blocks .size (); i += 3 ) {
69- this .attachedBlocks .add (new Vector3 (
70+ this .attachedBlocks .add (new BlockVector3 (
7071 ((IntTag ) blocks .get (i )).data ,
7172 ((IntTag ) blocks .get (i + 1 )).data ,
7273 ((IntTag ) blocks .get (i + 1 )).data
@@ -92,7 +93,7 @@ private void moveCollidedEntities() {
9293// }
9394
9495 BlockFace pushDir = this .extending ? facing : facing .getOpposite ();
95- for (Vector3 pos : this .attachedBlocks ) {
96+ for (BlockVector3 pos : this .attachedBlocks ) {
9697 BlockEntity blockEntity = this .level .getBlockEntity (pos .getSide (pushDir ));
9798
9899 if (blockEntity instanceof BlockEntityMovingBlock ) {
@@ -101,7 +102,7 @@ private void moveCollidedEntities() {
101102 }
102103 }
103104
104- public void move (boolean extending , List <Vector3 > attachedBlocks ) {
105+ public void move (boolean extending , List <BlockVector3 > attachedBlocks ) {
105106 this .extending = extending ;
106107 this .lastProgress = this .progress = extending ? 0 : 1 ;
107108 this .state = this .newState = extending ? 1 : 3 ;
@@ -133,7 +134,7 @@ public boolean onUpdate() {
133134
134135 BlockFace pushDir = this .extending ? facing : facing .getOpposite ();
135136
136- for (Vector3 pos : this .attachedBlocks ) {
137+ for (BlockVector3 pos : this .attachedBlocks ) {
137138 BlockEntity movingBlock = this .level .getBlockEntity (pos .getSide (pushDir ));
138139
139140 if (movingBlock instanceof BlockEntityMovingBlock ) {
@@ -150,6 +151,8 @@ public boolean onUpdate() {
150151 blockEntity .putInt ("z" , movingBlock .getFloorZ ());
151152 BlockEntity .createBlockEntity (blockEntity .getString ("id" ), this .level .getChunk (movingBlock .getChunkX (), movingBlock .getChunkZ ()), blockEntity );
152153 }
154+
155+ moved .onUpdate (Level .BLOCK_UPDATE_NORMAL );
153156 }
154157 }
155158
@@ -202,10 +205,10 @@ public CompoundTag getSpawnCompound() {
202205
203206 private ListTag <IntTag > getAttachedBlocks () {
204207 ListTag <IntTag > attachedBlocks = new ListTag <>("AttachedBlocks" );
205- for (Vector3 block : this .attachedBlocks ) {
206- attachedBlocks .add (new IntTag ("" , block .getFloorX () ));
207- attachedBlocks .add (new IntTag ("" , block .getFloorY () ));
208- attachedBlocks .add (new IntTag ("" , block .getFloorZ () ));
208+ for (BlockVector3 block : this .attachedBlocks ) {
209+ attachedBlocks .add (new IntTag ("" , block .x ));
210+ attachedBlocks .add (new IntTag ("" , block .y ));
211+ attachedBlocks .add (new IntTag ("" , block .z ));
209212 }
210213
211214 return attachedBlocks ;
0 commit comments