mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-18 08:36:13 +01:00
127 lines
3.9 KiB
Diff
127 lines
3.9 KiB
Diff
|
--- a/net/minecraft/server/TileEntityLectern.java
|
||
|
+++ b/net/minecraft/server/TileEntityLectern.java
|
||
|
@@ -1,10 +1,61 @@
|
||
|
package net.minecraft.server;
|
||
|
|
||
|
import javax.annotation.Nullable;
|
||
|
+// CraftBukkit start
|
||
|
+import java.util.ArrayList;
|
||
|
+import java.util.Arrays;
|
||
|
+import java.util.List;
|
||
|
+import org.bukkit.Location;
|
||
|
+import org.bukkit.block.Lectern;
|
||
|
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||
|
+import org.bukkit.entity.HumanEntity;
|
||
|
+import org.bukkit.inventory.InventoryHolder;
|
||
|
+// CraftBukkit end
|
||
|
|
||
|
-public class TileEntityLectern extends TileEntity implements Clearable, ITileInventory {
|
||
|
+public class TileEntityLectern extends TileEntity implements Clearable, ITileInventory, ICommandListener { // CraftBukkit - ICommandListener
|
||
|
|
||
|
public final IInventory inventory = new IInventory() {
|
||
|
+ // CraftBukkit start - add fields and methods
|
||
|
+ public List<HumanEntity> transaction = new ArrayList<>();
|
||
|
+ private int maxStack = 1;
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public List<ItemStack> getContents() {
|
||
|
+ return Arrays.asList(book);
|
||
|
+ }
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public void onOpen(CraftHumanEntity who) {
|
||
|
+ transaction.add(who);
|
||
|
+ }
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public void onClose(CraftHumanEntity who) {
|
||
|
+ transaction.remove(who);
|
||
|
+ }
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public List<HumanEntity> getViewers() {
|
||
|
+ return transaction;
|
||
|
+ }
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public void setMaxStackSize(int i) {
|
||
|
+ maxStack = i;
|
||
|
+ }
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public Location getLocation() {
|
||
|
+ return new Location(world.getWorld(), position.getX(), position.getY(), position.getZ());
|
||
|
+ }
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public InventoryHolder getOwner() {
|
||
|
+ return (Lectern) CraftBlock.at(world, position).getState();
|
||
|
+ }
|
||
|
+ // CraftBukkit end
|
||
|
+
|
||
|
@Override
|
||
|
public int getSize() {
|
||
|
return 1;
|
||
|
@@ -53,7 +104,7 @@
|
||
|
|
||
|
@Override
|
||
|
public int getMaxStackSize() {
|
||
|
- return 1;
|
||
|
+ return maxStack; // CraftBukkit
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
@@ -158,6 +209,32 @@
|
||
|
return itemstack;
|
||
|
}
|
||
|
|
||
|
+ // CraftBukkit start
|
||
|
+ @Override
|
||
|
+ public void sendMessage(IChatBaseComponent ichatbasecomponent) {
|
||
|
+ }
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
|
||
|
+ return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, this);
|
||
|
+ }
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public boolean shouldSendSuccess() {
|
||
|
+ return false;
|
||
|
+ }
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public boolean shouldSendFailure() {
|
||
|
+ return false;
|
||
|
+ }
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public boolean shouldBroadcastCommands() {
|
||
|
+ return false;
|
||
|
+ }
|
||
|
+
|
||
|
+ // CraftBukkit end
|
||
|
private CommandListenerWrapper a(@Nullable EntityHuman entityhuman) {
|
||
|
String s;
|
||
|
Object object;
|
||
|
@@ -172,7 +249,8 @@
|
||
|
|
||
|
Vec3D vec3d = new Vec3D((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D);
|
||
|
|
||
|
- return new CommandListenerWrapper(ICommandListener.DUMMY, vec3d, Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityhuman);
|
||
|
+ // CraftBukkit - this
|
||
|
+ return new CommandListenerWrapper(this, vec3d, Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityhuman);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
@@ -206,7 +284,7 @@
|
||
|
|
||
|
@Override
|
||
|
public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) {
|
||
|
- return new ContainerLectern(i, this.inventory, this.containerProperties);
|
||
|
+ return new ContainerLectern(i, this.inventory, this.containerProperties, playerinventory); // CraftBukkit
|
||
|
}
|
||
|
|
||
|
@Override
|