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 Containerintprivate final intfinal intfinal int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanallowModification(Player player) protected voidcheckTakeAchievements(ItemStack stack) intgetItem()intintgetMaxStackSize(ItemStack stack) com.mojang.datafixers.util.Pair<ResourceLocation, ResourceLocation> 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 stack, int amount) Typically increases an internal count, then callsonCrafting(item).voidonQuickCraft(ItemStack oldStack, ItemStack newStack) if par2 has more items than par1, onCrafting(item,countIncrease) is calledprotected voidonSwapCraft(int numItemsCrafted) voidremove(int amount) Decrease the size of the stack in slot (first int arg) by the amount of the second int arg.safeInsert(ItemStack stack) safeInsert(ItemStack stack, int increment) voidHelper method to put a stack in the slot.setBackground(ResourceLocation atlas, ResourceLocation sprite) Sets the background atlas and sprite location.voidsetByPlayer(ItemStack stack) voidsetByPlayer(ItemStack newStack, ItemStack oldStack) 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:
stack- the output - ie, iron ingots, and pickaxes, not ore and wood.
-
onSwapCraft
protected void onSwapCraft(int numItemsCrafted) -
checkTakeAchievements
- Parameters:
stack- 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()
-