Need info about BlockState

Discussion in 'Plugin Development' started by randomer679, Oct 15, 2011.

Thread Status:
Not open for further replies.
  1. Hi I understand most of the bukkit api. But one thing I don't understand is what getBlockState is for? Why would you need to use it? I've read the api documentation for it but still don't understand. It seems too similiar to getBlock to me but I think I've just not understood what it does. This is purely for future reference so any info would be greatly appreciated :)
     
  2. A BlockState is basically just what it says: a block's state at the point of time when it is created.
    Unlike the regular Block instance, it won't automatically update/change when the block itself changes and vice versa (the block won't update when the BlockState changes).

    The main uses I can think of right now for BlockStates:
    Storing a snapshot of blocks to use it later - e.g. you set an area of blocks to something for your plugin, but you want to reset it to the original blocks later. Instead of manually storing the previous blockIDs/data (and TileEntity data like chest contents, sign text, etc.) you just store BlockState's and then update() them.

    Getting access to enhanced block-specific methods for TileEntities (e.g. Signs, Chests, Furnaces, etc.) - common example is setting the contents of a Sign. The class "Sign" extends BlockState, so getting the BlockState, setting the lines, and then updating the sign is the way to go.
     
    randomer679 likes this.
  3. THANK YOU! :D that was a great explanation :) I know understand and may actually use this at some point now I know what it does :)
     
Thread Status:
Not open for further replies.

Share This Page