From 3418f8d7a1597cd2aabad7e43ba39ab5151d3c66 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 22 Aug 2018 08:52:17 +1000 Subject: [PATCH] SPIGOT-4298: Block command sender returns wrong block --- nms-patches/TileEntityCommand.patch | 2 +- nms-patches/TileEntitySign.patch | 2 +- .../craftbukkit/command/CraftBlockCommandSender.java | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/nms-patches/TileEntityCommand.patch b/nms-patches/TileEntityCommand.patch index b23a8e4cea..a33d896945 100644 --- a/nms-patches/TileEntityCommand.patch +++ b/nms-patches/TileEntityCommand.patch @@ -7,7 +7,7 @@ + // CraftBukkit start + @Override + public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { -+ return new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper); ++ return new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, TileEntityCommand.this); + } + // CraftBukkit end + diff --git a/nms-patches/TileEntitySign.patch b/nms-patches/TileEntitySign.patch index d25d0893b4..6175865020 100644 --- a/nms-patches/TileEntitySign.patch +++ b/nms-patches/TileEntitySign.patch @@ -66,7 +66,7 @@ + // CraftBukkit start + @Override + public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { -+ return wrapper.f() != null ? wrapper.f().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper); ++ return wrapper.f() != null ? wrapper.f().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, this); + } + // CraftBukkit end + diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java index 3ad7dfdbf6..701a57e020 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java @@ -1,13 +1,12 @@ package org.bukkit.craftbukkit.command; -import net.minecraft.server.CommandBlockListenerAbstract; import net.minecraft.server.CommandListenerWrapper; -import net.minecraft.server.ICommandListener; import net.minecraft.server.IChatBaseComponent; -import net.minecraft.server.Vec3D; +import net.minecraft.server.TileEntity; import org.bukkit.block.Block; import org.bukkit.command.BlockCommandSender; +import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.util.CraftChatMessage; /** @@ -15,15 +14,16 @@ import org.bukkit.craftbukkit.util.CraftChatMessage; */ public class CraftBlockCommandSender extends ServerCommandSender implements BlockCommandSender { private final CommandListenerWrapper block; + private final TileEntity tile; - public CraftBlockCommandSender(CommandListenerWrapper commandBlockListenerAbstract) { + public CraftBlockCommandSender(CommandListenerWrapper commandBlockListenerAbstract, TileEntity tile) { super(); this.block = commandBlockListenerAbstract; + this.tile = tile; } public Block getBlock() { - Vec3D pos = block.getPosition(); - return block.getWorld().getWorld().getBlockAt((int) pos.x, (int) pos.y, (int) pos.z); + return CraftBlock.at(tile.getWorld(), tile.getPosition()); } public void sendMessage(String message) {