Interface IGameplayHelper

All Known Implementing Classes:
NeoForgeGameplayHelper

public interface IGameplayHelper
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.minecraft.util.RandomSource
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    <M extends net.minecraft.world.inventory.AbstractContainerMenu, U extends net.minecraft.client.gui.screens.Screen & net.minecraft.client.gui.screens.inventory.MenuAccess<M>>
    void
    bindMenu(net.minecraft.world.inventory.MenuType<? extends M> type, RegisterMenuScreen.ScreenFactory<M,U> factory)
    Binds a screen to a menu using platform specific code.
    <T extends net.minecraft.world.level.block.entity.BlockEntity>
    net.minecraft.world.level.block.entity.BlockEntityType.Builder<T>
    blockEntityBuilder(BiFunction<net.minecraft.core.BlockPos,net.minecraft.world.level.block.state.BlockState,T> factory, net.minecraft.world.level.block.Block... validBlocks)
    Creates a new block entity builder using platform specific code.
    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.
    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.
    default net.minecraft.world.item.ItemStack
    getCraftingRemainder(net.minecraft.world.item.ItemStack input)
    Gets the crafting remainder for a given item.
    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.
    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.
    • blockEntityBuilder

      <T extends net.minecraft.world.level.block.entity.BlockEntity> net.minecraft.world.level.block.entity.BlockEntityType.Builder<T> blockEntityBuilder(BiFunction<net.minecraft.core.BlockPos,net.minecraft.world.level.block.state.BlockState,T> factory, net.minecraft.world.level.block.Block... validBlocks)
      Creates a new block entity builder using platform specific code. This is required because the underlying block entity factory is not accessible.
      Type Parameters:
      T - The type of the block entity.
      Parameters:
      factory - A factory that creates a new block entity instance.
      validBlocks - The array of valid blocks for the block entity.
      Returns:
      A new builder for your block entity type.
    • bindMenu

      <M extends net.minecraft.world.inventory.AbstractContainerMenu, U extends net.minecraft.client.gui.screens.Screen & net.minecraft.client.gui.screens.inventory.MenuAccess<M>> void bindMenu(net.minecraft.world.inventory.MenuType<? extends M> type, RegisterMenuScreen.ScreenFactory<M,U> factory)
      Binds a screen to a menu using platform specific code. This is required because the underlying screen factory is not accessible.
      Type Parameters:
      M - The type of the menu.
      U - The type of the screen.
      Parameters:
      type - The menu type to bind the screen to.
      factory - A factory that constructs the screen instance.
    • 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()