Interface IGameplayHelper
public interface IGameplayHelper
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault net.minecraft.world.item.ItemStackaddItem(net.minecraft.world.item.ItemStack stack, net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> inventory, int[] slots) Attempts to add an item to a list based inventory.default voiddropRemainders(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack old) Drops the crafting remainder of an item into the world if the item has one.default @Nullable net.minecraft.world.ContainergetContainer(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos) Gets a vanilla container for a given position.default net.minecraft.world.item.ItemStackgetCraftingRemainder(net.minecraft.world.item.ItemStack input) Gets the crafting remainder for a given item.default net.minecraft.world.item.ItemStackinventoryInsert(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side, net.minecraft.world.item.ItemStack stack) If an inventory exists at the specified position, attempt to insert the item into all available slots until the item has been fully inserted or no more slots are available.net.minecraft.world.item.CreativeModeTab.Builder
-
Field Details
-
RNG
static final net.minecraft.util.RandomSource RNG
-
-
Method Details
-
getCraftingRemainder
default net.minecraft.world.item.ItemStack getCraftingRemainder(net.minecraft.world.item.ItemStack input) Gets the crafting remainder for a given item. This is required as some platforms have different logic for determining the crafting remainder.- Parameters:
input- The input item.- Returns:
- The crafting remainder, or empty if none.
-
inventoryInsert
default net.minecraft.world.item.ItemStack inventoryInsert(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side, net.minecraft.world.item.ItemStack stack) If an inventory exists at the specified position, attempt to insert the item into all available slots until the item has been fully inserted or no more slots are available.- Parameters:
level- The world instance.pos- The position of the block.side- The side you are accessing the inventory from. This is from the perspective of the inventory, not your block. For example a hopper on top of a chest is inserting downwards but would use the upwards face because that is the side of the chest being accessed.stack- The item to try inserting.- Returns:
- The remaining items that were not inserted.
-
getContainer
@Nullable default @Nullable net.minecraft.world.Container getContainer(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos) Gets a vanilla container for a given position. This method supports block based containers like the composter, and block entity based containers like a chest or barrel.- Parameters:
level- The world instance.pos- The position to check.- Returns:
- The container that was found, or null if no container exists.
-
addItem
default net.minecraft.world.item.ItemStack addItem(net.minecraft.world.item.ItemStack stack, net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> inventory, int[] slots) Attempts to add an item to a list based inventory. This code will try to insert into all available slots until the item has been completely inserted or no items remain.- Parameters:
stack- The item to add into the inventory.inventory- The list of items to add to.slots- An array of valid slots to add to.- Returns:
- The remaining items that were not inserted.
-
dropRemainders
default void dropRemainders(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack old) Drops the crafting remainder of an item into the world if the item has one.- Parameters:
level- The world to drop the item within.pos- The position to spawn the items at.old- The base item to spawn a remainder from.
-
tabBuilder
net.minecraft.world.item.CreativeModeTab.Builder tabBuilder()
-