Interface BlockData

All Superinterfaces:
Cloneable
All Known Subinterfaces:
Ageable, AmethystCluster, AnaloguePowerable, Attachable, Bamboo, Bed, Beehive, Bell, BigDripleaf, Bisected, BrewingStand, BubbleColumn, Cake, Campfire, Candle, CaveVines, CaveVinesPlant, Chain, Chest, Cocoa, CommandBlock, Comparator, CoralWallFan, DaylightDetector, Directional, Dispenser, Door, Dripleaf, EnderChest, EndPortalFrame, FaceAttachable, Farmland, Fence, Fire, Furnace, Gate, GlassPane, GlowLichen, Grindstone, Hopper, Jigsaw, Jukebox, Ladder, Lantern, Leaves, Lectern, Levelled, Light, Lightable, LightningRod, MultipleFacing, NoteBlock, Observer, Openable, Orientable, Piston, PistonHead, PointedDripstone, Powerable, Rail, RedstoneRail, RedstoneWallTorch, RedstoneWire, Repeater, RespawnAnchor, Rotatable, Sapling, Scaffolding, SculkSensor, SeaPickle, Sign, Slab, SmallDripleaf, Snow, Snowable, Stairs, StructureBlock, Switch, TechnicalPiston, TNT, TrapDoor, Tripwire, TripwireHook, TurtleEgg, Wall, WallSign, Waterlogged

public interface BlockData extends Cloneable
  • Method Details

    • getMaterial

      @NotNull @NotNull Material getMaterial()
      Get the Material represented by this block data.
      Returns:
      the material
    • getAsString

      @NotNull @NotNull String getAsString()
      Gets a string, which when passed into a method such as Server.createBlockData(java.lang.String) will unambiguously recreate this instance.
      Returns:
      serialized data string for this block
    • getAsString

      @NotNull @NotNull String getAsString(boolean hideUnspecified)
      Gets a string, which when passed into a method such as Server.createBlockData(java.lang.String) will recreate this or a similar instance where unspecified states (if any) may be optionally omitted. If this instance was parsed and states are omitted, this exact instance will be creatable when parsed again, else their equality cannot be guaranteed.

      This method will only take effect for BlockData instances created by methods such as Server.createBlockData(String) or any similar method whereby states are optionally defined. If otherwise, the result of getAsString() will be returned. The following behaviour would be expected:

      
       String dataString = "minecraft:chest[waterlogged=true]"
       BlockData data = Bukkit.createBlockData(dataString);
       dataString.equals(data.getAsString(true)); // This would return true
       dataString.equals(data.getAsString(false)); // This would return false as all states are present
       dataString.equals(data.getAsString()); // This is equivalent to the above, "getAsString(false)"
       
      Parameters:
      hideUnspecified - true if unspecified states should be omitted, false if they are to be shown as performed by getAsString().
      Returns:
      serialized data string for this block
    • merge

      Merges all explicitly set states from the given data with this BlockData.
      Note that the given data MUST have been created from one of the String parse methods, e.g. Server.createBlockData(java.lang.String) and not have been subsequently modified.
      Note also that the block types must match identically.
      Parameters:
      data - the data to merge from
      Returns:
      a new instance of this blockdata with the merged data
    • matches

      boolean matches(@Nullable @Nullable BlockData data)
      Checks if the specified BlockData matches this block data.
      The semantics of this method are such that for manually created or modified BlockData it has the same effect as Object.equals(java.lang.Object), whilst for parsed data (that to which merge(org.bukkit.block.data.BlockData) applies, it will return true when the type and all explicitly set states match.
      Note that these semantics mean that a.matches(b) may not be the same as b.matches(a)
      Parameters:
      data - the data to match against (normally a parsed constant)
      Returns:
      if there is a match
    • clone

      Returns a copy of this BlockData.
      Returns:
      a copy of the block data
    • getSoundGroup

      @NotNull @NotNull SoundGroup getSoundGroup()
      Gets the block's SoundGroup which can be used to get its step sound, hit sound, and others.
      Returns:
      the sound effect group