From f7f381a54e0c6c3cfdbc6835d2b7a497e1646bb0 Mon Sep 17 00:00:00 2001 From: TheMode Date: Wed, 5 May 2021 21:41:48 +0200 Subject: [PATCH 1/4] Update kotlin plugin to 1.5.0 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 20b6b5125..b612cb005 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { id 'java' id 'maven-publish' id 'net.ltgt.apt' version '0.10' - id 'org.jetbrains.kotlin.jvm' version '1.4.21' + id 'org.jetbrains.kotlin.jvm' version '1.5.0' id 'checkstyle' } From 9a4fdae38a4fb73b048ce0d0509ce0030f412c5e Mon Sep 17 00:00:00 2001 From: TheMode Date: Fri, 7 May 2021 00:15:16 +0200 Subject: [PATCH 2/4] Fix block being transformed to AIR on interaction when in adventure mode --- .../server/listener/BlockPlacementListener.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/minestom/server/listener/BlockPlacementListener.java b/src/main/java/net/minestom/server/listener/BlockPlacementListener.java index 413d34a6d..cce66b69a 100644 --- a/src/main/java/net/minestom/server/listener/BlockPlacementListener.java +++ b/src/main/java/net/minestom/server/listener/BlockPlacementListener.java @@ -99,13 +99,15 @@ public class BlockPlacementListener { blockPosition.add(offsetX, offsetY, offsetZ); if (!canPlaceBlock) { - //Send a block change with AIR as block to keep the client in sync, - //using refreshChunk results in the client not being in sync - //after rapid invalid block placements - BlockChangePacket blockChangePacket = new BlockChangePacket(); - blockChangePacket.blockPosition = blockPosition; - blockChangePacket.blockStateId = Block.AIR.getBlockId(); - player.getPlayerConnection().sendPacket(blockChangePacket); + if (usedItem.getMaterial().isBlock()) { + //Send a block change with AIR as block to keep the client in sync, + //using refreshChunk results in the client not being in sync + //after rapid invalid block placements + BlockChangePacket blockChangePacket = new BlockChangePacket(); + blockChangePacket.blockPosition = blockPosition; + blockChangePacket.blockStateId = Block.AIR.getBlockId(); + player.getPlayerConnection().sendPacket(blockChangePacket); + } return; } From 744b8e7886129d490a91613455e41297a2879f44 Mon Sep 17 00:00:00 2001 From: TheMode Date: Fri, 7 May 2021 00:16:09 +0200 Subject: [PATCH 3/4] Smarter code --- .../net/minestom/server/listener/BlockPlacementListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/minestom/server/listener/BlockPlacementListener.java b/src/main/java/net/minestom/server/listener/BlockPlacementListener.java index cce66b69a..2eab9562a 100644 --- a/src/main/java/net/minestom/server/listener/BlockPlacementListener.java +++ b/src/main/java/net/minestom/server/listener/BlockPlacementListener.java @@ -99,7 +99,7 @@ public class BlockPlacementListener { blockPosition.add(offsetX, offsetY, offsetZ); if (!canPlaceBlock) { - if (usedItem.getMaterial().isBlock()) { + if (useMaterial.isBlock()) { //Send a block change with AIR as block to keep the client in sync, //using refreshChunk results in the client not being in sync //after rapid invalid block placements From 6bd1fcff65675ecec55d64e0b0115dc3f53d8b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20Noel?= Date: Fri, 7 May 2021 02:46:07 +0200 Subject: [PATCH 4/4] Remove block light data and send full sky data --- .../net/minestom/server/instance/Chunk.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/minestom/server/instance/Chunk.java b/src/main/java/net/minestom/server/instance/Chunk.java index 63a6df454..53987e804 100644 --- a/src/main/java/net/minestom/server/instance/Chunk.java +++ b/src/main/java/net/minestom/server/instance/Chunk.java @@ -417,22 +417,18 @@ public abstract class Chunk implements Viewable, Tickable, DataContainer { UpdateLightPacket updateLightPacket = new UpdateLightPacket(getIdentifier(), getLastChangeTime()); updateLightPacket.chunkX = getChunkX(); updateLightPacket.chunkZ = getChunkZ(); - updateLightPacket.skyLightMask = 0x3FFF0; - updateLightPacket.blockLightMask = 0x3F; - updateLightPacket.emptySkyLightMask = 0x0F; - updateLightPacket.emptyBlockLightMask = 0x3FFC0; + updateLightPacket.skyLightMask = 0b111111111111111111; + updateLightPacket.emptySkyLightMask = 0b000000000000000000; + updateLightPacket.blockLightMask = 0b000000000000000000; + updateLightPacket.emptyBlockLightMask = 0b111111111111111111; byte[] bytes = new byte[2048]; Arrays.fill(bytes, (byte) 0xFF); - List temp = new ArrayList<>(14); - List temp2 = new ArrayList<>(6); - for (int i = 0; i < 14; ++i) { + final List temp = new ArrayList<>(18); + for (int i = 0; i < 18; ++i) { temp.add(bytes); } - for (int i = 0; i < 6; ++i) { - temp2.add(bytes); - } updateLightPacket.skyLight = temp; - updateLightPacket.blockLight = temp2; + updateLightPacket.blockLight = new ArrayList<>(0); return updateLightPacket; }