Solved Save the color of the block (Glass & Concrete) [1.12.2]

Discussion in 'Plugin Development' started by Synchroneyes, Nov 5, 2019.

Thread Status:
Not open for further replies.
  1. Hello!
    I'm trying to make a class called "DisplayBlock".
    This class basically hide & display a block.
    public class DisplayBlock {
        private Block baseBlock;
        private Location position;
        private Material materiel;
        private BlockState etat;
        public DisplayBlock(Block baseBlock) {
            try {
                this.baseBlock = baseBlock;
                this.position = baseBlock.getLocation();
                this.materiel = baseBlock.getState().getType();
                this.etat = baseBlock.getState();
            }catch (Exception e){
        public Block getBlock() { return baseBlock;}
        public void display() {
        public void hide() {
    I'm able to hide & display the block but the block lose its color when i'm displaying it.
    My question is, how can i set the block color to its original one ?
    I'm running bukkit in 1.12.2
  2. @Synchroneyes In versions below 1.13, you have to set the data as well as the material. You can see the data for wool colors here.
  3. Thank you for your answer, but i'm not working with wool :/

    In the constructor, i'm storing the state of the block, and when i print the type of the state, i successfully get Concrete(COLOR ID) in the console. But how can i apply it to my concrete block or glass ?
  4. Glass and Concrete use the same values for the colors as wool does, you can view them all here:

    After looking through the javadocs for different versions, i think there's multiple ways to do it but, it seems like this would work for 1.13+ and <1.13:
    1. block.getState().setData(block.getState().getData());

    Though i haven't tested it.
  5. Thank you for your answer. I tried to do

    public void display() {
    but nothing is showing back, and the game is printing AIR(0)


    Updating to 1.14.4 and using this code solved my problem
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited: Nov 6, 2019
  6. @Synchroneyes May i ask why you didn't update to 1.14.4 to begin with? Glad you solved it though.
  7. I dont know ehe, when i started working on my plugin my friend told me to use 1.12.2, so i've followed his advice :)
Thread Status:
Not open for further replies.

Share This Page