From 53ee4ee8135a0da5c7d7fb9bafe0c54c2d76d09c Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sun, 7 Jan 2024 06:05:56 +0800 Subject: [PATCH] Copy custom block entity tag when doing custom placement --- build.gradle.kts | 2 +- .../moulberry/axiom/packet/SetBlockPacketListener.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 44ec1a7..efebb85 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "com.moulberry.axiom" -version = "1.5.6" +version = "1.5.7" description = "Serverside component for Axiom on Paper" java { diff --git a/src/main/java/com/moulberry/axiom/packet/SetBlockPacketListener.java b/src/main/java/com/moulberry/axiom/packet/SetBlockPacketListener.java index a4ec05c..c9f2905 100644 --- a/src/main/java/com/moulberry/axiom/packet/SetBlockPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/SetBlockPacketListener.java @@ -16,7 +16,9 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.ai.village.poi.PoiType; import net.minecraft.world.entity.ai.village.poi.PoiTypes; +import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.entity.BlockEntity; @@ -115,6 +117,8 @@ public class SetBlockPacketListener implements PluginMessageListener { CraftWorld world = player.level().getWorld(); + BlockPlaceContext blockPlaceContext = new BlockPlaceContext(player, hand, player.getItemInHand(hand), blockHit); + // Update blocks if (updateNeighbors) { int count = 0; @@ -252,6 +256,10 @@ public class SetBlockPacketListener implements PluginMessageListener { } } + if (!breaking) { + BlockItem.updateCustomBlockEntityTag(player.level(), player, blockPlaceContext.getClickedPos(), player.getItemInHand(hand)); + } + if (sequenceId >= 0) { player.connection.ackBlockChangesUpTo(sequenceId); }