/* * Decompiled with CFR 0.152. * * Could not load the following classes: * org.jspecify.annotations.Nullable */ package net.minecraft.client.gui.components; import java.util.function.Supplier; import net.minecraft.client.gui.ComponentPath; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.gui.navigation.FocusNavigationEvent; import net.minecraft.client.input.MouseButtonEvent; import net.minecraft.client.model.PlayerModel; import net.minecraft.client.model.geom.EntityModelSet; import net.minecraft.client.model.geom.ModelLayers; import net.minecraft.client.sounds.SoundManager; import net.minecraft.network.chat.CommonComponents; import net.minecraft.util.Mth; import net.minecraft.world.entity.player.PlayerModelType; import net.minecraft.world.entity.player.PlayerSkin; import org.jspecify.annotations.Nullable; public class PlayerSkinWidget extends AbstractWidget { private static final float MODEL_HEIGHT = 2.125f; private static final float FIT_SCALE = 0.97f; private static final float ROTATION_SENSITIVITY = 2.5f; private static final float DEFAULT_ROTATION_X = -5.0f; private static final float DEFAULT_ROTATION_Y = 30.0f; private static final float ROTATION_X_LIMIT = 50.0f; private final PlayerModel wideModel; private final PlayerModel slimModel; private final Supplier skin; private float rotationX = -5.0f; private float rotationY = 30.0f; public PlayerSkinWidget(int width, int height, EntityModelSet models, Supplier skin) { super(0, 0, width, height, CommonComponents.EMPTY); this.wideModel = new PlayerModel(models.bakeLayer(ModelLayers.PLAYER), false); this.slimModel = new PlayerModel(models.bakeLayer(ModelLayers.PLAYER_SLIM), true); this.skin = skin; } @Override protected void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float a) { float scale = 0.97f * (float)this.getHeight() / 2.125f; float pivotY = -1.0625f; PlayerSkin skin = this.skin.get(); PlayerModel model = skin.model() == PlayerModelType.SLIM ? this.slimModel : this.wideModel; graphics.submitSkinRenderState(model, skin.body().texturePath(), scale, this.rotationX, this.rotationY, -1.0625f, this.getX(), this.getY(), this.getRight(), this.getBottom()); } @Override protected void onDrag(MouseButtonEvent event, double dx, double dy) { this.rotationX = Mth.clamp(this.rotationX - (float)dy * 2.5f, -50.0f, 50.0f); this.rotationY += (float)dx * 2.5f; } @Override public void playDownSound(SoundManager soundManager) { } @Override protected void updateWidgetNarration(NarrationElementOutput output) { } @Override public @Nullable ComponentPath nextFocusPath(FocusNavigationEvent navigationEvent) { return null; } }