remove if rune block is broken

This commit is contained in:
zongor 2024-11-17 00:27:36 -05:00
parent 85db38a9a8
commit 1bd736dca8
1 changed files with 12 additions and 1 deletions

View File

@ -27,9 +27,20 @@ public class RuneBlock extends Block {
if (server != null) { if (server != null) {
StateSaverAndLoader serverState = StateSaverAndLoader.getServerState(server); StateSaverAndLoader serverState = StateSaverAndLoader.getServerState(server);
player.sendMessage(Text.literal(String.format("Clicked rune %s Total Runes in World: %d", serverState.runes.get(pos), serverState.totalNumberOfRunes))); player.sendMessage(Text.literal(String.format("Clicked rune %s Total Runes in World: %d", serverState.runes.get(pos), serverState.totalNumberOfRunes)));
world.playSound(player, pos, SoundEvents.BLOCK_AMETHYST_BLOCK_CHIME, SoundCategory.BLOCKS, 1f, 1f);
} }
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} }
@Override
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
super.onBreak(world, pos, state, player);
MinecraftServer server = world.getServer();
if (server != null) {
StateSaverAndLoader serverState = StateSaverAndLoader.getServerState(server);
serverState.runes.remove(pos);
serverState.totalNumberOfRunes -= 1;
}
}
} }