Search in sources :

Example 1 with LanternDyeColor

use of org.lanternpowered.server.data.type.LanternDyeColor in project LanternServer by LanternPowered.

the class SheepEntityProtocol method update.

@Override
protected void update(ParameterList parameterList) {
    super.update(parameterList);
    final DyeColor color = this.entity.get(Keys.DYE_COLOR).orElse(DyeColors.WHITE);
    int flags = -1;
    if (this.lastColor != color) {
        flags = 15 - ((LanternDyeColor) color).getInternalId();
        this.lastColor = color;
    }
    final boolean sheared = this.entity.get(Keys.IS_SHEARED).orElse(false);
    if (this.lastSheared != sheared) {
        if (flags == -1) {
            flags = 15 - ((LanternDyeColor) color).getInternalId();
        }
        if (sheared) {
            flags |= 0x10;
        }
        this.lastSheared = sheared;
    } else if (flags != -1 && sheared) {
        flags |= 0x10;
    }
    if (flags != -1) {
        parameterList.add(EntityParameters.Sheep.FLAGS, (byte) flags);
    }
}
Also used : LanternDyeColor(org.lanternpowered.server.data.type.LanternDyeColor) DyeColor(org.spongepowered.api.data.type.DyeColor) LanternDyeColor(org.lanternpowered.server.data.type.LanternDyeColor)

Aggregations

LanternDyeColor (org.lanternpowered.server.data.type.LanternDyeColor)1 DyeColor (org.spongepowered.api.data.type.DyeColor)1