mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
50 lines
3.1 KiB
Diff
50 lines
3.1 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 095c86ea25fc4f385d96d2e92fa67a150e27c489..b43a7bf5d8f555f97cc851c2c4c01b8a729396f6 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
+++ b/src/main/java/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/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
index c0b1f903962b25d8ff6c2b4fcd2be0e45de09b35..b88326cc6c54bf38a37f2491bfb2f0e0deb2b1df 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
|
+++ b/src/main/java/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();
|