Paper/Spigot-Server-Patches/0563-PortalCreateEvent-needs-to-know-its-entity.patch
jmp 1718f61bf8 Updated Upstream (CraftBukkit/Spigot)
Doesn't compile yet.

CraftBukkit Changes:
90d6905b Repackage NMS
69cf961d Repackage patches

Spigot Changes:
79d53c28 Repackage NMS
2021-03-18 18:03:22 +01:00

103 Zeilen
6.5 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 8b5aaa18d278f20e32e25edddc2a10069c2ba5e6..81c7aed22bd63179e6016de801497d17d804e301 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -367,7 +367,7 @@ public final class ItemStack {
IBlockData block = world.getType(newblockposition);
if (!(block.getBlock() instanceof BlockTileEntity)) { // Containers get placed automatically
- block.getBlock().onPlace(block, world, newblockposition, oldBlock, true);
+ block.getBlock().onPlace(block, world, newblockposition, oldBlock, true, itemactioncontext); // Paper - pass itemactioncontext
}
world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getType(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/BlockFire.java b/src/main/java/net/minecraft/world/level/block/BlockFire.java
index f940d93c5bceb4b130a40c1cde06ab8d2e82cd74..c695528d7e69fea5c168951583fea5841ddb80f1 100644
--- a/src/main/java/net/minecraft/world/level/block/BlockFire.java
+++ b/src/main/java/net/minecraft/world/level/block/BlockFire.java
@@ -363,8 +363,10 @@ public class BlockFire extends BlockFireAbstract {
}
@Override
- public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) {
- super.onPlace(iblockdata, world, blockposition, iblockdata1, flag);
+ // Paper start - ItemActionContext param
+ public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag, ItemActionContext itemActionContext) {
+ super.onPlace(iblockdata, world, blockposition, iblockdata1, flag, itemActionContext);
+ // Paper end
world.getBlockTickList().a(blockposition, this, a(world.random));
}
diff --git a/src/main/java/net/minecraft/world/level/block/BlockFireAbstract.java b/src/main/java/net/minecraft/world/level/block/BlockFireAbstract.java
index b86513497b7ca8bde84176f5228ef9c479a73abb..2ddedcf3e56b8958671b81e6fe8768535951ee25 100644
--- a/src/main/java/net/minecraft/world/level/block/BlockFireAbstract.java
+++ b/src/main/java/net/minecraft/world/level/block/BlockFireAbstract.java
@@ -66,14 +66,17 @@ public abstract class BlockFireAbstract extends Block {
super.a(iblockdata, world, blockposition, entity);
}
+ // Paper start - ItemActionContext param
+ @Override public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) { this.onPlace(iblockdata, world, blockposition, iblockdata1, flag, null); }
@Override
- public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) {
+ public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag, ItemActionContext itemActionContext) {
+ // Paper end
if (!iblockdata1.a(iblockdata.getBlock())) {
if (a(world)) {
Optional<BlockPortalShape> optional = BlockPortalShape.a((GeneratorAccess) world, blockposition, EnumDirection.EnumAxis.X);
if (optional.isPresent()) {
- ((BlockPortalShape) optional.get()).createPortal();
+ ((BlockPortalShape) optional.get()).createPortal(itemActionContext); // Paper - pass ItemActionContext param
return;
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBase.java b/src/main/java/net/minecraft/world/level/block/state/BlockBase.java
index 1fcbb2e78904aa9f6ab870d7e2bc95ae25fbd33a..ffb5dc4fabb9249dfc1c8521025eaad0d6205329 100644
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBase.java
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBase.java
@@ -119,6 +119,12 @@ public abstract class BlockBase {
PacketDebug.a(world, blockposition);
}
+ // Paper start - add ItemActionContext param
+ @Deprecated
+ public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag, ItemActionContext itemActionContext) {
+ this.onPlace(iblockdata, world, blockposition, iblockdata1, flag);
+ }
+ // Paper end
@Deprecated
public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) {
org.spigotmc.AsyncCatcher.catchOp("block onPlace"); // Spigot
diff --git a/src/main/java/net/minecraft/world/level/portal/BlockPortalShape.java b/src/main/java/net/minecraft/world/level/portal/BlockPortalShape.java
index 9f7ff56e43a3dc0cc57ed3a2c6dbc729afafa1f8..1a5845a0da039fafca7ef08f968fe3b800e01991 100644
--- a/src/main/java/net/minecraft/world/level/portal/BlockPortalShape.java
+++ b/src/main/java/net/minecraft/world/level/portal/BlockPortalShape.java
@@ -177,7 +177,10 @@ public class BlockPortalShape {
}
// CraftBukkit start - return boolean
- public boolean createPortal() {
+ // Paper start - ItemActionContext param
+ @Deprecated public boolean createPortal() { return this.createPortal(null); }
+ public boolean createPortal(ItemActionContext itemActionContext) {
+ // Paper end
org.bukkit.World bworld = this.b.getMinecraftWorld().getWorld();
// Copy below for loop
@@ -189,7 +192,7 @@ public class BlockPortalShape {
blocks.add(state);
});
- PortalCreateEvent event = new PortalCreateEvent(blocks, bworld, null, PortalCreateEvent.CreateReason.FIRE);
+ PortalCreateEvent event = new PortalCreateEvent(blocks, bworld, itemActionContext == null || itemActionContext.getEntity() == null ? null : itemActionContext.getEntity().getBukkitEntity(), PortalCreateEvent.CreateReason.FIRE); // Paper - pass entity param
this.b.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event);
if (event.isCancelled()) {