Fix block activation logic and add server-side message

Reversed client/server check to ensure correct logic during block activation. Added a server-side message to notify players when the block is activated. This improves clarity and ensures consistent behavior across client and server.

Signed-off-by: dragonruler1000 <github@me.minecraftchest2.us>
This commit is contained in:
dragonruler1000 2025-05-17 16:42:03 -05:00 committed by dragonruler1000
parent 8de9596a60
commit ef61988f61

View file

@ -102,10 +102,11 @@ public class Window extends HorizontalBlock {
@Override @Override
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (worldIn.isRemote()) { if (!worldIn.isRemote()) {
player.sendStatusMessage(new StringTextComponent("Client: Block activated!"), true); player.sendStatusMessage(new StringTextComponent("Client: Block activated!"), true);
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
} }
player.sendMessage(new StringTextComponent("blockActivated"), player.getUniqueID());
if (!worldIn.isRemote()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); if (!worldIn.isRemote()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit);
if (player.isCrouching()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); if (player.isCrouching()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit);