Class ChannelDataAccessor
- java.lang.Object
-
- com.gtnewhorizon.structurelib.alignment.constructable.ChannelDataAccessor
-
public class ChannelDataAccessor extends java.lang.ObjectProvide 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 intcountChannelData(ItemStack masterStack)Get the number of subchannels present on given trigger item.static intgetChannelData(ItemStack masterStack, java.lang.String channel)Get the subchannel data from given trigger item.static booleanhasSubChannel(ItemStack masterStack)Check if given trigger item contains any subchannelstatic booleanhasSubChannel(ItemStack masterStack, java.lang.String channel)Check if given trigger item contains specified subchannelstatic 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 voidsetChannelData(ItemStack masterStack, java.lang.String channel, int data)Set the subchannel data on given trigger itemstatic voidunsetChannelData(ItemStack masterStack, java.lang.String channel)Clear the given subchannel from given trigger item, if it existsstatic voidwipeChannelData(ItemStack masterStack)Wipe all subchannel data on given trigger itemstatic ItemStackwithChannel(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.
-
-
-
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
- Parameters:
masterStack- trigger item. can be the return value of anotherwithChannel(ItemStack, String)callchannel- 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 checkchannel- 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 fromchannel- 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 checkchannel- 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 unsetchannel- 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
ConcurrentModificationExceptionif 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
-
-