Class GlobalVariableHelper

java.lang.Object
me.desht.pneumaticcraft.common.variables.GlobalVariableHelper

public class GlobalVariableHelper extends Object
  • Constructor Details

    • GlobalVariableHelper

      public GlobalVariableHelper()
  • Method Details

    • getPos

      public static net.minecraft.core.BlockPos getPos(@Nullable UUID id, String varName, net.minecraft.core.BlockPos def)
      Retrieve a blockpos variable from the GVM. The variable may start with "#" or "%" to indicate player-global or global respectively. Missing prefix defaults to player-global.
      Parameters:
      id - the ID of the owning player (ignored for "%" global variables)
      varName - the variable name, optionally prefixed with "%" or "#"
      def - default value if not present in the GVM
      Returns:
      the variable's value
    • getPos

      public static net.minecraft.core.BlockPos getPos(@Nullable UUID id, String varName)
      Retrieve a blockpos variable from the GVM. The variable may start with "#" or "%" to indicate player-global or global respectively. Missing prefix defaults to player-global.
      Parameters:
      id - the ID of the owning player (ignored for "%" global variables, must be a valid player UUID otherwise)
      varName - the variable name, optionally prefixed with "%" or "#"
      Returns:
      the variable's value
    • getStack

      public static net.minecraft.world.item.ItemStack getStack(@Nullable UUID id, String varName, net.minecraft.world.item.ItemStack def)
      Retrieve an itemstack variable from the GVM. The variable may start with "#" or "%" to indicate player-global or global respectively. Missing prefix defaults to player-global "#".
      Parameters:
      id - the ID of the owning player (ignored for "%" global variables, must be a valid player UUID otherwise)
      varName - the variable name, optionally prefixed with "%" or "#"
      def - default value if not present in the GVM
      Returns:
      the variable's value
    • getStack

      public static net.minecraft.world.item.ItemStack getStack(@Nullable UUID id, String varName)
      Retrieve an itemstack variable from the GVM. The variable may start with "#" or "%" to indicate player-global or global respectively. Missing prefix defaults to player-global.
      Parameters:
      id - the ID of the owning player (ignored for "%" global variables, must be a valid player UUID otherwise)
      varName - the variable name, optionally prefixed with "%" or "#"
      Returns:
      the variable's value
    • setPos

      public static void setPos(UUID id, String varName, net.minecraft.core.BlockPos pos)
    • setStack

      public static void setStack(UUID id, String varName, net.minecraft.world.item.ItemStack stack)
    • getBool

      public static boolean getBool(UUID id, String varName)
    • getInt

      public static int getInt(UUID id, String varName)
    • getPrefixedVar

      public static String getPrefixedVar(String varName, boolean playerGlobal)
      Given a plain variable name, add the "#" or "%" prefix as appropriate
      Parameters:
      varName - the variable
      playerGlobal - true if a player-global, false if a server-global
      Returns:
      the prefixed var name
    • getVarPrefix

      public static String getVarPrefix(boolean playerGlobal)
      Get the correct var prefix
      Parameters:
      playerGlobal - true if a player-global, false if a server-global
      Returns:
      the var prefix
    • stripVarPrefix

      public static String stripVarPrefix(String varName)
      Strip the prefix character from a var name
      Parameters:
      varName - the var name
      Returns:
      the var name without a prefix
    • hasPrefix

      public static boolean hasPrefix(String varName)
      Check if this varname has a prefix character
      Parameters:
      varName - the var name
      Returns:
      true if prefixed, false otherwise
    • extractVarnames

      public static List<String> extractVarnames(String[] varnames, boolean playerGlobal)
      Given a list of prefixed var names, return a corresponding list of var names with a matching prefix character
      Parameters:
      varnames - the var names
      playerGlobal - true to extract player-global, false for server-global
      Returns:
      a list of unprefixed var names
    • getVariableProvider

      public static IVariableProvider getVariableProvider()