Class ChannelDataAccessor


  • public class ChannelDataAccessor
    extends java.lang.Object
    Provide accessor methods for channel data from trigger item. Channels section on overview
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int countChannelData​(ItemStack masterStack)
      Get the number of subchannels present on given trigger item.
      static int getChannelData​(ItemStack masterStack, java.lang.String channel)
      Get the subchannel data from given trigger item.
      static boolean hasSubChannel​(ItemStack masterStack)
      Check if given trigger item contains any subchannel
      static boolean hasSubChannel​(ItemStack masterStack, java.lang.String channel)
      Check if given trigger item contains specified subchannel
      static java.util.stream.Stream<java.util.Map.Entry<java.lang.String,​java.lang.Integer>> iterateChannelData​(ItemStack masterStack)
      Iterate over all subchannel data on trigger stack.
      static void setChannelData​(ItemStack masterStack, java.lang.String channel, int data)
      Set the subchannel data on given trigger item
      static void unsetChannelData​(ItemStack masterStack, java.lang.String channel)
      Clear the given subchannel from given trigger item, if it exists
      static void wipeChannelData​(ItemStack masterStack)
      Wipe all subchannel data on given trigger item
      static ItemStack withChannel​(ItemStack masterStack, java.lang.String channel)
      Return a trigger item that Still carry all the subchannel in some unspecified ways Have its master channel data replaced with specified subchannel's data If given subchannel does not exist, masterStack may or may not be returned to save performance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • withChannel

        public static ItemStack withChannel​(ItemStack masterStack,
                                            java.lang.String channel)
        Return a trigger item that
        • Still carry all the subchannel in some unspecified ways
        • Have its master channel data replaced with specified subchannel's data
        If given subchannel does not exist, masterStack may or may not be returned to save performance. Code within StructureLib can depend on this behavior, you cannot.
        Parameters:
        masterStack - trigger item. can be the return value of another withChannel(ItemStack, String) call
        channel - subchannel to use. will use current master channel data instead if this channel does not exist Note: all channel identifiers are supposed to be lower case and not empty.
        Returns:
        a trigger item with new master channel
      • hasSubChannel

        public static boolean hasSubChannel​(ItemStack masterStack)
        Check if given trigger item contains any subchannel
        Parameters:
        masterStack - trigger stack to check
        Returns:
        true if contains any subchannel
      • hasSubChannel

        public static boolean hasSubChannel​(ItemStack masterStack,
                                            java.lang.String channel)
        Check if given trigger item contains specified subchannel
        Parameters:
        masterStack - trigger stack to check
        channel - channel identifier. Note: all channel identifiers are supposed to be lower case and not empty.
        Returns:
        true if contains specified subchannel
      • getChannelData

        public static int getChannelData​(ItemStack masterStack,
                                         java.lang.String channel)
        Get the subchannel data from given trigger item. Will use master channel instead if not present.
        Parameters:
        masterStack - trigger stack to query from
        channel - channel identifier. Note: all channel identifiers are supposed to be lower case and not empty.
        Returns:
        channel data
      • setChannelData

        public static void setChannelData​(ItemStack masterStack,
                                          java.lang.String channel,
                                          int data)
        Set the subchannel data on given trigger item
        Parameters:
        masterStack - trigger stack to check
        channel - channel identifier. Note: all channel identifiers are supposed to be lower case and not empty.
        data - subchannel data. should always be a positive value
      • unsetChannelData

        public static void unsetChannelData​(ItemStack masterStack,
                                            java.lang.String channel)
        Clear the given subchannel from given trigger item, if it exists
        Parameters:
        masterStack - trigger stack to unset
        channel - channel identifier. Note: all channel identifiers are supposed to be lower case and not empty.
      • wipeChannelData

        public static void wipeChannelData​(ItemStack masterStack)
        Wipe all subchannel data on given trigger item
        Parameters:
        masterStack - trigger stack to wipe
      • iterateChannelData

        public static java.util.stream.Stream<java.util.Map.Entry<java.lang.String,​java.lang.Integer>> iterateChannelData​(ItemStack masterStack)
        Iterate over all subchannel data on trigger stack. Does not include master channel!!
        Parameters:
        masterStack - trigger stack to check
        Returns:
        A java8 stream of pairs. Key is channel identifier and value is channel data. Pairs do not support mutation nor removal. Can still cause ConcurrentModificationException if underlying channel data is modified while stream is working.
      • countChannelData

        public static int countChannelData​(ItemStack masterStack)
        Get the number of subchannels present on given trigger item. Does not include master channel.
        Parameters:
        masterStack - trigger stack to query from
        Returns:
        subchannel count