SPIGOT-8005: Can't open Crafter block
This commit is contained in:
parent
f152cadda7
commit
a02758acdb
@ -21,7 +21,7 @@
|
|||||||
public abstract class Container {
|
public abstract class Container {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
@@ -67,6 +81,28 @@
|
@@ -67,6 +81,31 @@
|
||||||
private ContainerSynchronizer synchronizer;
|
private ContainerSynchronizer synchronizer;
|
||||||
private boolean suppressRemoteUpdates;
|
private boolean suppressRemoteUpdates;
|
||||||
|
|
||||||
@ -44,13 +44,16 @@
|
|||||||
+ Preconditions.checkState(this.title == null, "Title already set");
|
+ Preconditions.checkState(this.title == null, "Title already set");
|
||||||
+ this.title = title;
|
+ this.title = title;
|
||||||
+ }
|
+ }
|
||||||
+ public void startOpen() {}
|
+ protected boolean opened;
|
||||||
|
+ public void startOpen() {
|
||||||
|
+ this.opened = true;
|
||||||
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
+
|
||||||
protected Container(@Nullable Containers<?> containers, int i) {
|
protected Container(@Nullable Containers<?> containers, int i) {
|
||||||
this.carried = ItemStack.EMPTY;
|
this.carried = ItemStack.EMPTY;
|
||||||
this.remoteSlots = NonNullList.create();
|
this.remoteSlots = NonNullList.create();
|
||||||
@@ -192,6 +228,15 @@
|
@@ -192,6 +231,15 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +69,7 @@
|
|||||||
public void removeSlotListener(ICrafting icrafting) {
|
public void removeSlotListener(ICrafting icrafting) {
|
||||||
this.containerListeners.remove(icrafting);
|
this.containerListeners.remove(icrafting);
|
||||||
}
|
}
|
||||||
@@ -417,7 +462,7 @@
|
@@ -417,7 +465,7 @@
|
||||||
}
|
}
|
||||||
} else if (this.quickcraftStatus == 2) {
|
} else if (this.quickcraftStatus == 2) {
|
||||||
if (!this.quickcraftSlots.isEmpty()) {
|
if (!this.quickcraftSlots.isEmpty()) {
|
||||||
@ -75,7 +78,7 @@
|
|||||||
k = ((Slot) this.quickcraftSlots.iterator().next()).index;
|
k = ((Slot) this.quickcraftSlots.iterator().next()).index;
|
||||||
this.resetQuickCraft();
|
this.resetQuickCraft();
|
||||||
this.doClick(k, this.quickcraftType, InventoryClickType.PICKUP, entityhuman);
|
this.doClick(k, this.quickcraftType, InventoryClickType.PICKUP, entityhuman);
|
||||||
@@ -433,6 +478,7 @@
|
@@ -433,6 +481,7 @@
|
||||||
l = this.getCarried().getCount();
|
l = this.getCarried().getCount();
|
||||||
Iterator iterator = this.quickcraftSlots.iterator();
|
Iterator iterator = this.quickcraftSlots.iterator();
|
||||||
|
|
||||||
@ -83,7 +86,7 @@
|
|||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Slot slot1 = (Slot) iterator.next();
|
Slot slot1 = (Slot) iterator.next();
|
||||||
ItemStack itemstack2 = this.getCarried();
|
ItemStack itemstack2 = this.getCarried();
|
||||||
@@ -443,12 +489,48 @@
|
@@ -443,12 +492,48 @@
|
||||||
int l1 = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemstack1) + j1, k1);
|
int l1 = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemstack1) + j1, k1);
|
||||||
|
|
||||||
l -= l1 - j1;
|
l -= l1 - j1;
|
||||||
@ -135,7 +138,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.resetQuickCraft();
|
this.resetQuickCraft();
|
||||||
@@ -466,8 +548,11 @@
|
@@ -466,8 +551,11 @@
|
||||||
if (i == -999) {
|
if (i == -999) {
|
||||||
if (!this.getCarried().isEmpty()) {
|
if (!this.getCarried().isEmpty()) {
|
||||||
if (clickaction == ClickAction.PRIMARY) {
|
if (clickaction == ClickAction.PRIMARY) {
|
||||||
@ -148,7 +151,7 @@
|
|||||||
} else {
|
} else {
|
||||||
entityhuman.drop(this.getCarried().split(1), true);
|
entityhuman.drop(this.getCarried().split(1), true);
|
||||||
}
|
}
|
||||||
@@ -530,6 +615,15 @@
|
@@ -530,6 +618,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
slot.setChanged();
|
slot.setChanged();
|
||||||
@ -164,7 +167,7 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int j2;
|
int j2;
|
||||||
@@ -662,8 +756,9 @@
|
@@ -662,8 +759,9 @@
|
||||||
ItemStack itemstack = this.getCarried();
|
ItemStack itemstack = this.getCarried();
|
||||||
|
|
||||||
if (!itemstack.isEmpty()) {
|
if (!itemstack.isEmpty()) {
|
||||||
@ -175,7 +178,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -893,6 +988,11 @@
|
@@ -893,6 +991,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getCarried() {
|
public ItemStack getCarried() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/world/inventory/ContainerChest.java
|
--- a/net/minecraft/world/inventory/ContainerChest.java
|
||||||
+++ b/net/minecraft/world/inventory/ContainerChest.java
|
+++ b/net/minecraft/world/inventory/ContainerChest.java
|
||||||
@@ -6,10 +6,44 @@
|
@@ -6,10 +6,45 @@
|
||||||
import net.minecraft.world.entity.player.PlayerInventory;
|
import net.minecraft.world.entity.player.PlayerInventory;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
@ -39,13 +39,14 @@
|
|||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void startOpen() {
|
+ public void startOpen() {
|
||||||
|
+ super.startOpen();
|
||||||
+ this.container.startOpen(this.player.player);
|
+ this.container.startOpen(this.player.player);
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
|
||||||
private ContainerChest(Containers<?> containers, int i, PlayerInventory playerinventory, int j) {
|
private ContainerChest(Containers<?> containers, int i, PlayerInventory playerinventory, int j) {
|
||||||
this(containers, i, playerinventory, new InventorySubcontainer(9 * j), j);
|
this(containers, i, playerinventory, new InventorySubcontainer(9 * j), j);
|
||||||
@@ -52,7 +86,10 @@
|
@@ -52,7 +87,10 @@
|
||||||
checkContainerSize(iinventory, j * 9);
|
checkContainerSize(iinventory, j * 9);
|
||||||
this.container = iinventory;
|
this.container = iinventory;
|
||||||
this.containerRows = j;
|
this.containerRows = j;
|
||||||
@ -57,7 +58,7 @@
|
|||||||
boolean flag = true;
|
boolean flag = true;
|
||||||
|
|
||||||
this.addChestGrid(iinventory, 8, 18);
|
this.addChestGrid(iinventory, 8, 18);
|
||||||
@@ -72,6 +109,7 @@
|
@@ -72,6 +110,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(EntityHuman entityhuman) {
|
public boolean stillValid(EntityHuman entityhuman) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/world/inventory/ContainerShulkerBox.java
|
--- a/net/minecraft/world/inventory/ContainerShulkerBox.java
|
||||||
+++ b/net/minecraft/world/inventory/ContainerShulkerBox.java
|
+++ b/net/minecraft/world/inventory/ContainerShulkerBox.java
|
||||||
@@ -6,10 +6,34 @@
|
@@ -6,10 +6,35 @@
|
||||||
import net.minecraft.world.entity.player.PlayerInventory;
|
import net.minecraft.world.entity.player.PlayerInventory;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
@ -29,13 +29,14 @@
|
|||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void startOpen() {
|
+ public void startOpen() {
|
||||||
|
+ super.startOpen();
|
||||||
+ container.startOpen(player.player);
|
+ container.startOpen(player.player);
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
|
||||||
public ContainerShulkerBox(int i, PlayerInventory playerinventory) {
|
public ContainerShulkerBox(int i, PlayerInventory playerinventory) {
|
||||||
this(i, playerinventory, new InventorySubcontainer(27));
|
this(i, playerinventory, new InventorySubcontainer(27));
|
||||||
@@ -19,7 +43,8 @@
|
@@ -19,7 +44,8 @@
|
||||||
super(Containers.SHULKER_BOX, i);
|
super(Containers.SHULKER_BOX, i);
|
||||||
checkContainerSize(iinventory, 27);
|
checkContainerSize(iinventory, 27);
|
||||||
this.container = iinventory;
|
this.container = iinventory;
|
||||||
@ -45,7 +46,7 @@
|
|||||||
boolean flag = true;
|
boolean flag = true;
|
||||||
boolean flag1 = true;
|
boolean flag1 = true;
|
||||||
|
|
||||||
@@ -34,6 +59,7 @@
|
@@ -34,6 +60,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(EntityHuman entityhuman) {
|
public boolean stillValid(EntityHuman entityhuman) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/world/inventory/CrafterMenu.java
|
--- a/net/minecraft/world/inventory/CrafterMenu.java
|
||||||
+++ b/net/minecraft/world/inventory/CrafterMenu.java
|
+++ b/net/minecraft/world/inventory/CrafterMenu.java
|
||||||
@@ -10,8 +10,29 @@
|
@@ -10,8 +10,35 @@
|
||||||
import net.minecraft.world.item.crafting.RecipeCrafting;
|
import net.minecraft.world.item.crafting.RecipeCrafting;
|
||||||
import net.minecraft.world.level.block.CrafterBlock;
|
import net.minecraft.world.level.block.CrafterBlock;
|
||||||
|
|
||||||
@ -26,11 +26,17 @@
|
|||||||
+ bukkitEntity = new CraftCrafterView(this.player.getBukkitEntity(), inventory, this);
|
+ bukkitEntity = new CraftCrafterView(this.player.getBukkitEntity(), inventory, this);
|
||||||
+ return bukkitEntity;
|
+ return bukkitEntity;
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void startOpen() {
|
||||||
|
+ super.startOpen();
|
||||||
|
+ this.refreshRecipeResult();
|
||||||
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
protected static final int SLOT_COUNT = 9;
|
protected static final int SLOT_COUNT = 9;
|
||||||
private static final int INV_SLOT_START = 9;
|
private static final int INV_SLOT_START = 9;
|
||||||
private static final int INV_SLOT_END = 36;
|
private static final int INV_SLOT_END = 36;
|
||||||
@@ -106,6 +127,7 @@
|
@@ -106,18 +133,24 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(EntityHuman entityhuman) {
|
public boolean stillValid(EntityHuman entityhuman) {
|
||||||
@ -38,7 +44,10 @@
|
|||||||
return this.container.stillValid(entityhuman);
|
return this.container.stillValid(entityhuman);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,9 +137,13 @@
|
private void refreshRecipeResult() {
|
||||||
|
+ if (!this.opened) return; // CraftBukkit - SPIGOT-8005: don't refresh until opened
|
||||||
|
EntityHuman entityhuman = this.player;
|
||||||
|
|
||||||
if (entityhuman instanceof EntityPlayer entityplayer) {
|
if (entityhuman instanceof EntityPlayer entityplayer) {
|
||||||
WorldServer worldserver = entityplayer.serverLevel();
|
WorldServer worldserver = entityplayer.serverLevel();
|
||||||
CraftingInput craftinginput = this.container.asCraftInput();
|
CraftingInput craftinginput = this.container.asCraftInput();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user