I'm trying to change the color of a placed glass block, but I'm not getting anywhere. I have already changed the color of a glass block, but it was only in the inventory.
What I did until now. The glass blocks are stored in a list. Don't worry, it works perfectly.
public int setGlassToGreen () {
int i = 0;
ItemStack glassitstack = new ItemStack (Material.STAINED_GLASS);
glassitstack.setDurability ((short) DyeColor.GREEN.getWoolData ());
for (Location loc: glass) {
MaterialData temp = glassitstack.getData ();
loc.getBlock ();
//loc.getBlock().set
//loc.getWorld (). GetBlockAt (loc) .setData (DyeColor.GREEN.getWoolData ());
i ++;
}
return i;
}
So in the world you can replace it with worldedit (// replace glassID1 glassID2)
I don't want to set it with worldedit, but programming ^^
Hm k then no idea Xd
Which version? From 1.13+ (I think) the following would go:
private void changeGlassToGreen (Block b) {
b.setType (Material.GREEN_STAINED_GLASS);
}
1.12-:
private void changeGlassToGreen (Block b) {
((Colorable) b.getState (). GetData ()). SetColor (DyeColor.GREEN);
}