Paper/patches/server/0418-PortalCreateEvent-needs-to-know-its-entity.patch
Nassim Jahnke 2641c02193
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
69fa4695 Add some missing deprecation annotations
f850da2e Update Maven plugins/versions
8d8400db Use regular compiler seeing as ECJ doesn't support Java 21 JRE
c29e1688 Revert "BUILDTOOLS-676: Downgrade Maven compiler version"
07bce714 SPIGOT-7355: More field renames and fixes
6a8ea764 Fix bad merge in penultimate commit
50a7920c Fix imports in previous commit
83640dd1 PR-995: Add required feature to MinecraftExperimental for easy lookups
fc1f96cf BUILDTOOLS-676: Downgrade Maven compiler version

CraftBukkit Changes:
90f1059ba Fix item placement
661afb43c SPIGOT-7633: Clearer error message for missing particle data
807b465b3 SPIGOT-7634: Armadillo updates infrequently
590cf09a8 Fix unit tests always seeing Mojang server as unavailable
7c7ac5eb2 SPIGOT-7636: Fix clearing ItemMeta
4a72905cf SPIGOT-7635: Fix Player#transfer and cookie methods
ebb50e136 Fix incorrect Vault implementation
b33fed8b7 Update Maven plugins/versions
6f00f0608 SPIGOT-7632: Control middle clicking chest does not copy contents
db821f405 Use regular compiler seeing as ECJ doesn't support Java 21 JRE
8a2976737 Revert "BUILDTOOLS-676: Downgrade Maven compiler version"
0297f87bb SPIGOT-7355: More field renames and fixes
2d03bdf6a SPIGOT-7629: Fix loading banner patterns
e77951fac Fix equality of deserialized display names
c66f3e4fd SPIGOT-7631: Fix deserialisation of BlockStateMeta
9c2c7be8d SPIGOT-7630: Fix crash saving unticked leashed entities
8c1e7c841 PR-1384: Disable certain PlayerProfile tests, if Mojang's services or internet are not available
ced93d572 SPIGOT-7626: sendSignChange() has no effect
c77362cae SPIGOT-7625: ItemStack with lore cannot be serialized in 1.20.5
ff2004387 SPIGOT-7620: Fix server crash when hoppers transfer items to double chests
8b4abeb03 BUILDTOOLS-676: Downgrade Maven compiler version
2024-04-25 23:23:57 +02:00

