Skip to content

Commit 7062580

Browse files
committed
MotionInvokingBlock now stops movement on block destruction
1 parent aa0f6ea commit 7062580

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/main/java/ace/actually/pirates/blocks/MotionInvokingBlock.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public void onStacksDropped(BlockState state, ServerWorld world, BlockPos pos, I
4747
this.dropExperience(world, pos, i);
4848
}
4949

50+
@Override
51+
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
52+
super.onStateReplaced(state, world, pos, newState, moved);
53+
stopMotion(world,pos);
54+
}
5055

5156
@Override
5257
public BlockRenderType getRenderType(BlockState state) {
@@ -56,6 +61,14 @@ public BlockRenderType getRenderType(BlockState state) {
5661
public static void disarm(World world, BlockPos pos) {
5762
if (world.isClient()) return;
5863

64+
stopMotion(world,pos);
65+
world.setBlockState(pos, Blocks.SPRUCE_PLANKS.getDefaultState());
66+
world.playSound(null, pos, SoundEvents.BLOCK_BEACON_DEACTIVATE, SoundCategory.BLOCKS, 1, 0.95f);
67+
68+
}
69+
70+
private static void stopMotion(World world, BlockPos pos)
71+
{
5972
DimensionIdProvider provider = (DimensionIdProvider) world;
6073
ChunkPos chunkPos = world.getChunk(pos).getPos();
6174
LoadedServerShip ship = (LoadedServerShip) ValkyrienSkiesMod.getVsCore().getHooks().getCurrentShipServerWorld().getLoadedShips().getByChunkPos(chunkPos.x, chunkPos.z, provider.getDimensionId());
@@ -65,9 +78,5 @@ public static void disarm(World world, BlockPos pos) {
6578
seatedControllingPlayer.setCruise(false);
6679
seatedControllingPlayer.setUpImpulse(0);
6780
ship.setAttachment(SeatedControllingPlayer.class, seatedControllingPlayer);
68-
69-
world.setBlockState(pos, Blocks.SPRUCE_PLANKS.getDefaultState());
70-
world.playSound(null, pos, SoundEvents.BLOCK_BEACON_DEACTIVATE, SoundCategory.BLOCKS, 1, 0.95f);
71-
7281
}
7382
}

0 commit comments

Comments
 (0)