Paper/src/main/java/net/minecraft/server/InventoryCraftResult.java
Celtic Minstrel 0842bab48b [Bleeding] Implementation of inventory framework. Addresses BUKKIT-856
See the corresponding Bukkit commit for details.

Implementation details:
- Any packets that include an itemstack will send air stacks as null; maybe this will even eliminate the client crash that occurs if the client receives an air stack
- Better handling of null itemstacks in general (ie less converting them to air stacks)
- Inventory.setContents() can now take an array smaller than the inventory without error
- Player.updateInventory() should now correctly update the result slot in a crafting inventory

Some small credit goes to Afforess (initial implementation of openInventory() methods) and Drakia (initial implementation of InventoryOpenEvent and InventoryCloseEvent).
2012-02-29 15:19:07 -05:00

75 Zeilen
1.6 KiB
Java

package net.minecraft.server;
// CraftBukkit start
import java.util.ArrayList;
import java.util.List;
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.InventoryHolder;
// CraftBukkit end
public class InventoryCraftResult implements IInventory {
private ItemStack[] items = new ItemStack[1];
// CraftBukkit start
public ItemStack[] getContents() {
return this.items;
}
public InventoryHolder getOwner() {
return null; // Result slots don't get an owner
}
// Don't need a transaction; the InventoryCrafting keeps track of it for us
public void onOpen(CraftHumanEntity who) {}
public void onClose(CraftHumanEntity who) {}
public List<HumanEntity> getViewers() {
return new ArrayList<HumanEntity>();
}
// CraftBukkit end
public InventoryCraftResult() {}
public int getSize() {
return 1;
}
public ItemStack getItem(int i) {
return this.items[i];
}
public String getName() {
return "Result";
}
public ItemStack splitStack(int i, int j) {
if (this.items[i] != null) {
ItemStack itemstack = this.items[i];
this.items[i] = null;
return itemstack;
} else {
return null;
}
}
public void setItem(int i, ItemStack itemstack) {
this.items[i] = itemstack;
}
public int getMaxStackSize() {
return 64;
}
public void update() {}
public boolean a(EntityHuman entityhuman) {
return true;
}
public void f() {}
public void g() {}
}