mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +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 -> {
|
||||
//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 {
|
||||
|
@ -75,6 +75,8 @@ public class BlockPlacementListener {
|
||||
// Player didn't try to place a block but interacted with one
|
||||
PlayerUseItemOnBlockEvent event = new PlayerUseItemOnBlockEvent(player, hand, usedItem, blockPosition, cursorPosition, blockFace);
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user