Search in sources :

Example 1 with HandPreference

use of org.spongepowered.api.data.type.HandPreference in project LanternServer by LanternPowered.

the class CodecPlayInClientSettings method decode.

@Override
public MessagePlayInClientSettings decode(CodecContext context, ByteBuffer buf) throws CodecException {
    final Locale locale = LocaleCache.get(buf.readLimitedString(16));
    final int viewDistance = buf.readByte();
    final ChatVisibility visibility = ChatVisibilityRegistryModule.get().getByInternalId(buf.readByte()).get();
    final boolean enableColors = buf.readBoolean();
    final int skinPartsBitPattern = buf.readByte() & 0xff;
    final HandPreference dominantHand = buf.readVarInt() == 1 ? HandPreferences.RIGHT : HandPreferences.LEFT;
    return new MessagePlayInClientSettings(locale, viewDistance, visibility, dominantHand, enableColors, skinPartsBitPattern);
}
Also used : Locale(java.util.Locale) ChatVisibility(org.spongepowered.api.text.chat.ChatVisibility) HandPreference(org.spongepowered.api.data.type.HandPreference) MessagePlayInClientSettings(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayInClientSettings)

Example 2 with HandPreference

use of org.spongepowered.api.data.type.HandPreference in project LanternServer by LanternPowered.

the class InsentientEntityProtocol method update.

@Override
protected void update(ParameterList parameterList) {
    super.update(parameterList);
    final HandPreference dominantHand = this.entity.get(Keys.DOMINANT_HAND).orElse(HandPreferences.RIGHT);
    if (dominantHand != this.lastDominantHand) {
        // Ignore the NoAI tag, isn't used on the client
        parameterList.add(EntityParameters.Insentient.FLAGS, (byte) (dominantHand == HandPreferences.LEFT ? 0x2 : 0));
        this.lastDominantHand = dominantHand;
    }
}
Also used : HandPreference(org.spongepowered.api.data.type.HandPreference)

Example 3 with HandPreference

use of org.spongepowered.api.data.type.HandPreference in project LanternServer by LanternPowered.

the class HumanoidEntityProtocol method update.

@Override
protected void update(ParameterList parameterList) {
    super.update(parameterList);
    final HandPreference dominantHand = this.entity.get(Keys.DOMINANT_HAND).orElse(HandPreferences.RIGHT);
    if (dominantHand != this.lastDominantHand) {
        parameterList.add(EntityParameters.Humanoid.MAIN_HAND, (byte) (dominantHand == HandPreferences.RIGHT ? 1 : 0));
        this.lastDominantHand = dominantHand;
    }
    final Set<SkinPart> skinParts = this.entity.get(LanternKeys.DISPLAYED_SKIN_PARTS).orElse(null);
    if (!Objects.equals(this.lastSkinParts, skinParts)) {
        parameterList.add(EntityParameters.Humanoid.SKIN_PARTS, (byte) (skinParts == null ? 0xff : LanternSkinPart.toBitPattern(skinParts)));
        this.lastSkinParts = skinParts;
    }
}
Also used : HandPreference(org.spongepowered.api.data.type.HandPreference) LanternSkinPart(org.lanternpowered.server.data.type.LanternSkinPart) SkinPart(org.spongepowered.api.data.type.SkinPart)

Aggregations

HandPreference (org.spongepowered.api.data.type.HandPreference)3 Locale (java.util.Locale)1 LanternSkinPart (org.lanternpowered.server.data.type.LanternSkinPart)1 MessagePlayInClientSettings (org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayInClientSettings)1 SkinPart (org.spongepowered.api.data.type.SkinPart)1 ChatVisibility (org.spongepowered.api.text.chat.ChatVisibility)1