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);
}
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;
}
}
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;
}
}
Aggregations