Package net.minecraft.world.inventory
Class Slot
java.lang.Object
net.minecraft.world.inventory.Slot
- Direct Known Subclasses:
ArmorSlot,BeaconMenu.PaymentSlot,BrewingStandMenu.FuelSlot,BrewingStandMenu.IngredientsSlot,BrewingStandMenu.PotionSlot,CrafterSlot,CreativeModeInventoryScreen.CustomCreativeSlot,CreativeModeInventoryScreen.SlotWrapper,FurnaceFuelSlot,FurnaceResultSlot,MerchantResultSlot,NonInteractiveResultSlot,ResultSlot,ShulkerBoxSlot,SlotItemHandler,StackCopySlot
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ResourceLocationfinal Containerintprivate final intfinal intfinal int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanallowModification(Player pPlayer) protected voidcheckTakeAchievements(ItemStack pStack) intgetItem()intintgetMaxStackSize(ItemStack pStack) intRetrieves the index in the inventory for this slot, this value should typically not be used, but can be useful for some occasions.booleanhasItem()booleanisActive()booleanisFake()booleanbooleanisSameInventory(Slot other) Checks if the other slot is in the same inventory, by comparing the inventory reference.booleanReturn whether this slot's stack can be taken from this slot.booleanCheck if the stack is allowed to be placed in this slot, used for armor slots as well as furnace fuel.protected voidonQuickCraft(ItemStack pStack, int pAmount) Typically increases an internal count, then callsonCrafting(item).voidonQuickCraft(ItemStack pOldStack, ItemStack pNewStack) if par2 has more items than par1, onCrafting(item,countIncrease) is calledprotected voidonSwapCraft(int pNumItemsCrafted) voidremove(int pAmount) Decrease the size of the stack in slot (first int arg) by the amount of the second int arg.safeInsert(ItemStack pStack) safeInsert(ItemStack pStack, int pIncrement) voidHelper method to put a stack in the slot.setBackground(ResourceLocation sprite) Sets the background atlas and sprite location.voidsetByPlayer(ItemStack pStack) voidsetByPlayer(ItemStack pNewStack, ItemStack pOldStack) void
-
Field Details
-
slot
private final int slot -
container
-
index
public int index -
x
public final int x -
y
public final int y -
backgroundSprite
-
-
Constructor Details
-
Slot
-
-
Method Details
-
onQuickCraft
if par2 has more items than par1, onCrafting(item,countIncrease) is called -
onQuickCraft
Typically increases an internal count, then callsonCrafting(item).- Parameters:
pStack- the output - ie, iron ingots, and pickaxes, not ore and wood.
-
onSwapCraft
protected void onSwapCraft(int pNumItemsCrafted) -
checkTakeAchievements
- Parameters:
pStack- the output - ie, iron ingots, and pickaxes, not ore and wood.
-
onTake
-
mayPlace
Check if the stack is allowed to be placed in this slot, used for armor slots as well as furnace fuel. -
getItem
-
hasItem
public boolean hasItem() -
setByPlayer
-
setByPlayer
-
set
Helper method to put a stack in the slot. -
setChanged
public void setChanged() -
getMaxStackSize
public int getMaxStackSize() -
getMaxStackSize
-
getNoItemIcon
-
remove
Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new stack. -
mayPickup
Return whether this slot's stack can be taken from this slot. -
isActive
public boolean isActive() -
getSlotIndex
public int getSlotIndex()Retrieves the index in the inventory for this slot, this value should typically not be used, but can be useful for some occasions.- Returns:
- Index in associated inventory for this slot.
-
isSameInventory
Checks if the other slot is in the same inventory, by comparing the inventory reference.- Parameters:
other-- Returns:
- true if the other slot is in the same inventory
-
setBackground
Sets the background atlas and sprite location.- Parameters:
sprite- The sprite located on that atlas.- Returns:
- this, to allow chaining.
-
tryRemove
-
safeTake
-
safeInsert
-
safeInsert
-
allowModification
-
getContainerSlot
public int getContainerSlot() -
isHighlightable
public boolean isHighlightable() -
isFake
public boolean isFake()
-