2021-06-11 14:02:28 +02:00
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
2024-01-21 19:37:09 +01:00
index 556d8d395df3660ec7923c6814bc281c5fce442f..b4f2b75960674e81c8189dc908523c56ae2e5079 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
2023-12-06 04:00:14 +01:00
@@ -478,7 +478,7 @@ public final class ItemStack {
2021-06-11 14:02:28 +02:00
net.minecraft.world.level.block.state.BlockState block = world.getBlockState(newblockposition);
if (!(block.getBlock() instanceof BaseEntityBlock)) { // Containers get placed automatically
- block.getBlock().onPlace(block, world, newblockposition, oldBlock, true);
2023-07-04 10:22:56 +02:00
+ block.getBlock().onPlace(block, world, newblockposition, oldBlock, true, context); // Paper - pass context
2021-06-11 14:02:28 +02:00
}
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
2024-02-01 10:15:57 +01:00
index e707553bbddf84bc48ec7186da00c3eb0632946d..839469c1249829b42e752e5a1b613550c3f65bba 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java
2024-02-01 10:15:57 +01:00
@@ -144,12 +144,19 @@ public abstract class BaseFireBlock extends Block {
2021-06-11 14:02:28 +02:00
@Override
2024-02-01 10:15:57 +01:00
public 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
+ public 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())) {
2021-06-14 15:45:16 +02:00
if (BaseFireBlock.inPortalDimension(world)) {
2024-02-01 10:15:57 +01:00
Optional<PortalShape> optional = PortalShape.findEmptyPortalShape(world, pos, Direction.Axis.X);
2021-06-11 14:02:28 +02:00
if (optional.isPresent()) {
2021-11-24 17:39:04 +01:00
- ((PortalShape) optional.get()).createPortalBlocks();
2024-02-01 10:15:57 +01:00
+ ((PortalShape) optional.get()).createPortalBlocks(context); // Paper - pass context param
2021-06-11 14:02:28 +02:00
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
2024-02-01 10:15:57 +01:00
index 65b2873ca8032a64a4968b7587637644df1aeca5..c5116d12f3c073f0a8695a8cd00545e6d947644d 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/block/FireBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FireBlock.java
2024-02-01 10:15:57 +01:00
@@ -368,8 +368,10 @@ public class FireBlock extends BaseFireBlock {
2021-06-11 14:02:28 +02:00
}
@Override
- public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
- super.onPlace(state, world, pos, oldState, notify);
2024-02-01 10:15:57 +01:00
+ // Paper start - UseOnContext param
+ public 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));
2021-06-11 14:02:28 +02:00
}
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
2024-02-01 10:15:57 +01:00
index 6f60622f2dad5f82fb24505612e7e3a32722ab93..c7b6377aafd32f67eb8ba4dedd7cce5841b2d58d 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
2024-02-01 10:15:57 +01:00
@@ -163,6 +163,13 @@ public abstract class BlockBehaviour implements FeatureElement {
2021-06-11 14:02:28 +02:00
DebugPackets.sendNeighborsUpdatePacket(world, pos);
}
2024-02-01 10:15:57 +01:00
+ // Paper start - UseOnContext param
2021-06-11 14:02:28 +02:00
+ @Deprecated
2024-02-01 10:15:57 +01:00
+ public 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);
2021-06-11 14:02:28 +02:00
+ }
2024-02-01 10:15:57 +01:00
+ // Paper end - UseOnContext param
+
2021-11-24 23:26:32 +01:00
/** @deprecated */
2021-06-11 14:02:28 +02:00
@Deprecated
public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean 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
2024-02-01 10:15:57 +01:00
index 9fc4997277dd199cf6cffccceb3a9735398c5356..912cee9ec45876f831ca230b59a1be3b48ce6aa5 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/portal/PortalShape.java
+++ b/src/main/java/net/minecraft/world/level/portal/PortalShape.java
2024-02-01 10:15:57 +01:00
@@ -190,7 +190,14 @@ public class PortalShape {
2021-06-11 14:02:28 +02:00
}
// CraftBukkit start - return boolean
2024-02-01 10:15:57 +01:00
+ @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
2021-06-14 15:45:16 +02:00
org.bukkit.World bworld = this.level.getMinecraftWorld().getWorld();
2021-06-11 14:02:28 +02:00
// Copy below for loop
2024-02-01 10:15:57 +01:00
@@ -200,7 +207,7 @@ public class PortalShape {
2021-06-14 15:45:16 +02:00
this.blocks.setBlock(blockposition, iblockdata, 18);
2021-06-11 14:02:28 +02:00
});
2021-06-14 15:45:16 +02:00
- PortalCreateEvent event = new PortalCreateEvent((java.util.List<org.bukkit.block.BlockState>) (java.util.List) this.blocks.getList(), bworld, null, PortalCreateEvent.CreateReason.FIRE);
2024-02-01 10:15:57 +01:00
+ 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
2021-06-14 15:45:16 +02:00
this.level.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event);
2021-06-11 14:02:28 +02:00
if (event.isCancelled()) {