mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 01:17:47 +01:00
hollow-cube/block-interact-ack-fix
This commit is contained in:
parent
716f32972a
commit
1f1a2bf196
@ -117,6 +117,23 @@ public class PlayerInit {
|
|||||||
})
|
})
|
||||||
.addListener(PlayerPacketEvent.class, event -> {
|
.addListener(PlayerPacketEvent.class, event -> {
|
||||||
//System.out.println("in " + event.getPacket().getClass().getSimpleName());
|
//System.out.println("in " + event.getPacket().getClass().getSimpleName());
|
||||||
|
})
|
||||||
|
.addListener(PlayerUseItemOnBlockEvent.class, event -> {
|
||||||
|
if (event.getHand() != Player.Hand.MAIN) return;
|
||||||
|
|
||||||
|
var itemStack = event.getItemStack();
|
||||||
|
var block = event.getInstance().getBlock(event.getPosition());
|
||||||
|
|
||||||
|
if ("false".equals(block.getProperty("waterlogged")) && itemStack.material().equals(Material.WATER_BUCKET)) {
|
||||||
|
block = block.withProperty("waterlogged", "true");
|
||||||
|
System.out.println("SET WATERLOGGER");
|
||||||
|
} else if ("true".equals(block.getProperty("waterlogged")) && itemStack.material().equals(Material.BUCKET)) {
|
||||||
|
block = block.withProperty("waterlogged", "false");
|
||||||
|
System.out.println("SET NOT WATERLOGGED");
|
||||||
|
} else return;
|
||||||
|
|
||||||
|
event.getInstance().setBlock(event.getPosition(), block);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -75,6 +75,8 @@ public class BlockPlacementListener {
|
|||||||
// Player didn't try to place a block but interacted with one
|
// Player didn't try to place a block but interacted with one
|
||||||
PlayerUseItemOnBlockEvent event = new PlayerUseItemOnBlockEvent(player, hand, usedItem, blockPosition, cursorPosition, blockFace);
|
PlayerUseItemOnBlockEvent event = new PlayerUseItemOnBlockEvent(player, hand, usedItem, blockPosition, cursorPosition, blockFace);
|
||||||
EventDispatcher.call(event);
|
EventDispatcher.call(event);
|
||||||
|
// Ack the block change. This is required to reset the client prediction to the server state.
|
||||||
|
player.sendPacket(new AcknowledgeBlockChangePacket(packet.sequence()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user