Class AbstractBlockLogicExtension



  • public abstract class AbstractBlockLogicExtension
    extends java.lang.Object
    Manages the game logic for a block. The instances are not saved in the map save file; therfore, every data saved in the fields are lost after quitting.
    Points to a Coordinate in the map. If the content of the coordinate changes it will be removed via Map. Check if is about to be removed via isValid().
    If you want to save information in the save file you have to use and spawn an AbstractEntity.
    • Constructor Detail

      • AbstractBlockLogicExtension

        public AbstractBlockLogicExtension​()
        Called when spawned. Should not access the map because during map creating this method is called and the map still empty. Also entities can not be spawned here.
    • Method Detail

      • registerClass

        public static void registerClass​(byte id,
                                         java.lang.Class<? extends AbstractBlockLogicExtension> aClass)
        Register a block id with a logic block class.
        Parameters:
        id -
        aClass -
      • newLogicInstance

        public static AbstractBlockLogicExtension newLogicInstance​(byte blockId,
                                                                   byte value,
                                                                   Coordinate coord)
        Creates a new logic instance if registered. This can happen before the chunk is filled at this position.
        Parameters:
        blockId - the block at the position
        value -
        coord - the position where the logic block is placed
        Returns:
        null if not registered
      • isRegistered

        public static boolean isRegistered​(byte blockId)
      • getPosition

        public Coordinate getPosition​()
        This method must be named "getPosition" so that this method can implement other interfaces using this API signature
        Returns:
        not copy safe. never null
      • isValid

        public boolean isValid​()
        A logicblock is still valid if the pointer shows to a block with the same id as during creation.
        Returns:
        false if should be deleted
      • update

        public abstract void update​(float dt)
        Parameters:
        dt - time in ms
      • dispose

        public abstract void dispose​()
        called when removed
      • setValue

        public void setValue​(byte value)
        Parameters:
        value -