From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Sat, 3 Jul 2021 18:40:32 -0500 Subject: [PATCH] Store placer on Block when placed diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java index 03271cdffd99ab443904a5d1da05d79c0566cbb4..dbc7bebaa4b14ee0eca51cb82e1aa80774f57fa5 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -384,6 +384,7 @@ public final class ItemStack { world.preventPoiUpdated = true; // CraftBukkit - SPIGOT-5710 for (BlockState blockstate : blocks) { blockstate.update(true, false); + ((CraftBlock) blockstate.getBlock()).getNMS().getBlock().forgetPlacer(); // Purpur } world.preventPoiUpdated = false; @@ -413,6 +414,7 @@ public final class ItemStack { if (!(block.getBlock() instanceof BaseEntityBlock)) { // Containers get placed automatically block.getBlock().onPlace(block, world, newblockposition, oldBlock, true, itemactioncontext); // Paper - pass itemactioncontext } + block.getBlock().forgetPlacer(); // Purpur world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point } diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java index ab5b9f00123e2ede2931ffc520684e482aac49b4..9a4858eb3a3289d3da9c1984d94ba7244db254bf 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java @@ -436,7 +436,17 @@ public class Block extends BlockBehaviour implements ItemLike { Block.dropResources(state, world, pos, blockEntity, player, stack); } - public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {} + // Purpur start + @Nullable protected LivingEntity placer = null; + + public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) { + this.placer = placer; + } + + public void forgetPlacer() { + this.placer = null; + } + // Purpur end public boolean isPossibleToRespawnInThis() { return !this.material.isSolid() && !this.material.isLiquid();