Class StructureUtility

    • Method Detail

      • isAir

        public static <T> IStructureElement<T> isAir()
        Return a structure element that only allow air (or air equivalents, like Railcraft hidden blocks). You usually don't need to call this yourselves. Use - in shape to automatically use this. Provided nontheless in case you want this as a fallback to something else.
      • notAir

        public static <T> IStructureElement<T> notAir()
        Return a structure element that allow anything but air (or air equivalents, like Railcraft hidden blocks). You usually don't need to call this yourselves. Use + in shape to automatically use this. Provided nontheless in case you want this as a fallback to something else.
      • error

        public static <T> IStructureElement<T> error()
        Check returns false. Placement is always handled by this and does nothing. Makes little to no use it in fallback chain.
      • ofBlocksTiered

        public static <T,​TIER> IStructureElement<T> ofBlocksTiered​(ITierConverter<TIER> tierExtractor,
                                                                         @Nullable
                                                                         java.util.List<org.apache.commons.lang3.tuple.Pair<Block,​java.lang.Integer>> allKnownTiers,
                                                                         @Nullable
                                                                         TIER notSet,
                                                                         java.util.function.BiConsumer<T,​TIER> setter,
                                                                         java.util.function.Function<T,​TIER> getter)
        Element representing a component with different tiers. Your multi will accept any of them (as long as player does not mix them (*)), but would like to know which is used. Player can use more blueprint to get hints denoting more advanced components.

        (*): Implementation wise, this structure element will only accept a block if its tier is the same as existing tier or if existing tier is unset (i.e. value of third argument)

        Above all else, you need to decide what tier you are going to use. For simpler cases, Integer is a good choice. You can also use an existing Enum. Tier can never be null though. It can also be a String or a ResourceLocation, or basically anything. It doesn't even have to implement Comparable.

        This assumes you will reset the backing storage, and on the first occurrence getter would return notSet. You can also make getter to return other value to forcefully select a certain tier, but you're probably better off using block adders or ofBlock(Block, int, Block, int) and its overloads

        Implementation wise, this allows a block only when we don't yet have a tier, or the block at that location has the same tier as we already have.

        There is yet no TileEntity counterpart of this utility. Feel free to submit a PR to add it.

        For most typical use cases, you will NOT want to return notSet from your tierExtractor. If you do so, we will have this kind of chain of events:

        • at check start, tier is reset to notSet
        • at first occurrence, ofBlocksTiered finds your current tier is notSet, and the block's tier is notSet, so it's accepted
        • at 2nd, 3rd..., same thing in 2 happens
        • at last occurrence, player placed a valid block with a tier not notSet. ofBlocksTiered now sets your current tier to this tier, and accept the block
        • check got notified structure is sound, and tier is not notSet. it marks the structure as complete and start doing its business
        • Player enjoy a (probably) hilariously shaped multi and (probably) reduced build cost.

        Example:

        Assume you have 16 tier, each map to one block's 16 different meta. You will usually want something like this

         public class Tile extends TileEntity {
             private static final Block B = getTargetBlock();
             private static final IStructureDefinition<Tile> S = IStructureDefinition.<Tile>builder()
                    // ... addShape, and other elements
                    .addElement('c', ofBlocksTiered((b, m) -> b == B ? m : null,
                                                    IntStream.range(0, 16).mapToObj(i -> Pair.of(B, i)).collect(Collectors.toList()),
                                                    -1,
                                                    (t, m) -> t.tier = m,
                                                    t -> t.tier))
                    .build();
             private int tier;
        
             public boolean check() {
                 tier = -1;
                 if (!S.check(...))
                     return false;
                 return isTierAcceptable(tier);
             }
         }
         
        Parameters:
        tierExtractor - a function to extract tier info from a block. This function can return null and will never be passed a null block or an invalid block meta.
        allKnownTiers - A list of all known tiers as of calling. Can be empty or null. No hint will be spawned if empty or null. Cannot have null elements. First element denotes the most primitive tier. Last element denotes the most advanced tier. If not all tiers are available at definition construction time, use lazy(Supplier) or its overloads to delay a bit. This list is only for hint particle spawning and survival build. The hint/autoplace code will choose 1st pair to spawn/place if trigger item has master channel data of 1, 2nd pair if 2, and so on.
        notSet - The value returned from getter when there were no tier info found in T yet. Can be null.
        getter - a function to retrieve the current tier from context object
        setter - a function to set the current tier into context object
      • ofBlockUnlocalizedName

        public static <T> IStructureElement<T> ofBlockUnlocalizedName​(java.lang.String modid,
                                                                      java.lang.String unlocalizedName,
                                                                      int meta)
        Denote a block using unlocalized names. This can be useful to get around mod loading order issues.

        DUE TO HISTORICAL REASONS, THIS WAS CALLED ofBlockUnlocalizedName, BUT IT ACTUALLY USES REGISTRY NAME INSTEAD.

        While no immediate error will be thrown, client code should ensure said mod is loaded and said mod is present, otherwise bad things will happen later!

      • ofBlockUnlocalizedName

        public static <T> IStructureElement<T> ofBlockUnlocalizedName​(java.lang.String modid,
                                                                      java.lang.String registryName,
                                                                      int meta,
                                                                      boolean wildcard)
        Denote a block using unlocalized names. This can be useful to get around mod loading order issues.

        DUE TO HISTORICAL REASONS, THIS WAS CALLED ofBlockUnlocalizedName, BUT IT ACTUALLY USES REGISTRY NAME INSTEAD.

        While no immediate error will be thrown, client code should ensure said mod is loaded and said mod is present, otherwise the element will effectively become an error().

        Will place block or hint using the given meta if wildcard is true.

      • ofBlockUnlocalizedName

        public static <T> IStructureElement<T> ofBlockUnlocalizedName​(java.lang.String modid,
                                                                      java.lang.String unlocalizedName,
                                                                      int meta,
                                                                      IStructureElement<T> fallback)
        Similiar to the other overload, but allows client code to specify a fallback in case said block was not found later when the element got called.

        DUE TO HISTORICAL REASONS, THIS WAS CALLED ofBlockUnlocalizedName, BUT IT ACTUALLY USES REGISTRY NAME INSTEAD.

        This is slightly different to using the other overload and another element in a ofChain(IStructureElement[]). Here fallback will only ever be used if this fails, where ofChain would form an OR relationship even if the mod is loaded and the block exists in registry.

      • ofBlocksMapHint

        public static <T> IStructureElementNoPlacement<T> ofBlocksMapHint​(java.util.Map<Block,​java.util.Collection<java.lang.Integer>> blocsMap,
                                                                          Block hintBlock,
                                                                          int hintMeta)
        Accept a set of blocks.

        Does not have autoplace.

        Parameters:
        blocsMap - Accepted (block, meta) pairs.
        hintBlock - hint block to use
        hintMeta - hint meta to use
        See Also:
        ofBlocksFlatHint(Map, Block, int)
      • ofBlockHint

        public static <T> IStructureElementNoPlacement<T> ofBlockHint​(Block block,
                                                                      int meta,
                                                                      Block hintBlock,
                                                                      int hintMeta)
        Accept one (block, meta). Spawn hint particles using an alternative block and meta. Not very useful...
      • ofBlockAdderHint

        public static <T> IStructureElementNoPlacement<T> ofBlockAdderHint​(IBlockAdder<T> iBlockAdder,
                                                                           Block hintBlock,
                                                                           int hintMeta)
        Add a block using block adder. Spawn hints using given hint block and meta.

        Useful when your logic is very complex. Does not support autoplace.

      • ofBlocksFlat

        public static <T> IStructureElement<T> ofBlocksFlat​(java.util.Map<Block,​java.lang.Integer> blocsMap,
                                                            Block defaultBlock,
                                                            int defaultMeta)
        Accept a set of blocks. Less cumbersome to use than ofBlocksMap(Map, Block, int) when for any accepted block type we accept only one meta for each.
        Parameters:
        blocsMap - Accepted (block, meta) pairs.
        defaultBlock - default block to place/spawn hint
        defaultMeta - default meta to place/spawn hint
        See Also:
        ofBlocksMapHint(Map, Block, int)
      • ofBlocksMap

        public static <T> IStructureElement<T> ofBlocksMap​(java.util.Map<Block,​java.util.Collection<java.lang.Integer>> blocsMap,
                                                           Block defaultBlock,
                                                           int defaultMeta)
        Accept a set of blocks.
        Parameters:
        blocsMap - Accepted (block, meta) pairs.
        defaultBlock - default block to place/spawn hint
        defaultMeta - default meta to place/spawn hint
        See Also:
        ofBlocksMapHint(Map, Block, int)
      • ofBlock

        public static <T> IStructureElement<T> ofBlock​(Block block,
                                                       int meta,
                                                       Block defaultBlock,
                                                       int defaultMeta)
        Accept a block. Spawn hint/autoplace using another.
        Parameters:
        block - accepted block
        meta - accepted meta
        defaultBlock - hint block
        defaultMeta - hint meta
      • ofBlock

        public static <T> IStructureElement<T> ofBlock​(Block block,
                                                       int meta)
        Accept a single block with a fixed meta. Most primitive form of structure.
      • ofBlockAnyMeta

        public static <T> IStructureElement<T> ofBlockAnyMeta​(Block block)
        Accept a single block, but accept any meta.
      • ofBlockAnyMeta

        public static <T> IStructureElement<T> ofBlockAnyMeta​(Block block,
                                                              int defaultMeta)
        Accept a single block, but accept any meta. Spawn hint/autoplace using given meta.
      • ofBlockAdder

        public static <T> IStructureElement<T> ofBlockAdder​(IBlockAdder<T> iBlockAdder,
                                                            Block defaultBlock,
                                                            int defaultMeta)
        Add a block using block adder. Spawn hints/autoplace using given hint block and meta.

        Useful when your logic is very complex.

      • ofTileAdder

        public static <T> IStructureElementNoPlacement<T> ofTileAdder​(ITileAdder<T> iTileAdder,
                                                                      Block hintBlock,
                                                                      int hintMeta)
        Try to add a structure element with a tile entity. Note that tile adder will be called with a null argument at locations without tile entity.
      • ofSpecificTileAdder

        public static <T,​E> IStructureElementNoPlacement<T> ofSpecificTileAdder​(java.util.function.BiPredicate<T,​E> iTileAdder,
                                                                                      java.lang.Class<E> tileClass,
                                                                                      Block hintBlock,
                                                                                      int hintMeta)
        Try to add a structure element with a particular type of tile entity. Note that tile adder will not be called at locations without a tile entity.
      • onElementPass

        public static <B extends IStructureElement<T>,​T> IStructureElement<T> onElementPass​(java.util.function.Consumer<T> onCheckPass,
                                                                                                  B element)
        Call a callback if downstream element returned true in check.
        Parameters:
        onCheckPass - side effect
        element - downstream
      • onElementFail

        public static <B extends IStructureElement<T>,​T> IStructureElement<T> onElementFail​(java.util.function.Consumer<T> onFail,
                                                                                                  B element)
        Call a callback if downstream element returned false in check.
        Parameters:
        onFail - side effect
        element - downstream
      • onlyIf

        public static <T> IStructureElement<T> onlyIf​(java.util.function.Predicate<? super T> predicate,
                                                      IStructureElement<? super T> downstream)
        Enable this structure element only if given predicate returns true.

        Return SKIP when survival auto place if given predicate returns false.

      • onlyIf

        public static <T> IStructureElement<T> onlyIf​(java.util.function.Predicate<? super T> predicate,
                                                      IStructureElement<? super T> downstream,
                                                      IStructureElement.PlaceResult placeResultWhenDisabled)
        Enable this structure element only if given predicate returns true.
        Parameters:
        placeResultWhenDisabled - value to return for survival auto place when predicate returns false
      • ofChain

        @SafeVarargs
        public static <T> IStructureElementChain<T> ofChain​(IStructureElement<T>... elementChain)
        This allows you to compose different IStructureElement to form a OR chain. As with any other OR operator, this one exhibits short-circuiting behavior, i.e. it will not call next structure element if previous one succeeded. (*)

        This allows you e.g. accept both a glass block using ofBlock(Block, int, Block, int) and a piece of air using isAir(). It will not attempt to capture any errors though, so next one will not be tried if previous one would crash.

        (*): For survival auto place, it will * REJECT, if all structure element REJECT * SKIP, if 1 or more structure element SKIP and the rest structure element (0 or more) REJECT * any other result, **immediately** upon any structure element returns these other results. This behavior is not 100% fixed and might change later on, but we will send the notice on a best effort basis.

        Take care while chaining, as it will try to call every structure element until it returns true. If none does it will finally return false.

      • withContext

        public static <CTX,​T extends IWithExtendedContext<CTX>> IStructureElement<T> withContext​(IStructureElement<CTX> elem)
        Switch to the extended context object in the downstream element
        Type Parameters:
        CTX - extended context type
        T - existing context object type
        Parameters:
        elem - downstream element
      • lazy

        public static <T> IStructureElementDeferred<T> lazy​(java.util.function.Supplier<IStructureElement<T>> to)
        Similar to defer, but caches the first returned element returned and won't call it again. Initialization is not thread safe. These both allow the structure element **constructor** to access properties only present on the context object (e.g. GT5 multiblock controller), e.g. hatch texture index to use. Use `lazy` if the data you access will remain constant across different context object.
      • lazy

        public static <T> IStructureElementDeferred<T> lazy​(java.util.function.Function<T,​IStructureElement<T>> to)
        This will defer the actual instantiation of structure element until the first time structure code is actually called.

        Similar to defer, but caches the first returned element returned and won't call it again. Initialization is not thread safe. This will allow the structure element constructor to access properties only present on the context object (e.g. GT5 multiblock controller), e.g. hatch texture index to use. Use this if the data you access will remain constant.

        Parameters:
        to - create structure element from the first context object passed in
      • defer

        public static <T> IStructureElementDeferred<T> defer​(java.util.function.Supplier<IStructureElement<T>> to)
        This will defer the actual instantiation of structure element until the structure code is actually called. This will allow the structure element constructor to access properties only present on the context object (e.g. GT5 multiblock controller), e.g. hatch texture index to use. Use this if it might change for the same structure definition, e.g. if your structure might switch mode and change some parameter, while basically remain the same shape. Using this while lazy(Supplier) is enough will not break anything, but would incur unnecessary performance overhead.
        Parameters:
        to - downstream element supplier
      • defer

        public static <T> IStructureElementDeferred<T> defer​(java.util.function.Function<T,​IStructureElement<T>> to)
        This will defer the actual instantiation of structure element until the structure code is actually called. This will allow the structure element constructor to access properties only present on the context object (e.g. GT5 multiblock controller), e.g. hatch texture index to use. Use this if it might change for the same structure definition, e.g. if your structure might switch mode and change some parameter, while basically remain the same shape. Using this while lazy(Supplier) is enough will not break anything, but would incur unnecessary performance overhead.
        Parameters:
        to - downstream element supplier
      • defer

        @Deprecated
        public static <T,​K> IStructureElementDeferred<T> defer​(java.util.function.Function<T,​K> keyExtractor,
                                                                     java.util.Map<K,​IStructureElement<T>> map)
        Deprecated.
        renamed to partitionBy
        This is the switch block for structure code.

        This allows you to extract or compute a key from context object, and lookup a map for actual structure element to use.

        Parameters:
        keyExtractor - extract a key from the context object
        map - all possible structure element
      • partitionBy

        public static <T,​K> IStructureElementDeferred<T> partitionBy​(java.util.function.Function<T,​K> keyExtractor,
                                                                           java.util.Map<K,​IStructureElement<T>> map)
        This is the switch block for structure code.

        This allows you to extract or compute a key from context object, and lookup a map for actual structure element to use. This will usually, but not guaranteed, to throw an exception at runtime if keyExtractor returns a key not found in map.

        Do pay attention to what properties your map has though. You need to pay attention to how they consider equality and how they consider null key/values. Guava ImmutableMap is usually a good enough choice.

        Parameters:
        keyExtractor - extract a key from the context object
        map - all possible structure element
      • defer

        @Deprecated
        public static <T,​K> IStructureElementDeferred<T> defer​(java.util.function.Function<T,​K> keyExtractor,
                                                                     java.util.Map<K,​IStructureElement<T>> map,
                                                                     IStructureElement<T> defaultElem)
        Deprecated.
        renamed to partitionBy
        This is the switch block for structure code, with default case support.

        This allows you to extract or compute a key from context object, and lookup a map for actual structure element to use. The fallback will only be used when keyExtractor returns a value not found in given map. This will play nicely in combination with error()

        Do pay attention to what properties your map has though. You need to pay attention to how they consider equality and how they consider null key/values. Guava ImmutableMap is usually a good enough choice.

        Parameters:
        keyExtractor - extract a key from the context object
        map - all possible structure element
        defaultElem - element to use when keyExtractor returns a value not found in given map
      • partitionBy

        public static <T,​K> IStructureElementDeferred<T> partitionBy​(java.util.function.Function<T,​K> keyExtractor,
                                                                           java.util.Map<K,​IStructureElement<T>> map,
                                                                           IStructureElement<T> defaultElem)
        This is the switch block for structure code, with default case support.

        This allows you to extract or compute a key from context object, and lookup a map for actual structure element to use. The fallback will only be used when keyExtractor returns a value not found in given map. This will play nicely in combination with error()

        Do pay attention to what properties your map has though. You need to pay attention to how they consider equality and how they consider null key/values. Guava ImmutableMap is usually a good enough choice.

        Parameters:
        keyExtractor - extract a key from the context object
        map - all possible structure element
        defaultElem - element to use when keyExtractor returns a value not found in given map
      • defer

        @SafeVarargs
        @Deprecated
        public static <T> IStructureElementDeferred<T> defer​(java.util.function.Function<T,​java.lang.Integer> keyExtractor,
                                                             IStructureElement<T>... array)
        Deprecated.
        renamed to partitionBy
        This is the switch block for structure code.

        This allows you to extract or compute an index from context object, and lookup an array for actual structure element to use. This will usually, but not guaranteed, to throw an exception at runtime if keyExtractor returns an index not within the array bound

        Do pay place null values in the array.

        Parameters:
        keyExtractor - extract an index from the context object
        array - all possible structure element
      • partitionBy

        @SafeVarargs
        public static <T> IStructureElementDeferred<T> partitionBy​(java.util.function.Function<T,​java.lang.Integer> keyExtractor,
                                                                   IStructureElement<T>... array)
        This is the switch block for structure code.

        This allows you to extract or compute an index from context object, and lookup an array for actual structure element to use. This will usually, but not guaranteed, to throw an exception at runtime if keyExtractor returns an index not within the array bound

        Do pay place null values in the array.

        Parameters:
        keyExtractor - extract an index from the context object
        array - all possible structure element
      • defer

        @Deprecated
        public static <T> IStructureElementDeferred<T> defer​(java.util.function.Function<T,​java.lang.Integer> keyExtractor,
                                                             java.util.List<IStructureElement<T>> array)
        Deprecated.
        renamed to partitionBy
        This is the switch block for structure code.

        This allows you to extract or compute an index from context object, and lookup an array for actual structure element to use. This will usually, but not guaranteed, to throw an exception at runtime if keyExtractor returns an index not within the array bound

        Do pay place null values in the array.

        Parameters:
        keyExtractor - extract an index from the context object
        array - all possible structure element
      • partitionBy

        public static <T> IStructureElementDeferred<T> partitionBy​(java.util.function.Function<T,​java.lang.Integer> keyExtractor,
                                                                   java.util.List<IStructureElement<T>> array)
        This is the switch block for structure code.

        This allows you to extract or compute an index from context object, and lookup an array for actual structure element to use. This will usually, but not guaranteed, to throw an exception at runtime if keyExtractor returns an index not within the array bound

        Do pay place null values in the array.

        Parameters:
        keyExtractor - extract an index from the context object
        array - all possible structure element
      • defer

        public static <T> IStructureElementDeferred<T> defer​(java.util.function.BiFunction<T,​ItemStack,​IStructureElement<T>> to)
        This will defer the actual instantiation of structure element until the structure code is actually called. This will allow the structure element constructor to access properties only present on the context object (e.g. GT5 multiblock controller), e.g. hatch texture index to use. Use this if it might change for the same structure definition, e.g. if your structure might switch mode and change some parameter, while basically remain the same shape. Using this while lazy(Supplier) is enough will not break anything, but would incur unnecessary performance overhead.

        This variant also passes the trigger item to the function, allowing it to get more info.

        Parameters:
        to - downstream element supplier
      • defer

        @Deprecated
        public static <T,​K> IStructureElementDeferred<T> defer​(java.util.function.BiFunction<T,​ItemStack,​K> keyExtractor,
                                                                     java.util.Map<K,​IStructureElement<T>> map)
        Deprecated.
        renamed to partitionBy
        This is the switch block for structure code.

        This allows you to extract or compute a key from context object, and lookup a map for actual structure element to use. This will usually, but not guaranteed, to throw an exception at runtime if keyExtractor returns a key not found in map.

        Do pay attention to what properties your map has though. You need to pay attention to how they consider equality and how they consider null key/values. Guava ImmutableMap is usually a good enough choice.

        This variant also passes the trigger item to the function, allowing it to get more info.

        Parameters:
        keyExtractor - extract a key from the context object and trigger item
        map - all possible structure element
      • partitionBy

        public static <T,​K> IStructureElementDeferred<T> partitionBy​(java.util.function.BiFunction<T,​ItemStack,​K> keyExtractor,
                                                                           java.util.Map<K,​IStructureElement<T>> map)
        This is the switch block for structure code.

        This allows you to extract or compute a key from context object, and lookup a map for actual structure element to use. This will usually, but not guaranteed, to throw an exception at runtime if keyExtractor returns a key not found in map.

        Do pay attention to what properties your map has though. You need to pay attention to how they consider equality and how they consider null key/values. Guava ImmutableMap is usually a good enough choice.

        This variant also passes the trigger item to the function, allowing it to get more info.

        Parameters:
        keyExtractor - extract a key from the context object and trigger item
        map - all possible structure element
      • defer

        @Deprecated
        public static <T,​K> IStructureElementDeferred<T> defer​(java.util.function.BiFunction<T,​ItemStack,​K> keyExtractor,
                                                                     java.util.Map<K,​IStructureElement<T>> map,
                                                                     IStructureElement<T> defaultElem)
        Deprecated.
        renamed to partitionBy
        This is the switch block for structure code, with default case support.

        This allows you to extract or compute a key from context object, and lookup a map for actual structure element to use. The fallback will only be used when keyExtractor returns a value not found in given map. This will play nicely in combination with error()

        Do pay attention to what properties your map has though. You need to pay attention to how they consider equality and how they consider null key/values. Guava ImmutableMap is usually a good enough choice.

        This variant also passes the trigger item to the function, allowing it to get more info.

        Parameters:
        keyExtractor - extract a key from the context object and trigger item
        map - all possible structure element
        defaultElem - element to use when keyExtractor returns a value not found in given map
      • partitionBy

        public static <T,​K> IStructureElementDeferred<T> partitionBy​(java.util.function.BiFunction<T,​ItemStack,​K> keyExtractor,
                                                                           java.util.Map<K,​IStructureElement<T>> map,
                                                                           IStructureElement<T> defaultElem)
        This is the switch block for structure code, with default case support.

        This allows you to extract or compute a key from context object, and lookup a map for actual structure element to use. The fallback will only be used when keyExtractor returns a value not found in given map. This will play nicely in combination with error()

        Do pay attention to what properties your map has though. You need to pay attention to how they consider equality and how they consider null key/values. Guava ImmutableMap is usually a good enough choice.

        This variant also passes the trigger item to the function, allowing it to get more info.

        Parameters:
        keyExtractor - extract a key from the context object and trigger item
        map - all possible structure element
        defaultElem - element to use when keyExtractor returns a value not found in given map
      • defer

        @SafeVarargs
        public static <T> IStructureElementDeferred<T> defer​(java.util.function.BiFunction<T,​ItemStack,​java.lang.Integer> keyExtractor,
                                                             IStructureElement<T>... array)
        This is the switch block for structure code.

        This allows you to extract or compute an index from context object, and lookup an array for actual structure element to use. This will usually, but not guaranteed, to throw an exception at runtime if keyExtractor returns an index not within the array bound

        Do pay place null values in the array.

        This variant also passes the trigger item to the function, allowing it to get more info.

        Parameters:
        keyExtractor - extract a key from the context object and trigger item
        array - all possible structure element
      • defer

        public static <T> IStructureElementDeferred<T> defer​(java.util.function.BiFunction<T,​ItemStack,​java.lang.Integer> keyExtractor,
                                                             java.util.List<IStructureElement<T>> array)
        This is the switch block for structure code.

        This allows you to extract or compute an index from context object, and lookup an array for actual structure element to use. This will usually, but not guaranteed, to throw an exception at runtime if keyExtractor returns an index not within the array bound

        Do pay place null values in the array.

        This variant also passes the trigger item to the function, allowing it to get more info.

        Parameters:
        keyExtractor - extract a key from the context object and trigger item
        array - all possible structure element
      • defer

        public static <T> IStructureElementDeferred<T> defer​(java.util.function.Function<T,​IStructureElement<T>> toCheck,
                                                             java.util.function.BiFunction<T,​ItemStack,​IStructureElement<T>> to)
        This will defer the actual instantiation of structure element until the first time structure code is actually called.

        Similar to defer, but caches the first returned element returned and won't call it again. Initialization is not thread safe. This will allow the structure element constructor to access properties only present on the context object (e.g. GT5 multiblock controller), e.g. hatch texture index to use. Use this if the data you access will remain constant.

        This variant will override the check function of the structure element from second function with the one returned from the structure element from first function.

        Parameters:
        toCheck - override the check function with the returned element
        to - create structure element from the context object passed in
      • defer

        @Deprecated
        public static <T,​K> IStructureElementDeferred<T> defer​(java.util.function.Function<T,​K> keyExtractorCheck,
                                                                     java.util.function.BiFunction<T,​ItemStack,​K> keyExtractor,
                                                                     java.util.Map<K,​IStructureElement<T>> map)
        Deprecated.
        renamed to partitionBy
        This is the switch block for structure code.

        This allows you to extract or compute a key from context object, and lookup a map for actual structure element to use. This will usually, but not guaranteed, to throw an exception at runtime if keyExtractor returns a key not found in map.

        Do pay attention to what properties your map has though. You need to pay attention to how they consider equality and how they consider null key/values. Guava ImmutableMap is usually a good enough choice.

        This variant also passes the trigger item to the function, allowing it to get more info.

        This variant will override the check function of the structure element from second function with the one returned from the structure element from first function.

        Parameters:
        keyExtractorCheck - key extractor of the structure element that will be used for check.
        keyExtractor - extract a key from the context object and trigger item
        map - all possible structure element
      • partitionBy

        public static <T,​K> IStructureElementDeferred<T> partitionBy​(java.util.function.Function<T,​K> keyExtractorCheck,
                                                                           java.util.function.BiFunction<T,​ItemStack,​K> keyExtractor,
                                                                           java.util.Map<K,​IStructureElement<T>> map)
        This is the switch block for structure code.

        This allows you to extract or compute a key from context object, and lookup a map for actual structure element to use. This will usually, but not guaranteed, to throw an exception at runtime if keyExtractor returns a key not found in map.

        Do pay attention to what properties your map has though. You need to pay attention to how they consider equality and how they consider null key/values. Guava ImmutableMap is usually a good enough choice.

        This variant also passes the trigger item to the function, allowing it to get more info.

        This variant will override the check function of the structure element from second function with the one returned from the structure element from first function.

        Parameters:
        keyExtractorCheck - key extractor of the structure element that will be used for check.
        keyExtractor - extract a key from the context object and trigger item
        map - all possible structure element
      • defer

        @Deprecated
        public static <T,​K> IStructureElementDeferred<T> defer​(java.util.function.Function<T,​K> keyExtractorCheck,
                                                                     java.util.function.BiFunction<T,​ItemStack,​K> keyExtractor,
                                                                     java.util.Map<K,​IStructureElement<T>> map,
                                                                     IStructureElement<T> defaultElem)
        Deprecated.
        renamed to partitionBy
        This is the switch block for structure code, with default case.

        This allows you to extract or compute a key from context object, and lookup a map for actual structure element to use. defaultElem will be used if either extractor returned a key not found in map.

        Do pay attention to what properties your map has though. You need to pay attention to how they consider equality and how they consider null key/values. Guava ImmutableMap is usually a good enough choice.

        This variant also passes the trigger item to the function, allowing it to get more info.

        This variant will override the check function of the structure element from second function with the one returned from the structure element from first function.

        Parameters:
        keyExtractorCheck - key extractor of the structure element that will be used for check.
        keyExtractor - extract a key from the context object and trigger item
        map - all possible structure element
      • partitionBy

        public static <T,​K> IStructureElementDeferred<T> partitionBy​(java.util.function.Function<T,​K> keyExtractorCheck,
                                                                           java.util.function.BiFunction<T,​ItemStack,​K> keyExtractor,
                                                                           java.util.Map<K,​IStructureElement<T>> map,
                                                                           IStructureElement<T> defaultElem)
        This is the switch block for structure code, with default case.

        This allows you to extract or compute a key from context object, and lookup a map for actual structure element to use. defaultElem will be used if either extractor returned a key not found in map.

        Do pay attention to what properties your map has though. You need to pay attention to how they consider equality and how they consider null key/values. Guava ImmutableMap is usually a good enough choice.

        This variant also passes the trigger item to the function, allowing it to get more info.

        This variant will override the check function of the structure element from second function with the one returned from the structure element from first function.

        Parameters:
        keyExtractorCheck - key extractor of the structure element that will be used for check.
        keyExtractor - extract a key from the context object and trigger item
        map - all possible structure element
      • defer

        @SafeVarargs
        @Deprecated
        public static <T> IStructureElementDeferred<T> defer​(java.util.function.Function<T,​java.lang.Integer> keyExtractorCheck,
                                                             java.util.function.BiFunction<T,​ItemStack,​java.lang.Integer> keyExtractor,
                                                             IStructureElement<T>... array)
        Deprecated.
        renamed to partitionBy
        This is the switch block for structure code, with default case.

        This allows you to extract or compute an index from context object, and lookup an array for actual structure element to use. This will usually, but not guaranteed, to throw an exception at runtime if keyExtractor returns an index not within the array bound

        Do pay place null values in the array.

        This variant also passes the trigger item to the function, allowing it to get more info.

        This variant will override the check function of the structure element from second function with the one returned from the structure element from first function.

        Parameters:
        keyExtractorCheck - key extractor of the structure element that will be used for check.
        keyExtractor - extract a key from the context object and trigger item
        array - all possible structure element
      • partitionBy

        @SafeVarargs
        public static <T> IStructureElementDeferred<T> partitionBy​(java.util.function.Function<T,​java.lang.Integer> keyExtractorCheck,
                                                                   java.util.function.BiFunction<T,​ItemStack,​java.lang.Integer> keyExtractor,
                                                                   IStructureElement<T>... array)
        This is the switch block for structure code, with default case.

        This allows you to extract or compute an index from context object, and lookup an array for actual structure element to use. This will usually, but not guaranteed, to throw an exception at runtime if keyExtractor returns an index not within the array bound

        Do pay place null values in the array.

        This variant also passes the trigger item to the function, allowing it to get more info.

        This variant will override the check function of the structure element from second function with the one returned from the structure element from first function.

        Parameters:
        keyExtractorCheck - key extractor of the structure element that will be used for check.
        keyExtractor - extract a key from the context object and trigger item
        array - all possible structure element
      • defer

        @Deprecated
        public static <T> IStructureElementDeferred<T> defer​(java.util.function.Function<T,​java.lang.Integer> keyExtractorCheck,
                                                             java.util.function.BiFunction<T,​ItemStack,​java.lang.Integer> keyExtractor,
                                                             java.util.List<IStructureElement<T>> array)
        Deprecated.
        renamed to partitionBy
        This is the switch block for structure code, with default case.

        This allows you to extract or compute an index from context object, and lookup an array for actual structure element to use. This will usually, but not guaranteed, to throw an exception at runtime if keyExtractor returns an index not within the array bound

        This variant also passes the trigger item to the function, allowing it to get more info.

        This variant will override the check function of the structure element from second function with the one returned from the structure element from first function.

        Parameters:
        keyExtractorCheck - key extractor of the structure element that will be used for check.
        keyExtractor - extract a key from the context object and trigger item
        array - all possible structure element
      • partitionBy

        public static <T> IStructureElementDeferred<T> partitionBy​(java.util.function.Function<T,​java.lang.Integer> keyExtractorCheck,
                                                                   java.util.function.BiFunction<T,​ItemStack,​java.lang.Integer> keyExtractor,
                                                                   java.util.List<IStructureElement<T>> array)
        This is the switch block for structure code, with default case.

        This allows you to extract or compute an index from context object, and lookup an array for actual structure element to use. This will usually, but not guaranteed, to throw an exception at runtime if keyExtractor returns an index not within the array bound

        This variant also passes the trigger item to the function, allowing it to get more info.

        This variant will override the check function of the structure element from second function with the one returned from the structure element from first function.

        Parameters:
        keyExtractorCheck - key extractor of the structure element that will be used for check.
        keyExtractor - extract a key from the context object and trigger item
        array - all possible structure element
      • step

        public static <T> com.gtnewhorizon.structurelib.structure.IStructureNavigate<T> step​(int a,
                                                                                             int b,
                                                                                             int c)
        Used internally, to generate skips for structure definitions
      • step

        public static <T> com.gtnewhorizon.structurelib.structure.IStructureNavigate<T> step​(Vec3Impl step)
        Used internally, to generate skips for structure definitions
      • getPseudoJavaCode

        public static java.lang.String getPseudoJavaCode​(World world,
                                                         ExtendedFacing extendedFacing,
                                                         int basePositionX,
                                                         int basePositionY,
                                                         int basePositionZ,
                                                         int basePositionA,
                                                         int basePositionB,
                                                         int basePositionC,
                                                         java.util.function.Function<? super TileEntity,​java.lang.String> tileEntityClassifier,
                                                         int sizeA,
                                                         int sizeB,
                                                         int sizeC,
                                                         boolean transpose)
        Used only to get pseudo code in structure writer...

        NOTE: GT specific code got removed. TODO add a mean

        Parameters:
        tileEntityClassifier - return a string that denote the type of a tile entity, or null if it's nothing special. useful if the tile entity cannot be simply distinguished via getClass.
      • iterate

        public static void iterate​(World world,
                                   ExtendedFacing extendedFacing,
                                   int basePositionX,
                                   int basePositionY,
                                   int basePositionZ,
                                   int basePositionA,
                                   int basePositionB,
                                   int basePositionC,
                                   int sizeA,
                                   int sizeB,
                                   int sizeC,
                                   IBlockPosConsumer iBlockPosConsumer)
      • iterate

        public static void iterate​(World world,
                                   ExtendedFacing extendedFacing,
                                   int basePositionX,
                                   int basePositionY,
                                   int basePositionZ,
                                   int basePositionA,
                                   int basePositionB,
                                   int basePositionC,
                                   boolean transpose,
                                   int sizeA,
                                   int sizeB,
                                   int sizeC,
                                   IBlockPosConsumer iBlockPosConsumer,
                                   java.lang.Runnable nextB,
                                   java.lang.Runnable nextC)
      • transpose

        public static java.lang.String[][] transpose​(java.lang.String[][] structurePiece)
        Transposes shape (swaps B and C axis, can be used to un-transpose transposed shape) WARNING! Do not use on old api...
        Parameters:
        structurePiece - shape (transposed shape)
        Returns:
        transposed shape (untransposed shape)