| 1 | package net.minecraft.inventory;
|
| 2 |
|
| 3 | import net.minecraft.entity.player.EntityPlayer;
|
| 4 | import net.minecraft.item.ItemStack;
|
| 5 | import net.minecraft.util.ChatComponentText;
|
| 6 | import net.minecraft.util.ChatComponentTranslation;
|
| 7 | import net.minecraft.util.IChatComponent;
|
| 8 |
|
| 9 | public class InventoryCraftResult implements IInventory
|
| 10 | {
|
| 11 | /** A list of one item containing the result of the crafting formula */
|
| 12 | private ItemStack[] stackResult = new ItemStack[1];
|
| 13 |
|
| 14 | /**
|
| 15 | * Returns the number of slots in the inventory.
|
| 16 | */
|
| 17 | public int getSizeInventory()
|
| 18 | {
|
| 19 | return 1;
|
| 20 | }
|
| 21 |
|
| 22 | /**
|
| 23 | * Returns the stack in the given slot.
|
| 24 | */
|
| 25 | public ItemStack getStackInSlot(int index)
|
| 26 | {
|
| 27 | return this.stackResult[0];
|
| 28 | }
|
| 29 |
|
| 30 | /**
|
| 31 | * Get the name of this object. For players this returns their username
|
| 32 | */
|
| 33 | public String getName()
|
| 34 | {
|
| 35 | return "Result";
|
| 36 | }
|
| 37 |
|
| 38 | /**
|
| 39 | * Returns true if this thing is named
|
| 40 | */
|
| 41 | public boolean hasCustomName()
|
| 42 | {
|
| 43 | return false;
|
| 44 | }
|
| 45 |
|
| 46 | /**
|
| 47 | * Get the formatted ChatComponent that will be used for the sender's username in chat
|
| 48 | */
|
| 49 | public IChatComponent getDisplayName()
|
| 50 | {
|
| 51 | return (IChatComponent)(this.hasCustomName() ? new ChatComponentText(this.getName()) : new ChatComponentTranslation(this.getName(), new Object[0]));
|
| 52 | }
|
| 53 |
|
| 54 | /**
|
| 55 | * Removes up to a specified number of items from an inventory slot and returns them in a new stack.
|
| 56 | */
|
| 57 | public ItemStack decrStackSize(int index, int count)
|
| 58 | {
|
| 59 | if (this.stackResult[0] != null)
|
| 60 | {
|
| 61 | ItemStack itemstack = this.stackResult[0];
|
| 62 | this.stackResult[0] = null;
|
| 63 | return itemstack;
|
| 64 | }
|
| 65 | else
|
| 66 | {
|
| 67 | return null;
|
| 68 | }
|
| 69 | }
|
| 70 |
|
| 71 | /**
|
| 72 | * Removes a stack from the given slot and returns it.
|
| 73 | */
|
| 74 | public ItemStack removeStackFromSlot(int index)
|
| 75 | {
|
| 76 | if (this.stackResult[0] != null)
|
| 77 | {
|
| 78 | ItemStack itemstack = this.stackResult[0];
|
| 79 | this.stackResult[0] = null;
|
| 80 | return itemstack;
|
| 81 | }
|
| 82 | else
|
| 83 | {
|
| 84 | return null;
|
| 85 | }
|
| 86 | }
|
| 87 |
|
| 88 | /**
|
| 89 | * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
|
| 90 | */
|
| 91 | public void setInventorySlotContents(int index, ItemStack stack)
|
| 92 | {
|
| 93 | this.stackResult[0] = stack;
|
| 94 | }
|
| 95 |
|
| 96 | /**
|
| 97 | * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
|
| 98 | */
|
| 99 | public int getInventoryStackLimit()
|
| 100 | {
|
| 101 | return 64;
|
| 102 | }
|
| 103 |
|
| 104 | /**
|
| 105 | * For tile entities, ensures the chunk containing the tile entity is saved to disk later - the game won't think it
|
| 106 | * hasn't changed and skip it.
|
| 107 | */
|
| 108 | public void markDirty()
|
| 109 | {
|
| 110 | }
|
| 111 |
|
| 112 | /**
|
| 113 | * Do not make give this method the name canInteractWith because it clashes with Container
|
| 114 | */
|
| 115 | public boolean isUseableByPlayer(EntityPlayer player)
|
| 116 | {
|
| 117 | return true;
|
| 118 | }
|
| 119 |
|
| 120 | public void openInventory(EntityPlayer player)
|
| 121 | {
|
| 122 | }
|
| 123 |
|
| 124 | public void closeInventory(EntityPlayer player)
|
| 125 | {
|
| 126 | }
|
| 127 |
|
| 128 | /**
|
| 129 | * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
|
| 130 | */
|
| 131 | public boolean isItemValidForSlot(int index, ItemStack stack)
|
| 132 | {
|
| 133 | return true;
|
| 134 | }
|
| 135 |
|
| 136 | public int getField(int id)
|
| 137 | {
|
| 138 | return 0;
|
| 139 | }
|
| 140 |
|
| 141 | public void setField(int id, int value)
|
| 142 | {
|
| 143 | }
|
| 144 |
|
| 145 | public int getFieldCount()
|
| 146 | {
|
| 147 | return 0;
|
| 148 | }
|
| 149 |
|
| 150 | public void clear()
|
| 151 | {
|
| 152 | for (int i = 0; i < this.stackResult.length; ++i)
|
| 153 | {
|
| 154 | this.stackResult[i] = null;
|
| 155 | }
|
| 156 | }
|
| 157 | }
|
| 158 |
|