42
42
import static net .minecraft .state .property .Properties .HORIZONTAL_FACING ;
43
43
44
44
public class MotionInvokingBlockEntity extends BlockEntity {
45
-
46
45
NbtList instructions = new NbtList ();
47
46
long nextInstruction = 0 ;
47
+
48
+ public NbtList getInstructions () {return instructions ;}
49
+ public void setNextInstruction (long nextInstruction ) {this .nextInstruction = nextInstruction ;}
50
+ public void advanceInstructionList () {instructions .add (instructions .remove (0 ));}
51
+
48
52
private static int updateTicks = -1 ;
49
53
50
54
public MotionInvokingBlockEntity (BlockPos pos , BlockState state ) {
51
55
super (Pirates .MOTION_INVOKING_BLOCK_ENTITY , pos , state );
52
56
}
53
57
58
+
59
+
54
60
public static void tick (World world , BlockPos pos , BlockState state , MotionInvokingBlockEntity be ) {
55
61
56
62
if (!(world .getBlockState (pos .up ()).getBlock () instanceof ShipHelmBlock )) {
@@ -74,13 +80,12 @@ public static void tick(World world, BlockPos pos, BlockState state, MotionInvok
74
80
75
81
}
76
82
if (!world .isClient && world .getGameRules ().getBoolean (Pirates .PIRATES_IS_LIVE_WORLD ) && world .getTime () >= be .nextInstruction ) {
77
- DimensionIdProvider provider = (DimensionIdProvider ) world ;
78
83
79
84
if (VSGameUtilsKt .isBlockInShipyard (world , pos )) {
80
85
81
86
82
87
ChunkPos chunkPos = world .getChunk (pos ).getPos ();
83
- LoadedServerShip ship = ( LoadedServerShip ) ValkyrienSkiesMod . getVsCore (). getHooks (). getCurrentShipServerWorld (). getLoadedShips (). getByChunkPos ( chunkPos . x , chunkPos . z , provider . getDimensionId () );
88
+ LoadedServerShip ship = VSGameUtilsKt . getShipObjectManagingPos (( ServerWorld ) world , chunkPos );
84
89
85
90
//Pirates.LOGGER.info("scaling of ship: "+s.x()+" "+s.y()+" "+s.z());
86
91
@@ -194,16 +199,8 @@ private void moveTowards(SeatedControllingPlayer power, LoadedServerShip ship)
194
199
195
200
}
196
201
197
- private double vdis (double x , double xto )
198
- {
199
- if (x >xto )
200
- {
201
- return x -xto ;
202
- }
203
- else
204
- {
205
- return xto -x ;
206
- }
202
+ private double vdis (double x , double xto ) {
203
+ return Math .abs (x -xto );
207
204
}
208
205
209
206
private void moveShipForward (LoadedServerShip ship )
@@ -220,23 +217,4 @@ private void moveShipForward(LoadedServerShip ship)
220
217
//gtfa.applyInvariantForce(qdc);
221
218
}
222
219
}
223
-
224
- private void utiliseInternalPattern (SeatedControllingPlayer seatedControllingPlayer , MotionInvokingBlockEntity be ) {
225
- String [] instruction = be .instructions .getString (0 ).split (" " );
226
-
227
- if (seatedControllingPlayer == null ) return ;
228
- switch (instruction [0 ]) {
229
- case "forward" -> seatedControllingPlayer .setForwardImpulse (Float .parseFloat (instruction [1 ]));
230
- case "left" -> seatedControllingPlayer .setLeftImpulse (Float .parseFloat (instruction [1 ]));
231
- case "right" -> seatedControllingPlayer .setLeftImpulse (-Float .parseFloat (instruction [1 ]));
232
- case "backwards" -> seatedControllingPlayer .setForwardImpulse (-Float .parseFloat (instruction [1 ]));
233
- case "up" -> seatedControllingPlayer .setUpImpulse (Float .parseFloat (instruction [1 ]));
234
- case "down" -> seatedControllingPlayer .setUpImpulse (-Float .parseFloat (instruction [1 ]));
235
- }
236
-
237
- be .nextInstruction = world .getTime () + Long .parseLong (instruction [2 ]);
238
- be .instructions .add (be .instructions .remove (0 ));
239
- be .markDirty ();
240
- }
241
-
242
220
}
0 commit comments