SPIGOT-5047: Correct slot types for 1.14 inventories
Dieser Commit ist enthalten in:
Ursprung
e8c0836216
Commit
4090d01f6d
@ -26,7 +26,7 @@
|
|||||||
+ return bukkitEntity;
|
+ return bukkitEntity;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ CraftInventoryStonecutter inventory = new CraftInventoryStonecutter(this.inventory);
|
+ CraftInventoryStonecutter inventory = new CraftInventoryStonecutter(this.inventory, this.n);
|
||||||
+ bukkitEntity = new CraftInventoryView(this.player, inventory, this);
|
+ bukkitEntity = new CraftInventoryView(this.player, inventory, this);
|
||||||
+ return bukkitEntity;
|
+ return bukkitEntity;
|
||||||
+ }
|
+ }
|
||||||
|
@ -10,7 +10,6 @@ import net.minecraft.server.InventoryEnderChest;
|
|||||||
import net.minecraft.server.InventoryMerchant;
|
import net.minecraft.server.InventoryMerchant;
|
||||||
import net.minecraft.server.PlayerInventory;
|
import net.minecraft.server.PlayerInventory;
|
||||||
import net.minecraft.server.TileEntityBarrel;
|
import net.minecraft.server.TileEntityBarrel;
|
||||||
import net.minecraft.server.TileEntityBeacon;
|
|
||||||
import net.minecraft.server.TileEntityBlastFurnace;
|
import net.minecraft.server.TileEntityBlastFurnace;
|
||||||
import net.minecraft.server.TileEntityBrewingStand;
|
import net.minecraft.server.TileEntityBrewingStand;
|
||||||
import net.minecraft.server.TileEntityDispenser;
|
import net.minecraft.server.TileEntityDispenser;
|
||||||
|
@ -5,54 +5,18 @@ import net.minecraft.server.ContainerAnvil;
|
|||||||
import net.minecraft.server.IInventory;
|
import net.minecraft.server.IInventory;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.inventory.AnvilInventory;
|
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 Location location;
|
||||||
private final IInventory resultInventory;
|
|
||||||
private final ContainerAnvil container;
|
private final ContainerAnvil container;
|
||||||
|
|
||||||
public CraftInventoryAnvil(Location location, IInventory inventory, IInventory resultInventory, ContainerAnvil container) {
|
public CraftInventoryAnvil(Location location, IInventory inventory, IInventory resultInventory, ContainerAnvil container) {
|
||||||
super(inventory);
|
super(inventory, resultInventory);
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.resultInventory = resultInventory;
|
|
||||||
this.container = container;
|
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
|
@Override
|
||||||
public Location getLocation() {
|
public Location getLocation() {
|
||||||
return location;
|
return location;
|
||||||
|
@ -3,17 +3,9 @@ package org.bukkit.craftbukkit.inventory;
|
|||||||
import net.minecraft.server.IInventory;
|
import net.minecraft.server.IInventory;
|
||||||
import org.bukkit.inventory.CartographyInventory;
|
import org.bukkit.inventory.CartographyInventory;
|
||||||
|
|
||||||
public class CraftInventoryCartography extends CraftInventory implements CartographyInventory {
|
public class CraftInventoryCartography extends CraftResultInventory implements CartographyInventory {
|
||||||
|
|
||||||
private final IInventory resultInventory;
|
|
||||||
|
|
||||||
public CraftInventoryCartography(IInventory inventory, IInventory resultInventory) {
|
public CraftInventoryCartography(IInventory inventory, IInventory resultInventory) {
|
||||||
super(inventory);
|
super(inventory, resultInventory);
|
||||||
this.resultInventory = resultInventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSize() {
|
|
||||||
return super.getSize() + resultInventory.getSize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,9 @@ package org.bukkit.craftbukkit.inventory;
|
|||||||
import net.minecraft.server.IInventory;
|
import net.minecraft.server.IInventory;
|
||||||
import org.bukkit.inventory.GrindstoneInventory;
|
import org.bukkit.inventory.GrindstoneInventory;
|
||||||
|
|
||||||
public class CraftInventoryGrindstone extends CraftInventory implements GrindstoneInventory {
|
public class CraftInventoryGrindstone extends CraftResultInventory implements GrindstoneInventory {
|
||||||
|
|
||||||
private final IInventory resultInventory;
|
|
||||||
|
|
||||||
public CraftInventoryGrindstone(IInventory inventory, IInventory resultInventory) {
|
public CraftInventoryGrindstone(IInventory inventory, IInventory resultInventory) {
|
||||||
super(inventory);
|
super(inventory, resultInventory);
|
||||||
this.resultInventory = resultInventory;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,9 @@ package org.bukkit.craftbukkit.inventory;
|
|||||||
import net.minecraft.server.IInventory;
|
import net.minecraft.server.IInventory;
|
||||||
import org.bukkit.inventory.LoomInventory;
|
import org.bukkit.inventory.LoomInventory;
|
||||||
|
|
||||||
public class CraftInventoryLoom extends CraftInventory implements LoomInventory {
|
public class CraftInventoryLoom extends CraftResultInventory implements LoomInventory {
|
||||||
|
|
||||||
private final IInventory resultInventory;
|
|
||||||
|
|
||||||
public CraftInventoryLoom(IInventory inventory, IInventory resultInventory) {
|
public CraftInventoryLoom(IInventory inventory, IInventory resultInventory) {
|
||||||
super(inventory);
|
super(inventory, resultInventory);
|
||||||
this.resultInventory = resultInventory;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.bukkit.craftbukkit.inventory;
|
|||||||
import net.minecraft.server.IInventory;
|
import net.minecraft.server.IInventory;
|
||||||
import org.bukkit.inventory.StonecutterInventory;
|
import org.bukkit.inventory.StonecutterInventory;
|
||||||
|
|
||||||
public class CraftInventoryStonecutter extends CraftInventory implements StonecutterInventory {
|
public class CraftInventoryStonecutter extends CraftResultInventory implements StonecutterInventory {
|
||||||
|
|
||||||
public CraftInventoryStonecutter(IInventory inventory) {
|
public CraftInventoryStonecutter(IInventory inventory, IInventory resultInventory) {
|
||||||
super(inventory);
|
super(inventory, resultInventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren