I've googled the crap out of bed color and I'm stumped

Discussion in 'Spigot Help' started by deathbat3216, Mar 14, 2018 at 2:24 AM.

  1. I've been Googling this all night, and I can't find a answer that works. I've tried Colorable and that didn't work. I need a way to get what the current color of a bed is. Is this possible?
    BTW, the API is a train wreck when it comes to this stuff, wish they would release 1.14 so we can get rid of the deprecation and such.

    Block sourceBlock = get some block...
    MaterialData sMat = sourceBlock.getState().getData();
    if (sMat instanceof Bed) {

    Bed bed = (Bed) sMat;
    if (!bed.isHeadOfBed()) {
    } else {

    Works till here...

    if (bed instanceof Colorable)

    Colorable c = (Colorable)bed;
    System.out.println("COLOR: " + c.getColor().name());
    System.out.println("NO COLOR!!!");

    All I get is No Color but I know the bed has a color, and according to the API Bed implements interface colorable, so can someone give me a hint to what I am doing wrong?
  2. 1.12.2
    Code (Text):
  3. I saw that post, I'll try it again.
  4. I did this and it is showing a red squigly saying that getColor isn't a function of Bed

    DyeColor d = ((Bed)sourceBlock.getState()).getColor();

    I'm using the BuildToolsGui.exe to build my libraries, and I reran it with latest. Do I need to do something else?
  5. The message I get is org.bukkit.craftbukkit.v1_12_R1.block.CraftBed cannot be cast to org.bukkit.material.Bed
  6. MaterialData d = sourceBlock.getState().getData();
    DyeColor dye = ((Colorable)((Bed)d)).getColor();

    org.bukkit.material.Bed cannot be cast to org.bukkit.material.Colorable
  7. thank you, now I'm confused though, how do you know which include to use?

    Is there any documentation which states when to use each?

  8. THANK YOU!!!!!!

    That makes since and worked, so quick question... why is there two Bed classes?
    • Like Like x 1
  9. One is the blockstate in a world the other the materialData of an item.
    • Informative Informative x 1
  10. wait.. i wasn't wrong for once? i had the right code figured out?

Share This Page