Class BlockStateValues

java.lang.Object
org.geysermc.geyser.level.block.BlockStateValues

public final class BlockStateValues extends Object
Used for block entities if the Java block state contains Bedrock block information.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
     
    static int
     
    static int
     
    static int
     
    static int
     
    static int
     
    static int
     
    static int
     
    static int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    canPistonDestroyBlock​(int state)
     
    static boolean
    canPistonMoveBlock​(int javaId, boolean isPushing)
     
    static int
    getBannerColor​(int state)
    Banner colors are part of the namespaced ID in Java Edition, but part of the block entity tag in Bedrock.
    static byte
    getBedColor​(int state)
    Bed colors are part of the namespaced ID in Java Edition, but part of the block entity tag in Bedrock.
    static it.unimi.dsi.fastutil.ints.Int2ByteMap
    The block state in Java and Bedrock both contain the conditional bit, however command block block entity tags in Bedrock need the conditional information.
    static it.unimi.dsi.fastutil.ints.Int2ObjectMap<DoubleChestValue>
    All double chest values are part of the block state in Java and part of the block entity tag in Bedrock.
    static it.unimi.dsi.fastutil.ints.Int2ObjectMap<String>
    Get the Int2ObjectMap of flower pot block states to containing plant
     
    static int
    getNoteblockPitch​(int state)
    The note that noteblocks output when hit is part of the block state in Java but sent as a BlockEventPacket in Bedrock.
    static int
    getPistonHead​(Direction direction)
    Get the Java Block State for a piston head for a specific direction This is used in PistonBlockEntity to get the BlockCollision for the piston head.
    static Direction
    getPistonOrientation​(int state)
    This is used in GeyserPistonEvents.java and accepts minecraft:piston, minecraft:sticky_piston, and minecraft:moving_piston.
    static it.unimi.dsi.fastutil.ints.Int2BooleanMap
    Get the Int2BooleanMap showing if a piston block state is extended or not.
    static byte
    getShulkerBoxDirection​(int state)
    Shulker box directions are part of the namespaced ID in Java Edition, but part of the block entity tag in Bedrock.
    static byte
    getSkullRotation​(int state)
    Skull rotations are part of the namespaced ID in Java Edition, but part of the block entity tag in Bedrock.
    static byte
    getSkullVariant​(int state)
    Skull variations are part of the namespaced ID in Java Edition, but part of the block entity tag in Bedrock.
    static it.unimi.dsi.fastutil.ints.Int2IntMap
    Skull rotations are part of the namespaced ID in Java Edition, but part of the block entity tag in Bedrock.
    static float
    getSlipperiness​(int state)
    Get the slipperiness of a block.
    static int
    getWaterLevel​(int state)
    Get the level of water from the block state.
    static boolean
    isBlockAttached​(int stateA, int stateB)
    Check if two blocks are attached to each other.
    static boolean
    isBlockSticky​(int state)
    Checks if a block sticks to other blocks (Slime and honey blocks)
    static boolean
    isMovingPiston​(int state)
    Check if a block is a minecraft:moving_piston This is used in ChunkUtils to prevent them from being placed as it causes pistons to flicker and it is not needed
    static boolean
    isPistonHead​(int state)
     
    static boolean
    isStickyPiston​(int blockState)
     
    static void
    storeBlockStateValues​(String javaId, int javaBlockState, com.fasterxml.jackson.databind.JsonNode blockData)
    Determines if the block state contains Bedrock block information

    Methods inherited from class java.lang.Object

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

    • JAVA_AIR_ID

      public static final int JAVA_AIR_ID
      See Also:
      Constant Field Values
    • JAVA_BELL_ID

      public static int JAVA_BELL_ID
    • JAVA_COBWEB_ID

      public static int JAVA_COBWEB_ID
    • JAVA_FURNACE_ID

      public static int JAVA_FURNACE_ID
    • JAVA_FURNACE_LIT_ID

      public static int JAVA_FURNACE_LIT_ID
    • JAVA_HONEY_BLOCK_ID

      public static int JAVA_HONEY_BLOCK_ID
    • JAVA_SLIME_BLOCK_ID

      public static int JAVA_SLIME_BLOCK_ID
    • JAVA_SPAWNER_ID

      public static int JAVA_SPAWNER_ID
    • JAVA_WATER_ID

      public static int JAVA_WATER_ID
  • Method Details

    • storeBlockStateValues

      public static void storeBlockStateValues(String javaId, int javaBlockState, com.fasterxml.jackson.databind.JsonNode blockData)
      Determines if the block state contains Bedrock block information
      Parameters:
      javaId - The Java Identifier of the block
      javaBlockState - the Java Block State of the block
      blockData - JsonNode of info about the block from blocks.json
    • getBannerColor

      public static int getBannerColor(int state)
      Banner colors are part of the namespaced ID in Java Edition, but part of the block entity tag in Bedrock. This gives an integer color that Bedrock can use.
      Parameters:
      state - BlockState of the block
      Returns:
      Banner color integer or -1 if no color
    • getBedColor

      public static byte getBedColor(int state)
      Bed colors are part of the namespaced ID in Java Edition, but part of the block entity tag in Bedrock. This gives a byte color that Bedrock can use - Bedrock needs a byte in the final tag.
      Parameters:
      state - BlockState of the block
      Returns:
      Bed color byte or -1 if no color
    • getCommandBlockValues

      public static it.unimi.dsi.fastutil.ints.Int2ByteMap getCommandBlockValues()
      The block state in Java and Bedrock both contain the conditional bit, however command block block entity tags in Bedrock need the conditional information.
      Returns:
      the list of all command blocks and if they are conditional (1 or 0)
    • getDoubleChestValues

      public static it.unimi.dsi.fastutil.ints.Int2ObjectMap<DoubleChestValue> getDoubleChestValues()
      All double chest values are part of the block state in Java and part of the block entity tag in Bedrock. This gives the DoubleChestValue that can be calculated into the final tag.
      Returns:
      The map of all DoubleChestValues.
    • getFlowerPotValues

      public static it.unimi.dsi.fastutil.ints.Int2ObjectMap<String> getFlowerPotValues()
      Get the Int2ObjectMap of flower pot block states to containing plant
      Returns:
      Int2ObjectMap of flower pot values
    • getLecternBookStates

      public static LecternHasBookMap getLecternBookStates()
      Returns:
      the lectern book state map pointing to book present state
    • getNoteblockPitch

      public static int getNoteblockPitch(int state)
      The note that noteblocks output when hit is part of the block state in Java but sent as a BlockEventPacket in Bedrock. This gives an integer pitch that Bedrock can use.
      Parameters:
      state - BlockState of the block
      Returns:
      note block note integer or -1 if not present
    • getPistonValues

      public static it.unimi.dsi.fastutil.ints.Int2BooleanMap getPistonValues()
      Get the Int2BooleanMap showing if a piston block state is extended or not.
      Returns:
      the Int2BooleanMap of piston extensions.
    • isStickyPiston

      public static boolean isStickyPiston(int blockState)
    • isPistonHead

      public static boolean isPistonHead(int state)
    • getPistonHead

      public static int getPistonHead(Direction direction)
      Get the Java Block State for a piston head for a specific direction This is used in PistonBlockEntity to get the BlockCollision for the piston head.
      Parameters:
      direction - Direction the piston head points in
      Returns:
      Block state for the piston head
    • isMovingPiston

      public static boolean isMovingPiston(int state)
      Check if a block is a minecraft:moving_piston This is used in ChunkUtils to prevent them from being placed as it causes pistons to flicker and it is not needed
      Parameters:
      state - Block state of the block
      Returns:
      True if the block is a moving_piston
    • getPistonOrientation

      public static Direction getPistonOrientation(int state)
      This is used in GeyserPistonEvents.java and accepts minecraft:piston, minecraft:sticky_piston, and minecraft:moving_piston.
      Parameters:
      state - The block state of the piston base
      Returns:
      The direction in which the piston faces
    • isBlockSticky

      public static boolean isBlockSticky(int state)
      Checks if a block sticks to other blocks (Slime and honey blocks)
      Parameters:
      state - The block state
      Returns:
      True if the block sticks to adjacent blocks
    • isBlockAttached

      public static boolean isBlockAttached(int stateA, int stateB)
      Check if two blocks are attached to each other.
      Parameters:
      stateA - The block state of block a
      stateB - The block state of block b
      Returns:
      True if the blocks are attached to each other
    • canPistonDestroyBlock

      public static boolean canPistonDestroyBlock(int state)
      Parameters:
      state - The block state of the block
      Returns:
      true if a piston can break the block
    • canPistonMoveBlock

      public static boolean canPistonMoveBlock(int javaId, boolean isPushing)
    • getSkullVariant

      public static byte getSkullVariant(int state)
      Skull variations are part of the namespaced ID in Java Edition, but part of the block entity tag in Bedrock. This gives a byte variant ID that Bedrock can use.
      Parameters:
      state - BlockState of the block
      Returns:
      Skull variant byte or -1 if no variant
    • getSkullRotation

      public static byte getSkullRotation(int state)
      Skull rotations are part of the namespaced ID in Java Edition, but part of the block entity tag in Bedrock. This gives a byte rotation that Bedrock can use.
      Parameters:
      state - BlockState of the block
      Returns:
      Skull rotation value or -1 if no value
    • getSkullWallDirections

      public static it.unimi.dsi.fastutil.ints.Int2IntMap getSkullWallDirections()
      Skull rotations are part of the namespaced ID in Java Edition, but part of the block entity tag in Bedrock. This gives a integer rotation that Bedrock can use.
      Returns:
      Skull wall rotation value with the blockstate
    • getShulkerBoxDirection

      public static byte getShulkerBoxDirection(int state)
      Shulker box directions are part of the namespaced ID in Java Edition, but part of the block entity tag in Bedrock. This gives a byte direction that Bedrock can use.
      Parameters:
      state - BlockState of the block
      Returns:
      Shulker direction value or -1 if no value
    • getWaterLevel

      public static int getWaterLevel(int state)
      Get the level of water from the block state. This is used in FishingHookEntity to create splash sounds when the hook hits the water.
      Parameters:
      state - BlockState of the block
      Returns:
      The water level or -1 if the block isn't water
    • getSlipperiness

      public static float getSlipperiness(int state)
      Get the slipperiness of a block. This is used in ItemEntity to calculate the friction on an item as it slides across the ground
      Parameters:
      state - BlockState of the block
      Returns:
      The block's slipperiness