Questions about setting Wool Block's color

I started looking at porting over one of my simpler plugins, WoolDyer, but ran into an issue and am wondering if there is a better way to accomplish this. The following code works for replacing everything except “lightBlue” wool. I tried replacing dyeColor with blockColor and it still still fails on light blue wool.

Is there a simpler way to deal with setting wool colors? (I really do not like abusing enums like I have, but it seems to work in this case) If not, how can I get the “lightBlue” wool to be set? Or is this possibly a bug with BlockProperty’s getValueForName?

public class SpongeEventListener {
    private TestSpongePlugin plugin;
    private enum colors { white, orange, magenta, lightBlue, yellow, lime, pink, gray, silver, cyan, purple, blue, brown, green, red, black }

    public SpongeEventListener(TestSpongePlugin testSpongePlugin) {
        plugin = testSpongePlugin;

    public void onPlayerInteract(PlayerInteractBlockEvent event) {
        if (event.getInteractionType() == EntityInteractionType.RIGHT_CLICK) {
            Player player = event.getPlayer();
            Optional<ItemStack> opholding = player.getItemInHand();

            if (opholding.isPresent()) {
                ItemStack holding = opholding.get();

                BlockLoc block = event.getBlock();
                if (block.getType() == BlockTypes.WOOL && holding.getItem() == ItemTypes.DYE) {

                    int dye = 15 - holding.getDamage();
                    String dyeColor = colors.values()[dye].toString();
          "DyeColor: " + dyeColor);

                    Optional<? extends Comparable<?>> opBlockColor = block.getState().getPropertyValue("color");
                    if (opBlockColor.isPresent()) {
                        String blockColor = opBlockColor.get().toString();

              "Block color: " + blockColor);
                        Optional<BlockProperty<?>> opBlockProperty = block.getState().getPropertyByName("color");

                        if (opBlockProperty.isPresent()) {
                            BlockProperty<?> colorProperty = opBlockProperty.get();

                            BlockState newBlock = block.getState().withProperty(colorProperty, colorProperty.getValueForName(dyeColor).get());

Let me know if you have any questions on what I’m doing or have any suggestions on improvements to anything I’m doing.


The BlockState stuff (including names) is tired directly into MC’s support for those, so the names it uses are correct by definition.

More likely whatever you’re using to define color names is incorrect for at least that color – it appears to be “light_blue”.

Interesting, I got the value from both the original block color and the BlockProperty:
Block color: lightBlue
Property: [white, orange, magenta, lightBlue, yellow, lime, pink, gray, silver, cyan, purple, blue, brown, green, red, black]

Is this something consistent across all properties that camelCase needs to be converted to underscored names?

Property names are not the .toString() of the objects. You need to ask the property .getNameForValue() function, which may or may not entirely work at the moment.