mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 00:10:32 +01:00
89d51d5f29
Because this exploit has been widely known for years and has not been fixed by Mojang, we decided that it was worth allowing people to toggle it on/off due to how easy it is to make it configurable. It should be noted that this decision does not promise all future exploits will be configurable.
108 lines
6.4 KiB
Diff
108 lines
6.4 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 4a6e128c62c890c34b62f826d586ae6a424e7f01..9d2d305a5e66b9f3d94f6464736f5bb40adae591 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
@@ -480,7 +480,7 @@ public final class ItemStack {
|
|
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);
|
|
+ block.getBlock().onPlace(block, 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 e707553bbddf84bc48ec7186da00c3eb0632946d..839469c1249829b42e752e5a1b613550c3f65bba 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
|
|
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())) {
|
|
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 65b2873ca8032a64a4968b7587637644df1aeca5..c5116d12f3c073f0a8695a8cd00545e6d947644d 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
|
|
- public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
|
|
- super.onPlace(state, world, pos, oldState, notify);
|
|
+ // 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));
|
|
}
|
|
|
|
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 6f60622f2dad5f82fb24505612e7e3a32722ab93..c7b6377aafd32f67eb8ba4dedd7cce5841b2d58d 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
|
|
@@ -163,6 +163,13 @@ public abstract class BlockBehaviour implements FeatureElement {
|
|
DebugPackets.sendNeighborsUpdatePacket(world, pos);
|
|
}
|
|
|
|
+ // Paper start - UseOnContext param
|
|
+ @Deprecated
|
|
+ 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);
|
|
+ }
|
|
+ // Paper end - UseOnContext param
|
|
+
|
|
/** @deprecated */
|
|
@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
|
|
index 9fc4997277dd199cf6cffccceb3a9735398c5356..912cee9ec45876f831ca230b59a1be3b48ce6aa5 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()) {
|