use of org.spongepowered.common.data.type.SpongeSkinPart in project SpongeCommon by SpongePowered.
the class SpongeRegistryLoaders method skinPart.
public static RegistryLoader<SkinPart> skinPart() {
return RegistryLoader.of(l -> {
l.add(SkinParts.CAPE, k -> new SpongeSkinPart("cape"));
l.add(SkinParts.HAT, k -> new SpongeSkinPart("hat"));
l.add(SkinParts.JACKET, k -> new SpongeSkinPart("jacket"));
l.add(SkinParts.LEFT_PANTS_LEG, k -> new SpongeSkinPart("left_pants_leg"));
l.add(SkinParts.LEFT_SLEEVE, k -> new SpongeSkinPart("left_sleeve"));
l.add(SkinParts.RIGHT_PANTS_LEG, k -> new SpongeSkinPart("right_pants_leg"));
l.add(SkinParts.RIGHT_SLEEVE, k -> new SpongeSkinPart("right_sleeve"));
});
}
use of org.spongepowered.common.data.type.SpongeSkinPart in project SpongeCommon by SpongePowered.
the class ServerPlayerMixin method impl$handleClientSettings.
@SuppressWarnings({ "ConstantConditions", "UnstableApiUsage" })
@Inject(method = "updateOptions", at = @At("HEAD"))
private void impl$handleClientSettings(final ServerboundClientInformationPacket packet, final CallbackInfo ci) {
if (!ShouldFire.PLAYER_CHANGE_CLIENT_SETTINGS_EVENT) {
return;
}
final ServerboundClientInformationPacketAccessor $packet = (ServerboundClientInformationPacketAccessor) packet;
final Locale newLocale = LocaleCache.getLocale($packet.accessor$language());
final ImmutableSet<SkinPart> skinParts = Sponge.game().registry(RegistryTypes.SKIN_PART).stream().map(part -> (SpongeSkinPart) part).filter(part -> part.test(packet.getModelCustomisation())).collect(ImmutableSet.toImmutableSet());
final int viewDistance = $packet.accessor$viewDistance();
// Post before the player values are updated
try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) {
final ChatVisibility visibility = (ChatVisibility) (Object) packet.getChatVisibility();
final PlayerChangeClientSettingsEvent event = SpongeEventFactory.createPlayerChangeClientSettingsEvent(frame.currentCause(), visibility, skinParts, newLocale, (ServerPlayer) this, packet.getChatColors(), viewDistance);
SpongeCommon.post(event);
}
}
use of org.spongepowered.common.data.type.SpongeSkinPart in project SpongeCommon by SpongePowered.
the class ServerPlayerMixin method bridge$setSkinParts.
@Override
public void bridge$setSkinParts(final Set<SkinPart> skinParts) {
int mask = 0;
for (final SkinPart part : skinParts) {
mask |= ((SpongeSkinPart) part).getMask();
}
this.shadow$getEntityData().set(DATA_PLAYER_MODE_CUSTOMISATION, (byte) mask);
this.impl$skinParts = ImmutableSet.copyOf(skinParts);
this.impl$skinPartMask = mask;
}
Aggregations