120 lines
7.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mariell Hoversholm <proximyst@proximyst.com>
Date: Fri, 21 Aug 2020 20:57:54 +0200
Subject: [PATCH] PortalCreateEvent needs to know its entity
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index 72ce219546306fc50da37468f37cec8e6bf551fe..d95272b1765368a4cd968fa566ad68844dced4c8 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -502,7 +502,7 @@ public final class ItemStack implements DataComponentHolder {
net.minecraft.world.level.block.state.BlockState block = world.getBlockState(newblockposition);
if (!(block.getBlock() instanceof BaseEntityBlock)) { // Containers get placed automatically
- block.onPlace(world, newblockposition, oldBlock, true);
+ block.onPlace(world, newblockposition, oldBlock, true, context); // Paper - pass context
}
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/BaseFireBlock.java b/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java
index 233236733537e036d3a37a3102f3ca6b887d076f..da4fd07f75aefb53b03e40c668f6c4a23693ffcb 100644
--- a/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java
@@ -144,12 +144,19 @@ public abstract class BaseFireBlock extends Block {
@Override
protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
+ // Paper start - UseOnContext param
+ this.onPlace(state, world, pos, oldState, notify, null);
+ }
+
+ @Override
+ protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify, net.minecraft.world.item.context.UseOnContext context) {
+ // Paper end - UseOnContext param
if (!oldState.is(state.getBlock())) {
if (BaseFireBlock.inPortalDimension(world)) {
Optional<PortalShape> optional = PortalShape.findEmptyPortalShape(world, pos, Direction.Axis.X);
if (optional.isPresent()) {
- ((PortalShape) optional.get()).createPortalBlocks();
+ ((PortalShape) optional.get()).createPortalBlocks(context); // Paper - pass context param
return;
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/FireBlock.java b/src/main/java/net/minecraft/world/level/block/FireBlock.java
index ceaa2a7048afc4955d3695af5291e83a79d83c5d..5dad1aa26a8908cba6a08398a4bad27f31d4c2c0 100644
--- a/src/main/java/net/minecraft/world/level/block/FireBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FireBlock.java
@@ -368,8 +368,10 @@ public class FireBlock extends BaseFireBlock {
}
@Override
- protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
- super.onPlace(state, world, pos, oldState, notify);
+ // Paper start - UseOnContext param
+ protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify, net.minecraft.world.item.context.UseOnContext context) {
+ super.onPlace(state, world, pos, oldState, notify, context);
+ // Paper end - UseOnContext param
world.scheduleTick(pos, (Block) this, FireBlock.getFireTickDelay(world.random));
}
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
index da8b97c590fb38f65dee2e8a881a2f7ad658b5e7..939d116ea940d52b319e08a11f08d1ccc406cb76 100644
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -155,6 +155,12 @@ public abstract class BlockBehaviour implements FeatureElement {
DebugPackets.sendNeighborsUpdatePacket(world, pos);
}
+ // Paper start - UseOnContext param
+ protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify, net.minecraft.world.item.context.UseOnContext context) {
+ this.onPlace(state, world, pos, oldState, notify);
+ }
+ // Paper end - UseOnContext param
+
protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
org.spigotmc.AsyncCatcher.catchOp("block onPlace"); // Spigot
}
@@ -1080,6 +1086,12 @@ public abstract class BlockBehaviour implements FeatureElement {
this.getBlock().updateIndirectNeighbourShapes(this.asState(), world, pos, flags, maxUpdateDepth);
}
+ // Paper start
+ public void onPlace(Level world, BlockPos pos, BlockState state, boolean notify, net.minecraft.world.item.context.UseOnContext context) {
+ this.getBlock().onPlace(this.asState(), world, pos, state, notify, context);
+ }
+ // Paper end
+
public void onPlace(Level world, BlockPos pos, BlockState state, boolean notify) {
this.getBlock().onPlace(this.asState(), world, pos, state, notify);
}
diff --git a/src/main/java/net/minecraft/world/level/portal/PortalShape.java b/src/main/java/net/minecraft/world/level/portal/PortalShape.java
index 766884046e2c22da4cb99712ff09d1f439394523..935ae100d3672cf493ebb6a3e6f70442ea22219b 100644
--- a/src/main/java/net/minecraft/world/level/portal/PortalShape.java
+++ b/src/main/java/net/minecraft/world/level/portal/PortalShape.java
@@ -190,7 +190,14 @@ public class PortalShape {
}
// CraftBukkit start - return boolean
+ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper
public boolean createPortalBlocks() {
+ // Paper start - UseOnContext param
+ return this.createPortalBlocks(null);
+ }
+
+ public boolean createPortalBlocks(net.minecraft.world.item.context.UseOnContext useOnContext) {
+ // Paper end - UseOnContext param
org.bukkit.World bworld = this.level.getMinecraftWorld().getWorld();
// Copy below for loop
@@ -200,7 +207,7 @@ public class PortalShape {
this.blocks.setBlock(blockposition, iblockdata, 18);
});
- PortalCreateEvent event = new PortalCreateEvent((java.util.List<org.bukkit.block.BlockState>) (java.util.List) this.blocks.getList(), bworld, null, PortalCreateEvent.CreateReason.FIRE);
+ PortalCreateEvent event = new PortalCreateEvent((java.util.List<org.bukkit.block.BlockState>) (java.util.List) blocks.getList(), bworld, useOnContext == null || useOnContext.getPlayer() == null ? null : useOnContext.getPlayer().getBukkitEntity(), PortalCreateEvent.CreateReason.FIRE); // Paper - pass entity param
this.level.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event);
if (event.isCancelled()) {