Files
Purpur/patches/todo/server/0194-Store-placer-on-Block-when-placed.patch
2023-06-07 20:24:56 -04:00

50 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
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 71acec715d65737d0b13392b5b42b607937c2d15..d5c667a9ca5562c2df38e191748f081ef9ffbd68 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -417,6 +417,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;
@@ -446,6 +447,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 4f91e4832a94c3facbc711fcae4cb5ad540a5ca0..84f031ec0f196b90c78a6432f344e68b22d363c0 100644
--- a/src/main/java/net/minecraft/world/level/block/Block.java
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
@@ -434,7 +434,17 @@ public class Block extends BlockBehaviour implements ItemLike {
Block.dropResources(state, world, pos, blockEntity, player, tool);
}
- 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();