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/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java index aac771d7d8aefc6d5fcb497763ab9bac1ce2dc31..a9fcade014e24f7967b003dcc45d290e3f456034 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java @@ -508,6 +508,7 @@ public final class ItemStack implements DataComponentHolder { world.isBlockPlaceCancelled = true; // Paper - prevent calling cleanup logic when undoing a block place upon a cancelled BlockPlaceEvent for (BlockState blockstate : blocks) { blockstate.update(true, false); + ((CraftBlock) blockstate.getBlock()).getNMS().getBlock().forgetPlacer(); // Purpur - Store placer on Block when placed } world.isBlockPlaceCancelled = false; // Paper - prevent calling cleanup logic when undoing a block place upon a cancelled BlockPlaceEvent world.preventPoiUpdated = false; @@ -540,6 +541,7 @@ public final class ItemStack implements DataComponentHolder { if (!(block.getBlock() instanceof BaseEntityBlock)) { // Containers get placed automatically block.onPlace(world, newblockposition, oldBlock, true, context); } + block.getBlock().forgetPlacer(); // Purpur - Store placer on Block when placed 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/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java index c0b1f903962b25d8ff6c2b4fcd2be0e45de09b35..b88326cc6c54bf38a37f2491bfb2f0e0deb2b1df 100644 --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java @@ -433,7 +433,17 @@ public class Block extends BlockBehaviour implements ItemLike { } // Paper - fix drops not preventing stats/food exhaustion } - public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {} + // Purpur start - Store placer on Block when placed + @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 - Store placer on Block when placed public boolean isPossibleToRespawnInThis(BlockState state) { return !state.isSolid() && !state.liquid();