Skip to content

Commit

Permalink
Readd firstPersonPixelScaling. Fix #196
Browse files Browse the repository at this point in the history
  • Loading branch information
tr7zw committed Nov 15, 2024
1 parent 588e770 commit 9e3855e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
java-version: 21
# to cache gradle files
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
uses: gradle/actions/setup-gradle@v4
with:
gradle-home-cache-cleanup: true
dependency-graph: generate-and-submit
Expand Down
32 changes: 22 additions & 10 deletions src/main/java/dev/tr7zw/skinlayers/api/OffsetProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,32 @@ public interface OffsetProvider {

public void applyOffset(PoseStack stack, Mesh mesh);

public final static OffsetProvider HEAD = createVanilla(Shape.HEAD, false);
public final static OffsetProvider LEFT_LEG = createVanilla(Shape.LEGS, false);
public final static OffsetProvider RIGHT_LEG = createVanilla(Shape.LEGS, false);
public final static OffsetProvider LEFT_ARM = createVanilla(Shape.ARMS, false);
public final static OffsetProvider LEFT_ARM_SLIM = createVanilla(Shape.ARMS_SLIM, false);
public final static OffsetProvider RIGHT_ARM = createVanilla(Shape.ARMS, true);
public final static OffsetProvider RIGHT_ARM_SLIM = createVanilla(Shape.ARMS_SLIM, true);
public final static OffsetProvider BODY = createVanilla(Shape.BODY, false);

private static OffsetProvider createVanilla(Shape shape, boolean mirrored) {
public final static OffsetProvider HEAD = createVanilla(Shape.HEAD);
public final static OffsetProvider LEFT_LEG = createVanilla(Shape.LEGS);
public final static OffsetProvider RIGHT_LEG = createVanilla(Shape.LEGS);
public final static OffsetProvider LEFT_ARM = createVanilla(Shape.ARMS);
public final static OffsetProvider LEFT_ARM_SLIM = createVanilla(Shape.ARMS_SLIM);
public final static OffsetProvider RIGHT_ARM = createVanilla(Shape.ARMS, true, false);
public final static OffsetProvider RIGHT_ARM_SLIM = createVanilla(Shape.ARMS_SLIM, true, false);
public final static OffsetProvider FIRSTPERSON_LEFT_ARM = createVanilla(Shape.ARMS, false, true);
public final static OffsetProvider FIRSTPERSON_LEFT_ARM_SLIM = createVanilla(Shape.ARMS_SLIM, false, true);
public final static OffsetProvider FIRSTPERSON_RIGHT_ARM = createVanilla(Shape.ARMS, true, true);
public final static OffsetProvider FIRSTPERSON_RIGHT_ARM_SLIM = createVanilla(Shape.ARMS_SLIM, true, true);
public final static OffsetProvider BODY = createVanilla(Shape.BODY);

private static OffsetProvider createVanilla(Shape shape) {
return createVanilla(shape, false, false);
}

private static OffsetProvider createVanilla(Shape shape, boolean mirrored, boolean firstperson) {
return (stack, mesh) -> {
float pixelScaling = SkinLayersModBase.config.baseVoxelSize;
float heightScaling = 1.035f;
float widthScaling = SkinLayersModBase.config.baseVoxelSize;
if (firstperson) {
pixelScaling = SkinLayersModBase.config.firstPersonPixelScaling;
widthScaling = SkinLayersModBase.config.firstPersonPixelScaling;
}

float x = 0;
float y = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void initialize() {
(b) -> config.fastRender = b));
options.add(getOnOffOption("text.skinlayers.compatibilityMode.enable", () -> config.compatibilityMode,
(b) -> config.compatibilityMode = b));
options.add(getDoubleOption("text.skinlayers.firstperson.voxelsize", 1.02f, 1.2f, 0.001f,
options.add(getDoubleOption("text.skinlayers.firstperson.voxelsize", 1.02f, 1.3f, 0.001f,
() -> (double) config.firstPersonPixelScaling, (i) -> {
config.firstPersonPixelScaling = i.floatValue();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

@Mixin(PlayerRenderer.class)
public abstract class PlayerRendererMixin
// spotless:off
// spotless:off
//#if MC >= 12102
extends LivingEntityRenderer<AbstractClientPlayer, PlayerRenderState, PlayerModel> {
//#else
Expand Down Expand Up @@ -196,7 +196,7 @@ public void extractRenderState(AbstractClientPlayer abstractClientPlayer, Player
// spotless:on

@Inject(method = "renderHand", at = @At("HEAD"))
// spotless:off
// spotless:off
//#if MC >= 12102
private void renderHandStart(PoseStack poseStack, MultiBufferSource multiBufferSource, int i,
ResourceLocation resourceLocation, ModelPart arm, boolean bl, CallbackInfo info) {
Expand Down Expand Up @@ -224,12 +224,12 @@ private void renderHandStart(PoseStack poseStack, MultiBufferSource multiBufferS
if (arm == getModel().leftArm) {
if (SkinLayersModBase.config.enableLeftSleeve) {
((ModelPartInjector) (Object) sleeve).setInjectedMesh(settings.getLeftArmMesh(),
slim ? OffsetProvider.LEFT_ARM_SLIM : OffsetProvider.LEFT_ARM);
slim ? OffsetProvider.FIRSTPERSON_LEFT_ARM_SLIM : OffsetProvider.FIRSTPERSON_LEFT_ARM);
}
} else {
if (SkinLayersModBase.config.enableRightSleeve) {
((ModelPartInjector) (Object) sleeve).setInjectedMesh(settings.getRightArmMesh(),
slim ? OffsetProvider.RIGHT_ARM_SLIM : OffsetProvider.RIGHT_ARM);
slim ? OffsetProvider.FIRSTPERSON_RIGHT_ARM_SLIM : OffsetProvider.FIRSTPERSON_RIGHT_ARM);
}
}
}
Expand Down

0 comments on commit 9e3855e

Please sign in to comment.