Class StructureLibAPI


  • public class StructureLibAPI
    extends java.lang.Object
    A stable interface into the structure lib's internals. Backwards compatibility is maintained to the maximum extend possible.
    • Constructor Detail

      • StructureLibAPI

        public StructureLibAPI()
    • Method Detail

      • enableInstrument

        public static void enableInstrument​(java.lang.Object identifier)
        Start instrumenting for the current thread only. When instrumentation is enabled, IStructureDefinition's builtin iteration methods will send StructureEvent and its subclasses when appropriate. Otherwise, these events will not be sent at all, regardless of whether a listener for these events are registered.

        Identifiers are required to be value-comparable, i.e. overrides Object.equals(Object). Suggested identifier includes

        It's an API abuse for normal IStructureDefinition users to depend on this feature. They have full control and full knowledge of the IStructureDefinition they are using. Using events to instrument the structure check/autoplace is completely unnecessary and does nothing but add overhead.

        Instruments are required to call disableInstrument() whenever it is done with its business, as there can be only one instrument for any given thread.

        Parameters:
        identifier - an identifier sent along the actual event.
        Throws:
        java.lang.IllegalStateException - if instrument has already been enabled.
      • disableInstrument

        public static void disableInstrument()
        Stop instrumenting.
        Throws:
        java.lang.IllegalStateException - if instrumenting hasn't been enabled.
      • isInstrumentEnabled

        public static boolean isInstrumentEnabled()
        Check if instrumenting is enabled.
        Returns:
        true if enabled, false otherwise
      • hintParticleTinted

        public static void hintParticleTinted​(World w,
                                              int x,
                                              int y,
                                              int z,
                                              IIcon[] icons,
                                              short[] RGBa)
        Generate a new hint particle on client side at given location using given textures with a tint.
        Parameters:
        w - World to spawn. Usually the client world.
        x - x coord
        y - y coord
        z - z coord
        icons - 6 texture. in forge direction order.
        RGBa - a 4 short array. tint in rgba form. currently alpha channel is ignored, but we might change this later on.
      • hintParticleTinted

        public static void hintParticleTinted​(World w,
                                              int x,
                                              int y,
                                              int z,
                                              Block block,
                                              int meta,
                                              short[] RGBa)
        Generate a new hint particle on client side at given location using textures from given block with a tint.
        Parameters:
        w - World to spawn. Usually the client world.
        x - x coord
        y - y coord
        z - z coord
        block - block to take texture from
        meta - the meta of block to take texture from
        RGBa - a 4 short array. tint in rgba form. currently alpha channel is ignored, but we might change this later on.
      • hintParticle

        public static void hintParticle​(World w,
                                        int x,
                                        int y,
                                        int z,
                                        IIcon[] icons)
        Generate a new hint particle on client side at given location using given textures.
        Parameters:
        w - World to spawn. Usually the client world.
        x - x coord
        y - y coord
        z - z coord
        icons - 6 texture. in forge direction order.
      • hintParticle

        public static void hintParticle​(World w,
                                        int x,
                                        int y,
                                        int z,
                                        Block block,
                                        int meta)
        Generate a new hint particle on client side at given location using textures from given block.
        Parameters:
        w - World to spawn. Usually the client world.
        x - x coord
        y - y coord
        z - z coord
        block - block to take texture from
        meta - the meta of block to take texture from
      • markHintParticleError

        public static boolean markHintParticleError​(EntityPlayer player,
                                                    World w,
                                                    int x,
                                                    int y,
                                                    int z)
        Update the tint of given hint particle. Do nothing if particle not found.

        Can be called on either client side or server side. Server side will schedule a network message to update it for this player only. Will do nothing if no hint particle is found at given location.

        Returns:
        false if nothing updated. true if updated or update instruction sent.
      • updateHintParticleTint

        public static boolean updateHintParticleTint​(EntityPlayer player,
                                                     World w,
                                                     int x,
                                                     int y,
                                                     int z,
                                                     short[] RGBa)
        Update the tint of given hint particle. Do nothing if particle not found.
        Returns:
        false if nothing updated. true if updated.
      • sendAlignment

        public static void sendAlignment​(IAlignmentProvider provider)
        Send the ExtendedFacing of this Tile Entity to all players. Can be called on server side only.

        The receiving tile entity will receive the ExtendedFacing via its IAlignment.setExtendedFacing(ExtendedFacing) method.

        Throws:
        java.lang.IllegalArgumentException - if is not tile entity or provided a null alignment
      • sendAlignment

        public static void sendAlignment​(IAlignmentProvider provider,
                                         World dimension)
        Send the ExtendedFacing of this Tile Entity to all players in that dimension. Can be called on server side only.

        The receiving tile entity will receive the ExtendedFacing via its IAlignment.setExtendedFacing(ExtendedFacing) method.

        Throws:
        java.lang.IllegalArgumentException - if is not tile entity or provided a null alignment
      • getBlockHint

        public static Block getBlockHint()
        Get the Block for StructureLib supplied hint block.
      • getItemBlockHint

        public static Item getItemBlockHint()
        Get the ItemBlock for StructureLib supplied hint block.
      • getDefaultHologramItem

        public static Item getDefaultHologramItem()
        Get the hologram item.
      • isDebugEnabled

        public static boolean isDebugEnabled()
        Check if structure debug mode is on.
        Returns:
        true if debug mode is on
      • setDebugEnabled

        public static void setDebugEnabled​(boolean enabled)
      • addThrottledChat

        public static void addThrottledChat​(java.lang.Object throttleKey,
                                            EntityPlayer player,
                                            IChatComponent text,
                                            short intervalRequired)
        Send chat to player, but throttled.
        Parameters:
        throttleKey - throttle key. Must properly implement Object.hashCode() and Object.equals(Object) to handle value equality.
        player - player to send chat to
        text - chat to send
        intervalRequired - interval required before last recorded time to actually send the message. unit in millisecond. we purposefully chose to not use a bigger data type to limit how long this interval can be
      • addThrottledChat

        public static void addThrottledChat​(java.lang.Object throttleKey,
                                            EntityPlayer player,
                                            IChatComponent text,
                                            short intervalRequired,
                                            boolean forceUpdateLastSend)
        Send chat to player, but throttled.
        Parameters:
        throttleKey - throttle key. Must properly implement Object.hashCode() and Object.equals(Object) to handle value equality.
        player - player to send chat to
        text - chat to send
        intervalRequired - interval required before last recorded time to actually send the message. unit in millisecond. we purposefully chose to not use a bigger data type to limit how long this interval can be
        forceUpdateLastSend - if true, always update the last send time, even if the message isn't actually sent.