Class CloudBlockRegistry

java.lang.Object
org.cloudburstmc.server.registry.CloudBlockRegistry
All Implemented Interfaces:
org.cloudburstmc.api.registry.Registry

public class CloudBlockRegistry extends Object implements org.cloudburstmc.api.registry.Registry
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    extendBehavior​(org.cloudburstmc.api.block.BlockType type, Function<org.cloudburstmc.api.block.behavior.BlockBehavior,​BlockBehaviorDelegate> factory)
    Extends current behavior with delegated one provided by the factory.
    get()
     
    org.cloudburstmc.api.block.behavior.BlockBehavior
    getBehavior​(org.cloudburstmc.api.block.BlockType blockType)
     
    org.cloudburstmc.api.block.BlockState
    getBlock​(int runtimeId)
     
    org.cloudburstmc.api.block.BlockState
    getBlock​(int id, int meta)
     
    org.cloudburstmc.api.block.BlockState
    getBlock​(com.nukkitx.nbt.NbtMap tag)
     
    org.cloudburstmc.api.block.BlockState
    getBlock​(org.cloudburstmc.api.block.BlockType type)
     
    org.cloudburstmc.api.block.BlockState
    getBlock​(org.cloudburstmc.api.item.ItemStack item)
     
    org.cloudburstmc.api.block.BlockState
    getBlock​(org.cloudburstmc.api.util.Identifier identifier)
     
    org.cloudburstmc.api.block.BlockState
    getBlock​(org.cloudburstmc.api.util.Identifier identifier, int meta)
     
    com.google.common.collect.ImmutableList<org.cloudburstmc.api.block.BlockState>
     
    int
     
    int
    getLegacyId​(org.cloudburstmc.api.util.Identifier identifier)
     
    org.cloudburstmc.api.util.Identifier
     
    com.nukkitx.nbt.NbtList<com.nukkitx.nbt.NbtMap>
     
    com.nukkitx.nbt.NbtMap
     
    int
    getRuntimeId​(int id, int meta)
     
    int
    getRuntimeId​(org.cloudburstmc.api.block.BlockState blockState)
     
    int
    getRuntimeId​(org.cloudburstmc.api.util.Identifier identifier, int meta)
     
    void
    overwriteBehavior​(org.cloudburstmc.api.block.BlockType type, org.cloudburstmc.api.block.behavior.BlockBehavior behavior)
    Overwrites existing or registers new BlockBehavior instance if absent
    void
    register​(org.cloudburstmc.api.block.BlockType type, org.cloudburstmc.api.block.behavior.BlockBehavior behavior)
     

    Methods inherited from class java.lang.Object

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

    • get

      public static CloudBlockRegistry get()
    • register

      public void register(org.cloudburstmc.api.block.BlockType type, org.cloudburstmc.api.block.behavior.BlockBehavior behavior) throws org.cloudburstmc.api.registry.RegistryException
      Throws:
      org.cloudburstmc.api.registry.RegistryException
    • extendBehavior

      public void extendBehavior(org.cloudburstmc.api.block.BlockType type, Function<org.cloudburstmc.api.block.behavior.BlockBehavior,​BlockBehaviorDelegate> factory)
      Extends current behavior with delegated one provided by the factory. All methods are delegated to the previous BlockBehavior instance by default.

      Extending behavior must extend BlockBehaviorDelegate class accepting parent behavior as a constructor parameter. Parent behavior instance is supplied as an argument to the factory function.

      Parameters:
      type - type to register the behavior for
      factory - factory providing BlockBehaviorDelegate instance
      Throws:
      org.cloudburstmc.api.registry.RegistryException - if there's no behavior registered for the specified type
    • overwriteBehavior

      public void overwriteBehavior(org.cloudburstmc.api.block.BlockType type, org.cloudburstmc.api.block.behavior.BlockBehavior behavior)
      Overwrites existing or registers new BlockBehavior instance if absent
      Parameters:
      type - type to register the behavior for
      behavior - overwriting behavior instance
    • getRuntimeId

      public int getRuntimeId(org.cloudburstmc.api.block.BlockState blockState)
    • getRuntimeId

      public int getRuntimeId(org.cloudburstmc.api.util.Identifier identifier, int meta)
    • getRuntimeId

      public int getRuntimeId(int id, int meta)
    • getBlock

      public org.cloudburstmc.api.block.BlockState getBlock(org.cloudburstmc.api.block.BlockType type)
    • getBlock

      public org.cloudburstmc.api.block.BlockState getBlock(org.cloudburstmc.api.item.ItemStack item)
    • getBlock

      public org.cloudburstmc.api.block.BlockState getBlock(org.cloudburstmc.api.util.Identifier identifier)
    • getBlock

      public org.cloudburstmc.api.block.BlockState getBlock(org.cloudburstmc.api.util.Identifier identifier, int meta)
    • getBlock

      public org.cloudburstmc.api.block.BlockState getBlock(int id, int meta)
    • getBlock

      public org.cloudburstmc.api.block.BlockState getBlock(int runtimeId)
    • getBlock

      public org.cloudburstmc.api.block.BlockState getBlock(com.nukkitx.nbt.NbtMap tag)
    • getLegacyId

      public int getLegacyId(String name)
    • getLegacyId

      public int getLegacyId(org.cloudburstmc.api.util.Identifier identifier)
    • getNameFromLegacyId

      public org.cloudburstmc.api.util.Identifier getNameFromLegacyId(int id)
    • close

      public void close() throws org.cloudburstmc.api.registry.RegistryException
      Specified by:
      close in interface org.cloudburstmc.api.registry.Registry
      Throws:
      org.cloudburstmc.api.registry.RegistryException
    • getPaletteTag

      public com.nukkitx.nbt.NbtList<com.nukkitx.nbt.NbtMap> getPaletteTag()
    • getPropertiesTag

      public com.nukkitx.nbt.NbtMap getPropertiesTag()
    • getBehavior

      public org.cloudburstmc.api.block.behavior.BlockBehavior getBehavior(org.cloudburstmc.api.block.BlockType blockType)
    • getBlockStates

      public com.google.common.collect.ImmutableList<org.cloudburstmc.api.block.BlockState> getBlockStates()