Interface IPositionProvider

All Known Implementing Classes:
AmadronTabletItem, GPSAreaToolItem, GPSToolItem

public interface IPositionProvider
Represents an item which can store & provide one or more block positions. An example would be the GPS Tool (one position), the GPS Area Tool (possibly many positions) or the Amadron Tablet (two positions).
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Whether or not the rendered positions should be visible through the world.
    default List<net.minecraft.core.BlockPos>
    getRawStoredPositions(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack)
    Gets the raw stored positions in this provider.
    default int
    getRenderColor(int index)
    Color that should be used to highlight the stored block positions if & when they are rendered on-screen.
    List<net.minecraft.core.BlockPos>
    getStoredPositions(UUID playerId, net.minecraft.world.item.ItemStack stack)
    Get block position data from the given ItemStack.
    default void
    syncVariables(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.item.ItemStack stack)
    If the item stores any global variables which the client needs to know about (e.g.
  • Method Details

    • getStoredPositions

      @Nonnull List<net.minecraft.core.BlockPos> getStoredPositions(UUID playerId, @Nonnull net.minecraft.world.item.ItemStack stack)
      Get block position data from the given ItemStack. It is up to the implementor to decide how the block positions should be stored on the itemstack and in what order they should be returned.
      Parameters:
      playerId - the player, for player-global variable context (may be null)
      stack - the itemstack
      Returns:
      a list of block positions that has been retrieved from the itemstack
    • getRenderColor

      default int getRenderColor(int index)
      Color that should be used to highlight the stored block positions if & when they are rendered on-screen.
      Parameters:
      index - the index in the list returned by getStoredPositions()
      Returns:
      a color in ARGB format, or 0 to skip rendering completely
    • disableDepthTest

      default boolean disableDepthTest()
      Whether or not the rendered positions should be visible through the world.
      Returns:
      true if visible through the world, false if not.
    • getRawStoredPositions

      default List<net.minecraft.core.BlockPos> getRawStoredPositions(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack)
      Gets the raw stored positions in this provider. E.g. for the GPS Area Tool, just the two clicked positions, not the whole set of positions defined by the tool's area type.
      Parameters:
      player - the player, for player-global variable context
      stack - the itemstack
      Returns:
      the raw positions stored on the itemstack
    • syncVariables

      default void syncVariables(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.item.ItemStack stack)
      If the item stores any global variables which the client needs to know about (e.g. for area rendering), override this method to sync their values to the client. This method is called server-side when an item in any player's inventory (which implements IPositionProvider) changes in any way.

      See PneumaticRegistry.IPneumaticCraftInterface.syncGlobalVariable(ServerPlayer, String)} for a convenience method to send the necessary sync packet.

      Parameters:
      player - the player to sync to
      stack - the itemstack