Interface CompatHelper

All Known Implementing Classes:
ForgeCompatHelper

public interface CompatHelper
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
    static final String
     
    static final String
     
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    allModsLoaded(String... namespaces)
     
    default boolean
    anyModsLoaded(String... namespaces)
     
    List<net.minecraft.world.item.ItemStack>
    backSlotDisabled(net.minecraft.world.entity.player.Player owner)
     
    static net.minecraft.world.entity.Entity
    createBackpackEntity(net.minecraft.world.item.ItemStack backpackStack, int x, double y, int z, float yaw, boolean onDeath, net.minecraft.core.Direction direction, net.minecraft.world.level.Level level, UUID uuid, net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> stacks)
    This method places a new backpack dependent on the ItemStack.
    default net.minecraft.world.item.ItemStack
    createEnderBackpack(Optional<UUID> uuid, boolean persistent)
    Creates a bound Ender Backpack to the provided UUID, if empty it will default to the first player who interacts with it
    static BackData
    getBackData(net.minecraft.world.entity.player.Player player)
    This hold all the data for the player.
    static net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack>
    getBackpackInventory(net.minecraft.world.entity.player.Player player)
    Grabs the literal non-copy back inventory whether they have a backpack equipped or not.
    net.minecraft.world.item.ItemStack
    getBackSlotItem(BackData backData, net.minecraft.world.item.ItemStack defaultItem)
     
    static net.minecraft.world.item.ItemStack
    getBackStack(net.minecraft.world.entity.player.Player player)
    Collects the ItemStack worn by either the BackSlot, Trinkets, or Curios.
    getFluidTexture(net.minecraft.world.level.material.Fluid fluid, net.minecraft.client.renderer.texture.TextureAtlas blocksAtlas)
     
    default boolean
     
    boolean
     
    boolean
    isBackSlot(net.minecraft.world.inventory.Slot slot)
     
    boolean
    isModLoaded(String namespace)
     
    void
    setBackSlotItem(BackData data, net.minecraft.world.item.ItemStack stack)
     
    static void
    setBackStack(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack backStack)
    Sets the BackData stack and updates any other variables or compatibilities.
    static void
    updateBackpackInventory2C(net.minecraft.server.level.ServerPlayer player)
    Syncs the ServerPlayer's back inventory to that player's client.
    default void
    updateEnderEntry(@NotNull UUID uuid, String name, boolean translatable, String trim)
    Updates an Ender Entry.
    default void
    updateEnderEntry(@NotNull UUID uuid, Optional<net.minecraft.network.chat.Component> name, Optional<net.minecraft.nbt.CompoundTag> trim)
    Updates an Ender Entry.
  • Field Details

  • Method Details

    • isModLoaded

      boolean isModLoaded(String namespace)
    • anyModsLoaded

      default boolean anyModsLoaded(String... namespaces)
    • allModsLoaded

      default boolean allModsLoaded(String... namespaces)
    • backSlotDisabled

      List<net.minecraft.world.item.ItemStack> backSlotDisabled(net.minecraft.world.entity.player.Player owner)
    • isBackSlot

      boolean isBackSlot(net.minecraft.world.inventory.Slot slot)
    • getFluidTexture

      CauldronInventory.FluidAttributes getFluidTexture(net.minecraft.world.level.material.Fluid fluid, net.minecraft.client.renderer.texture.TextureAtlas blocksAtlas)
    • graveModLoaded

      default boolean graveModLoaded()
    • setBackSlotItem

      void setBackSlotItem(BackData data, net.minecraft.world.item.ItemStack stack)
    • getBackSlotItem

      net.minecraft.world.item.ItemStack getBackSlotItem(BackData backData, net.minecraft.world.item.ItemStack defaultItem)
    • invokeListenersOnDeath

      boolean invokeListenersOnDeath(BackData backData)
    • updateEnderEntry

      default void updateEnderEntry(@NotNull @NotNull UUID uuid, Optional<net.minecraft.network.chat.Component> name, Optional<net.minecraft.nbt.CompoundTag> trim)
      Updates an Ender Entry. If fields "name" or "trim" is Optional.empty(), it will not update those fields.
      Parameters:
      uuid - Entry to look up the specific ender entry.
      name - The displayed name of a bound ender backpack.
      trim - Taken directly from a trimmed ItemStack. The tag must contain a "pattern" and "material" string tag. If you are able to view a trimmed ItemStack, the tag is the contents of "Trim" and not "Trim" itself.
    • updateEnderEntry

      default void updateEnderEntry(@NotNull @NotNull UUID uuid, @Nullable String name, boolean translatable, @Nullable String trim)
      Updates an Ender Entry. If fields "name" or "trim" is null, it will not update those fields.
      Parameters:
      uuid - Entry to look up the specific ender entry.
      name - Written as a snbt string. ( §9Like This! )
      translatable - If true, the name field will be treated as a translation.
      trim - Written as a snbt tag. ( {pattern:"", material:""} )
    • createEnderBackpack

      default net.minecraft.world.item.ItemStack createEnderBackpack(Optional<UUID> uuid, boolean persistent)
      Creates a bound Ender Backpack to the provided UUID, if empty it will default to the first player who interacts with it
      Parameters:
      uuid - Owner of the backpack inventory.
      persistent - If true, the owner tag cannot be overridden unless empty.
    • createBackpackEntity

      @Nullable static net.minecraft.world.entity.Entity createBackpackEntity(net.minecraft.world.item.ItemStack backpackStack, int x, double y, int z, float yaw, boolean onDeath, net.minecraft.core.Direction direction, net.minecraft.world.level.Level level, UUID uuid, net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> stacks)
      This method places a new backpack dependent on the ItemStack. If a backpack cannot be created from the ItemStack null will be returned
      Parameters:
      onDeath - Determines whether to unbind an Ender Backpack if config allows
      direction - Direction.UP and Direction.DOWN implies the backpack is centered in the block, otherwise it will be hung and yaw will be ignored
      uuid - uuid of the player it is placed by or in the case of Ender Backpacks, the owner of the inventory
      stacks - ItemStacks of the backpack. Can be null or empty. Will be ignored if Ender Backpack
      Returns:
      The Backpack entity , else null if ItemStack cant turn into entity. Cast to EntityAbstract at the risk of refactoring breaking compat.
    • getBackpackInventory

      static net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> getBackpackInventory(net.minecraft.world.entity.player.Player player)
      Grabs the literal non-copy back inventory whether they have a backpack equipped or not.

      Be aware the tooltip graphic might need you to update the player's client after making changes. Use `updateBackpackInventory2C` below to sync the inventory.

    • updateBackpackInventory2C

      static void updateBackpackInventory2C(net.minecraft.server.level.ServerPlayer player)
      Syncs the ServerPlayer's back inventory to that player's client.
    • getBackStack

      static net.minecraft.world.item.ItemStack getBackStack(net.minecraft.world.entity.player.Player player)
      Collects the ItemStack worn by either the BackSlot, Trinkets, or Curios.

      Will cause Curios/Trinkets instabilities if this stack is overridden. Always use `setBackStack()` below especially if making changes other than NBT or count.

    • setBackStack

      static void setBackStack(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack backStack)
      Sets the BackData stack and updates any other variables or compatibilities. ItemStack.EMPTY
      Parameters:
      backStack - Passing ItemStack.EMPTY does not clear the back inventory but works otherwise.
    • getBackData

      static BackData getBackData(net.minecraft.world.entity.player.Player player)
      This hold all the data for the player. Powerful but refactors may break any compat with this method. Use if no other alternatives.