13
0
geforkt von Mirrors/Paper

SPIGOT-5047: Correct slot types for 1.14 inventories

Dieser Commit ist enthalten in:
md_5 2019-06-13 21:26:04 +10:00
Ursprung e8c0836216
Commit 4090d01f6d
8 geänderte Dateien mit 59 neuen und 63 gelöschten Zeilen

Datei anzeigen

@ -26,7 +26,7 @@
+ return bukkitEntity;
+ }
+
+ CraftInventoryStonecutter inventory = new CraftInventoryStonecutter(this.inventory);
+ CraftInventoryStonecutter inventory = new CraftInventoryStonecutter(this.inventory, this.n);
+ bukkitEntity = new CraftInventoryView(this.player, inventory, this);
+ return bukkitEntity;
+ }

Datei anzeigen

@ -10,7 +10,6 @@ import net.minecraft.server.InventoryEnderChest;
import net.minecraft.server.InventoryMerchant;
import net.minecraft.server.PlayerInventory;
import net.minecraft.server.TileEntityBarrel;
import net.minecraft.server.TileEntityBeacon;
import net.minecraft.server.TileEntityBlastFurnace;
import net.minecraft.server.TileEntityBrewingStand;
import net.minecraft.server.TileEntityDispenser;

Datei anzeigen

@ -5,54 +5,18 @@ import net.minecraft.server.ContainerAnvil;
import net.minecraft.server.IInventory;
import org.bukkit.Location;
import org.bukkit.inventory.AnvilInventory;
import org.bukkit.inventory.ItemStack;
public class CraftInventoryAnvil extends CraftInventory implements AnvilInventory {
public class CraftInventoryAnvil extends CraftResultInventory implements AnvilInventory {
private final Location location;
private final IInventory resultInventory;
private final ContainerAnvil container;
public CraftInventoryAnvil(Location location, IInventory inventory, IInventory resultInventory, ContainerAnvil container) {
super(inventory);
super(inventory, resultInventory);
this.location = location;
this.resultInventory = resultInventory;
this.container = container;
}
public IInventory getResultInventory() {
return resultInventory;
}
public IInventory getIngredientsInventory() {
return inventory;
}
@Override
public ItemStack getItem(int slot) {
if (slot < getIngredientsInventory().getSize()) {
net.minecraft.server.ItemStack item = getIngredientsInventory().getItem(slot);
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
} else {
net.minecraft.server.ItemStack item = getResultInventory().getItem(slot - getIngredientsInventory().getSize());
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
}
}
@Override
public void setItem(int index, ItemStack item) {
if (index < getIngredientsInventory().getSize()) {
getIngredientsInventory().setItem(index, CraftItemStack.asNMSCopy(item));
} else {
getResultInventory().setItem((index - getIngredientsInventory().getSize()), CraftItemStack.asNMSCopy(item));
}
}
@Override
public int getSize() {
return getResultInventory().getSize() + getIngredientsInventory().getSize();
}
@Override
public Location getLocation() {
return location;

Datei anzeigen

@ -3,17 +3,9 @@ package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.IInventory;
import org.bukkit.inventory.CartographyInventory;
public class CraftInventoryCartography extends CraftInventory implements CartographyInventory {
private final IInventory resultInventory;
public class CraftInventoryCartography extends CraftResultInventory implements CartographyInventory {
public CraftInventoryCartography(IInventory inventory, IInventory resultInventory) {
super(inventory);
this.resultInventory = resultInventory;
}
@Override
public int getSize() {
return super.getSize() + resultInventory.getSize();
super(inventory, resultInventory);
}
}

Datei anzeigen

@ -3,12 +3,9 @@ package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.IInventory;
import org.bukkit.inventory.GrindstoneInventory;
public class CraftInventoryGrindstone extends CraftInventory implements GrindstoneInventory {
private final IInventory resultInventory;
public class CraftInventoryGrindstone extends CraftResultInventory implements GrindstoneInventory {
public CraftInventoryGrindstone(IInventory inventory, IInventory resultInventory) {
super(inventory);
this.resultInventory = resultInventory;
super(inventory, resultInventory);
}
}

Datei anzeigen

@ -3,12 +3,9 @@ package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.IInventory;
import org.bukkit.inventory.LoomInventory;
public class CraftInventoryLoom extends CraftInventory implements LoomInventory {
private final IInventory resultInventory;
public class CraftInventoryLoom extends CraftResultInventory implements LoomInventory {
public CraftInventoryLoom(IInventory inventory, IInventory resultInventory) {
super(inventory);
this.resultInventory = resultInventory;
super(inventory, resultInventory);
}
}

Datei anzeigen

@ -3,9 +3,9 @@ package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.IInventory;
import org.bukkit.inventory.StonecutterInventory;
public class CraftInventoryStonecutter extends CraftInventory implements StonecutterInventory {
public class CraftInventoryStonecutter extends CraftResultInventory implements StonecutterInventory {
public CraftInventoryStonecutter(IInventory inventory) {
super(inventory);
public CraftInventoryStonecutter(IInventory inventory, IInventory resultInventory) {
super(inventory, resultInventory);
}
}

Datei anzeigen

@ -0,0 +1,47 @@
package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.IInventory;
import org.bukkit.inventory.ItemStack;
public class CraftResultInventory extends CraftInventory {
private final IInventory resultInventory;
public CraftResultInventory(IInventory inventory, IInventory resultInventory) {
super(inventory);
this.resultInventory = resultInventory;
}
public IInventory getResultInventory() {
return resultInventory;
}
public IInventory getIngredientsInventory() {
return inventory;
}
@Override
public ItemStack getItem(int slot) {
if (slot < getIngredientsInventory().getSize()) {
net.minecraft.server.ItemStack item = getIngredientsInventory().getItem(slot);
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
} else {
net.minecraft.server.ItemStack item = getResultInventory().getItem(slot - getIngredientsInventory().getSize());
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
}
}
@Override
public void setItem(int index, ItemStack item) {
if (index < getIngredientsInventory().getSize()) {
getIngredientsInventory().setItem(index, CraftItemStack.asNMSCopy(item));
} else {
getResultInventory().setItem((index - getIngredientsInventory().getSize()), CraftItemStack.asNMSCopy(item));
}
}
@Override
public int getSize() {
return getResultInventory().getSize() + getIngredientsInventory().getSize();
}
}