aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches-Unmapped/0562-PortalCreateEvent-needs-to-know-its-entity.patch
blob: 51e748ada1c1198adb0697e1d610beadef572926 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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 158c7a30af8326fa419af391167c07d75b8611ac..fee862951f2767d4a3c5268dff157c185378a939 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -368,7 +368,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 e6ea1d29c7f3f4cb6039df0e35c8db94b6f38c3e..70c32b7a53a1107cced3491ebac19b0eaf4fec2e 100644
--- a/src/main/java/net/minecraft/world/level/block/BlockFire.java
+++ b/src/main/java/net/minecraft/world/level/block/BlockFire.java
@@ -15,6 +15,7 @@ import net.minecraft.core.EnumDirection;
 import net.minecraft.server.MCUtil;
 import net.minecraft.server.level.WorldServer;
 import net.minecraft.world.item.context.BlockActionContext;
+import net.minecraft.world.item.context.ItemActionContext;
 import net.minecraft.world.level.GameRules;
 import net.minecraft.world.level.GeneratorAccess;
 import net.minecraft.world.level.IBlockAccess;
@@ -364,8 +365,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..02047bf07c2008c7de8daf3d76b660e25b77bce8 100644
--- a/src/main/java/net/minecraft/world/level/block/BlockFireAbstract.java
+++ b/src/main/java/net/minecraft/world/level/block/BlockFireAbstract.java
@@ -7,6 +7,7 @@ import net.minecraft.world.damagesource.DamageSource;
 import net.minecraft.world.entity.Entity;
 import net.minecraft.world.entity.player.EntityHuman;
 import net.minecraft.world.item.context.BlockActionContext;
+import net.minecraft.world.item.context.ItemActionContext;
 import net.minecraft.world.level.GeneratorAccess;
 import net.minecraft.world.level.IBlockAccess;
 import net.minecraft.world.level.World;
@@ -66,14 +67,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 2a785ea58a7bdc80c703a60bc6ed602dc8040aa0..9af91784544dbb0555824a91088257659bdf2c3d 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
@@ -32,6 +32,7 @@ import net.minecraft.world.item.EnumColor;
 import net.minecraft.world.item.Item;
 import net.minecraft.world.item.ItemStack;
 import net.minecraft.world.item.context.BlockActionContext;
+import net.minecraft.world.item.context.ItemActionContext;
 import net.minecraft.world.level.BlockAccessAir;
 import net.minecraft.world.level.GeneratorAccess;
 import net.minecraft.world.level.IBlockAccess;
@@ -120,6 +121,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..3f8a674345bcad8289a48d2daa5e2a283528e952 100644
--- a/src/main/java/net/minecraft/world/level/portal/BlockPortalShape.java
+++ b/src/main/java/net/minecraft/world/level/portal/BlockPortalShape.java
@@ -11,6 +11,7 @@ import net.minecraft.tags.Tag;
 import net.minecraft.tags.TagsBlock;
 import net.minecraft.util.MathHelper;
 import net.minecraft.world.entity.EntitySize;
+import net.minecraft.world.item.context.ItemActionContext;
 import net.minecraft.world.level.GeneratorAccess;
 import net.minecraft.world.level.block.BlockPortal;
 import net.minecraft.world.level.block.Blocks;
@@ -177,7 +178,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 +193,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()) {