craftbukkit/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch

86 lines
3.1 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/inventory/ContainerCartography.java
+++ b/net/minecraft/world/inventory/ContainerCartography.java
2024-04-24 01:15:00 +10:00
@@ -14,8 +14,30 @@
2021-03-16 09:00:00 +11:00
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.saveddata.maps.WorldMap;
2019-04-23 12:00:00 +10:00
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.inventory.CraftInventoryCartography;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+import org.bukkit.entity.Player;
+// CraftBukkit end
+
public class ContainerCartography extends Container {
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private Player player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
2021-06-11 15:00:00 +10:00
+ CraftInventoryCartography inventory = new CraftInventoryCartography(this.container, this.resultContainer);
2019-04-23 12:00:00 +10:00
+ bukkitEntity = new CraftInventoryView(this.player, inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
2021-06-11 15:00:00 +10:00
public static final int MAP_SLOT = 0;
public static final int ADDITIONAL_SLOT = 1;
public static final int RESULT_SLOT = 2;
2024-04-24 01:15:00 +10:00
@@ -40,6 +62,13 @@
2021-11-22 09:00:00 +11:00
ContainerCartography.this.slotsChanged(this);
super.setChanged();
}
+
+ // CraftBukkit start
+ @Override
+ public Location getLocation() {
+ return containeraccess.getLocation();
+ }
+ // CraftBukkit end
};
2021-06-11 15:00:00 +10:00
this.resultContainer = new InventoryCraftResult() {
@Override
2024-04-24 01:15:00 +10:00
@@ -47,15 +76,22 @@
2021-11-22 09:00:00 +11:00
ContainerCartography.this.slotsChanged(this);
super.setChanged();
2019-04-23 12:00:00 +10:00
}
+
+ // CraftBukkit start
+ @Override
+ public Location getLocation() {
+ return containeraccess.getLocation();
+ }
+ // CraftBukkit end
};
2021-06-11 15:00:00 +10:00
this.access = containeraccess;
2024-04-24 01:15:00 +10:00
- this.addSlot(new Slot(this, this.container, 0, 15, 15) {
+ this.addSlot(new Slot(this.container, 0, 15, 15) { // CraftBukkit - decompile error
@Override
public boolean mayPlace(ItemStack itemstack) {
return itemstack.is(Items.FILLED_MAP);
}
});
- this.addSlot(new Slot(this, this.container, 1, 15, 52) {
+ this.addSlot(new Slot(this.container, 1, 15, 52) { // CraftBukkit - decompile error
@Override
public boolean mayPlace(ItemStack itemstack) {
return itemstack.is(Items.PAPER) || itemstack.is(Items.MAP) || itemstack.is(Items.GLASS_PANE);
@@ -97,10 +133,12 @@
2021-11-22 09:00:00 +11:00
this.addSlot(new Slot(playerinventory, j, 8 + j * 18, 142));
2019-04-23 12:00:00 +10:00
}
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
@Override
2021-11-22 09:00:00 +11:00
public boolean stillValid(EntityHuman entityhuman) {
2019-04-23 12:00:00 +10:00
+ if (!this.checkReachable) return true; // CraftBukkit
2021-11-22 09:00:00 +11:00
return stillValid(this.access, entityhuman, Blocks.CARTOGRAPHY_TABLE);
2019-04-23 12:00:00 +10:00
}