mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Store placer on Block when placed
This commit is contained in:
committed by
granny
parent
ab27287ecb
commit
305d99234b
@@ -1,49 +0,0 @@
|
|||||||
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/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();
|
|
||||||
@@ -1,5 +1,21 @@
|
|||||||
--- a/net/minecraft/world/item/ItemStack.java
|
--- a/net/minecraft/world/item/ItemStack.java
|
||||||
+++ b/net/minecraft/world/item/ItemStack.java
|
+++ b/net/minecraft/world/item/ItemStack.java
|
||||||
|
@@ -461,6 +_,7 @@
|
||||||
|
serverLevel.isBlockPlaceCancelled = true; // Paper - prevent calling cleanup logic when undoing a block place upon a cancelled BlockPlaceEvent
|
||||||
|
for (org.bukkit.block.BlockState blockstate : blocks) {
|
||||||
|
blockstate.update(true, false);
|
||||||
|
+ ((org.bukkit.craftbukkit.block.CraftBlock) blockstate.getBlock()).getNMS().getBlock().forgetPlacer(); // Purpur - Store placer on Block when placed
|
||||||
|
}
|
||||||
|
serverLevel.isBlockPlaceCancelled = false; // Paper - prevent calling cleanup logic when undoing a block place upon a cancelled BlockPlaceEvent
|
||||||
|
serverLevel.preventPoiUpdated = false;
|
||||||
|
@@ -486,6 +_,7 @@
|
||||||
|
if (!(block.getBlock() instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // Containers get placed automatically
|
||||||
|
block.onPlace(serverLevel, newPos, oldBlock, true, context);
|
||||||
|
}
|
||||||
|
+ block.getBlock().forgetPlacer(); // Purpur - Store placer on Block when placed
|
||||||
|
|
||||||
|
serverLevel.notifyAndUpdatePhysics(newPos, null, oldBlock, block, serverLevel.getBlockState(newPos), updateFlag, net.minecraft.world.level.block.Block.UPDATE_LIMIT); // send null chunk as chunk.k() returns false by this point
|
||||||
|
}
|
||||||
@@ -627,6 +_,26 @@
|
@@ -627,6 +_,26 @@
|
||||||
return this.isDamageableItem() && this.getDamageValue() > 0;
|
return this.isDamageableItem() && this.getDamageValue() > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
--- a/net/minecraft/world/level/block/Block.java
|
||||||
|
+++ b/net/minecraft/world/level/block/Block.java
|
||||||
|
@@ -412,7 +_,15 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlacedBy(Level level, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||||
|
- }
|
||||||
|
+ this.placer = placer; // Purpur - Store placer on Block when placed
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // Purpur start - Store placer on Block when placed
|
||||||
|
+ @Nullable protected LivingEntity placer = null;
|
||||||
|
+ public void forgetPlacer() {
|
||||||
|
+ this.placer = null;
|
||||||
|
+ }
|
||||||
|
+ // Purpur end - Store placer on Block when placed
|
||||||
|
|
||||||
|
public boolean isPossibleToRespawnInThis(BlockState state) {
|
||||||
|
return !state.isSolid() && !state.liquid();
|
||||||
Reference in New Issue
Block a user