Skip to content

Commit 20540a5

Browse files
committed
Fix: relax render patch failures and correct RenderType patching
1 parent 0683266 commit 20540a5

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

Bootstrap/Core/src/main/java/customskinloader/bootstrap/transformer/patch/PatchSupport.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,15 @@ protected boolean matches(String range) {
199199
}
200200

201201
protected boolean applyIfMatches(String range, String label, BooleanSupplier operation) {
202+
return applyIfMatches(range, label, operation, true);
203+
}
204+
205+
protected boolean applyIfMatches(String range, String label, BooleanSupplier operation, boolean required) {
202206
if (!this.matches(range)) {
203207
return false;
204208
}
205209

206-
return this.requireModified(label, operation.getAsBoolean());
210+
return this.requireModified(label, operation.getAsBoolean(), required);
207211
}
208212

209213
protected boolean requireModified(String label, boolean modified) {
@@ -222,7 +226,7 @@ protected boolean requireModified(String label, boolean modified, boolean requir
222226
throw new IllegalStateException(message);
223227
}
224228

225-
if (!required && Boolean.getBoolean(IGNORE_PATCH_FAILURE_PROPERTY)) {
229+
if (!required || Boolean.getBoolean(IGNORE_PATCH_FAILURE_PROPERTY)) {
226230
LOGGER.warn(message);
227231
return false;
228232
}

Bootstrap/Core/src/main/java/customskinloader/bootstrap/transformer/patch/RenderPatch.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,27 +97,27 @@ private boolean patchCapeLayer(ClassTransformationContext context) {
9797
modified |= this.applyIfMatches("[556,560]", "cape-layer.render.v1", () -> replaceEntitySolidWithTranslucent(
9898
context, context.findMethod(CAPE_LAYER, "render", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(ABSTRACT_CLIENT_PLAYER) + "FFFFFFF)V"),
9999
RENDER_TYPE
100-
));
100+
), false);
101101
// 19w45a ~ 1.21.1 (1.15 ~ 1.21.1)
102102
modified |= this.applyIfMatches("[561,767],[801,803],[0x40000001,0x400000CC]", "cape-layer.render.v2", () -> replaceEntitySolidWithTranslucent(
103103
context, context.findMethod(CAPE_LAYER, "render", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(ABSTRACT_CLIENT_PLAYER) + "FFFFFF)V"),
104104
RENDER_TYPE
105-
));
105+
), false);
106106
// 24w33a ~ 1.21.8 (1.21.2 ~ 1.21.8)
107107
modified |= this.applyIfMatches("[768,772],[0x400000CD,0x40000103]", "cape-layer.render.v3", () -> replaceEntitySolidWithTranslucent(
108108
context, context.findMethod(CAPE_LAYER, "render", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(PLAYER_RENDER_STATE) + "FF)V"),
109109
RENDER_TYPE
110-
));
110+
), false);
111111
// 25w31a ~ 25w42a (1.21.9 ~ 1.21.10)
112112
modified |= this.applyIfMatches("773,[0x40000104,0x40000112]", "cape-layer.submit.v1", () -> replaceEntitySolidWithTranslucent(
113113
context, context.findMethod(CAPE_LAYER, "submit", "(" + objectDesc(POSE_STACK) + objectDesc(SUBMIT_NODE_COLLECTOR) + "I" + objectDesc(AVATAR_RENDER_STATE) + "FF)V"),
114114
RENDER_TYPE
115-
));
115+
), false);
116116
// 25w43a+ (1.21.11+)
117117
modified |= this.applyIfMatches("[774,800],[804,0x40000000],[0x40000113,]", "cape-layer.submit.v2", () -> replaceEntitySolidWithTranslucent(
118118
context, context.findMethod(CAPE_LAYER, "submit", "(" + objectDesc(POSE_STACK) + objectDesc(SUBMIT_NODE_COLLECTOR) + "I" + objectDesc(AVATAR_RENDER_STATE) + "FF)V"),
119119
RENDER_TYPES
120-
));
120+
), false);
121121
return modified;
122122
}
123123

@@ -127,12 +127,12 @@ private boolean patchPlayerRenderer(ClassTransformationContext context) {
127127
modified |= this.applyIfMatches("[556,560]", "player-renderer.render-hand.v1", () -> replaceEntitySolidWithTranslucent(
128128
context, context.findMethod(PLAYER_RENDERER, "renderHand", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + objectDesc(ABSTRACT_CLIENT_PLAYER) + objectDesc(MODEL_PART) + objectDesc(MODEL_PART) + ")V"),
129129
RENDER_TYPE
130-
));
130+
), false);
131131
// 19w45a ~ 1.21.1 (1.15 ~ 1.21.1)
132132
modified |= this.applyIfMatches("[561,767],[801,803],[0x40000001,0x400000CC]", "player-renderer.render-hand.v2", () -> replaceEntitySolidWithTranslucent(
133133
context, context.findMethod(PLAYER_RENDERER, "renderHand", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(ABSTRACT_CLIENT_PLAYER) + objectDesc(MODEL_PART) + objectDesc(MODEL_PART) + ")V"),
134134
RENDER_TYPE
135-
));
135+
), false);
136136
return modified;
137137
}
138138

@@ -157,7 +157,9 @@ private boolean replaceEntitySolidWithTranslucent(ClassTransformationContext con
157157
continue;
158158
}
159159

160-
methodNode.instructions.set(instruction, new MethodInsnNode(INVOKESTATIC, remappedOwner, replacementName, remappedDesc, false));
160+
methodNode.instructions.insertBefore(instruction, new InsnNode(DUP));
161+
methodNode.instructions.insert(instruction, new MethodInsnNode(INVOKESTATIC, remappedOwner, replacementName, remappedDesc, false));
162+
methodNode.instructions.insert(instruction, new InsnNode(POP));
161163
modified = true;
162164
}
163165

build.info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"mod_group": "customskinloader",
33
"mod_name": "CustomSkinLoader",
4-
"mod_version": "15.0",
4+
"mod_version": "15.0.1",
55
"edition": "Universal",
66

77
"loaders": [

0 commit comments

Comments
 (0)