mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 19:52:55 +01:00
119 lines
7.2 KiB
Diff
119 lines
7.2 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 cc8825acea0d84b36194313656a6f70d8c049072..7f7445a2b68fd2e6e5fcd509d950a0f8d680c1fe 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
@@ -522,7 +522,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 e499a5eb843af3e2417bcb31add3c63443c0deff..993538f613e52ecd009f01e7b68fddba76b6a3e8 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, @javax.annotation.Nullable 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 d02f7a547dbe8943f82c07103b1fff203e4533c2..335f43e49d31acecfec8b6da9be9afe88cd95ca9 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
|
|
@@ -154,6 +154,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
|
|
}
|
|
@@ -1086,6 +1092,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 bb22b12b05de29bed00e433630c91f233fa9a366..57139a0b8adcd1ea25cd100be78402681856ee75 100644
|
|
--- a/src/main/java/net/minecraft/world/level/portal/PortalShape.java
|
|
+++ b/src/main/java/net/minecraft/world/level/portal/PortalShape.java
|
|
@@ -189,7 +189,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(@Nullable net.minecraft.world.item.context.UseOnContext useOnContext) {
|
|
+ // Paper end - UseOnContext param
|
|
org.bukkit.World bworld = this.level.getMinecraftWorld().getWorld();
|
|
|
|
// Copy below for loop
|
|
@@ -199,7 +206,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()) {
|