2019-04-23 04:00:00 +02:00
|
|
|
--- a/net/minecraft/server/TileEntityLectern.java
|
|
|
|
+++ b/net/minecraft/server/TileEntityLectern.java
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -1,10 +1,64 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.List;
|
2020-06-25 02:00:00 +02:00
|
|
|
+import java.util.UUID;
|
2019-04-23 04:00:00 +02:00
|
|
|
+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
|
2019-05-20 11:46:20 +02:00
|
|
|
+
|
|
|
|
+ // CraftBukkit start - add fields and methods
|
|
|
|
+ public final IInventory inventory = new LecternInventory();
|
|
|
|
+ public class LecternInventory implements IInventory {
|
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
+ 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() {
|
2019-06-12 10:06:43 +02:00
|
|
|
+ return (Lectern) TileEntityLectern.this.getOwner();
|
2019-04-23 04:00:00 +02:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2019-05-20 11:46:20 +02:00
|
|
|
|
|
|
|
- public final IInventory inventory = new IInventory() {
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
|
|
|
public int getSize() {
|
|
|
|
return 1;
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -49,11 +103,20 @@
|
2019-05-17 20:03:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
- public void setItem(int i, ItemStack itemstack) {}
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ public void setItem(int i, ItemStack itemstack) {
|
|
|
|
+ if (i == 0) {
|
2019-05-27 22:30:00 +02:00
|
|
|
+ TileEntityLectern.this.setBook(itemstack);
|
2019-07-22 23:41:39 +02:00
|
|
|
+ if (TileEntityLectern.this.getWorld() != null) {
|
|
|
|
+ BlockLectern.setHasBook(TileEntityLectern.this.getWorld(), TileEntityLectern.this.getPosition(), TileEntityLectern.this.getBlock(), TileEntityLectern.this.hasBook());
|
|
|
|
+ }
|
2019-05-17 20:03:36 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2019-04-23 04:00:00 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getMaxStackSize() {
|
|
|
|
- return 1;
|
|
|
|
+ return maxStack; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -135,7 +198,7 @@
|
2020-04-01 00:30:47 +02:00
|
|
|
if (j != this.page) {
|
|
|
|
this.page = j;
|
|
|
|
this.update();
|
|
|
|
- BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock());
|
|
|
|
+ if (this.world != null) BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock()); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -158,6 +221,32 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ @Override
|
2020-06-25 02:00:00 +02:00
|
|
|
+ public void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid) {
|
2019-04-23 04:00:00 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @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;
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -172,7 +261,8 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
Vec3D vec3d = Vec3D.a((BaseBlockPosition) this.position);
|
2019-04-23 04:00:00 +02:00
|
|
|
|
|
|
|
- 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
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -211,7 +301,7 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
|
|
|
|
@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
|