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 com.mojang.datafixers.util.Pair
<ResourceLocation, ResourceLocation> final Container
int
private final int
final int
final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
allowModification
(Player pPlayer) protected void
checkTakeAchievements
(ItemStack pStack) int
getItem()
int
int
getMaxStackSize
(ItemStack pStack) com.mojang.datafixers.util.Pair
<ResourceLocation, ResourceLocation> int
Retrieves the index in the inventory for this slot, this value should typically not be used, but can be useful for some occasions.boolean
hasItem()
boolean
isActive()
boolean
isFake()
boolean
boolean
isSameInventory
(Slot other) Checks if the other slot is in the same inventory, by comparing the inventory reference.boolean
Return whether this slot's stack can be taken from this slot.boolean
Check if the stack is allowed to be placed in this slot, used for armor slots as well as furnace fuel.protected void
onQuickCraft
(ItemStack pStack, int pAmount) Typically increases an internal count, then callsonCrafting(item)
.void
onQuickCraft
(ItemStack pOldStack, ItemStack pNewStack) if par2 has more items than par1, onCrafting(item,countIncrease) is calledprotected void
onSwapCraft
(int pNumItemsCrafted) void
remove
(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) void
Helper method to put a stack in the slot.setBackground
(ResourceLocation atlas, ResourceLocation sprite) Sets the background atlas and sprite location.void
setByPlayer
(ItemStack pStack) void
setByPlayer
(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 -
backgroundPair
-
-
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:
atlas
- The atlas namesprite
- 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()
-