mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 18:27:41 +01:00
SPIGOT-4031: Improve bounds checking in CraftInventoryView.
By: Hex <hex@hex.lc>
This commit is contained in:
parent
11239259a0
commit
ac0ac69ea5
@ -50,7 +50,7 @@ public class CraftInventoryView extends InventoryView {
|
|||||||
@Override
|
@Override
|
||||||
public void setItem(int slot, ItemStack item) {
|
public void setItem(int slot, ItemStack item) {
|
||||||
net.minecraft.server.ItemStack stack = CraftItemStack.asNMSCopy(item);
|
net.minecraft.server.ItemStack stack = CraftItemStack.asNMSCopy(item);
|
||||||
if (slot != -999) {
|
if (slot >= 0) {
|
||||||
container.getSlot(slot).set(stack);
|
container.getSlot(slot).set(stack);
|
||||||
} else {
|
} else {
|
||||||
player.getHandle().drop(stack, false);
|
player.getHandle().drop(stack, false);
|
||||||
@ -59,7 +59,7 @@ public class CraftInventoryView extends InventoryView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(int slot) {
|
public ItemStack getItem(int slot) {
|
||||||
if (slot == -999) {
|
if (slot < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return CraftItemStack.asCraftMirror(container.getSlot(slot).getItem());
|
return CraftItemStack.asCraftMirror(container.getSlot(slot).getItem());
|
||||||
@ -125,7 +125,7 @@ public class CraftInventoryView extends InventoryView {
|
|||||||
// Nothing to do, it's a CONTAINER slot
|
// Nothing to do, it's a CONTAINER slot
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (slot == -999 || slot == -1) {
|
if (slot < 0) {
|
||||||
type = SlotType.OUTSIDE;
|
type = SlotType.OUTSIDE;
|
||||||
} else if (inventory.getType() == InventoryType.CRAFTING) { // Also includes creative inventory
|
} else if (inventory.getType() == InventoryType.CRAFTING) { // Also includes creative inventory
|
||||||
if (slot < 9) {
|
if (slot < 9) {
|
||||||
|
Loading…
Reference in New Issue
Block a user