Skip to content

Commit fc1563b

Browse files
committed
fix: Crash with Custom Player Models
1 parent 23081df commit fc1563b

File tree

6 files changed

+109
-9
lines changed

6 files changed

+109
-9
lines changed

.github/ISSUE_TEMPLATE/enhancement.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Enhancement
1+
name: Main
22
description: Request an enhancement or feature. THIS IS NOT FOR BUG REPORTS
33
title: "[Enhancement]: "
44
body:

src/main/java/com/ventooth/swansong/mixin/Mixin.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727

2828
import static com.falsepattern.lib.mixin.v2.MixinHelper.avoid;
2929
import static com.falsepattern.lib.mixin.v2.MixinHelper.builder;
30+
import static com.falsepattern.lib.mixin.v2.MixinHelper.mods;
3031
import static com.falsepattern.lib.mixin.v2.MixinHelper.require;
3132
import static com.ventooth.swansong.mixin.TargetMod.Avaritia;
33+
import static com.ventooth.swansong.mixin.TargetMod.CustomPlayerModels;
3234
import static com.ventooth.swansong.mixin.TargetMod.DragonAPI;
3335
import static com.ventooth.swansong.mixin.TargetMod.FoamFix;
3436
import static com.ventooth.swansong.mixin.TargetMod.JourneyMap;
@@ -95,12 +97,15 @@ public enum Mixin implements IMixins {
9597
"hooks.RenderDragonMixin",
9698
"hooks.QuadComparatorMixin",
9799
"hooks.GuiOptionsRowListMixin")),
98-
Hooks_AvoidModernWarfare(Phase.EARLY,
99-
avoid(ModernWarfare),
100-
client("hooks.RendererLivingEntityMixin_AvoidModernWarfare")),
101-
Hooks_RequireModernWarfare(Phase.EARLY,
102-
require(ModernWarfare),
103-
client("hooks.RendererLivingEntityMixin_RequireModernWarfare")),
100+
Hooks_RendererLivingEntity_Vanilla(Phase.EARLY,
101+
mods(avoid(ModernWarfare), avoid(CustomPlayerModels)),
102+
client("hooks.RendererLivingEntityMixin_Vanilla")),
103+
Hooks_RendererLivingEntity_ModernWarfare(Phase.EARLY,
104+
require(ModernWarfare),
105+
client("hooks.RendererLivingEntityMixin_ModernWarfare")),
106+
Hooks_RendererLivingEntity_CustomPlayerModels(Phase.EARLY,
107+
require(CustomPlayerModels),
108+
client("hooks.RendererLivingEntityMixin_CustomPlayerModels")),
104109

105110
Debug(Phase.EARLY,
106111
() -> ModuleConfig.Debug,

src/main/java/com/ventooth/swansong/mixin/TargetMod.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public enum TargetMod implements ITargetMod {
3333
NotFine("jss.notfine.mixinplugin.NotFineEarlyMixins"),
3434
Zume("dev.nolij.zume.api.config.v1.ZumeConfig"),
3535
ModernWarfare("com.vicmatskiv.weaponlib.core.WeaponlibCorePlugin"),
36+
CustomPlayerModels("com.tom.cpmcore.CPMLoadingPlugin"),
3637
//regular mods,
3738
Avaritia("fox.spiteful.avaritia.Avaritia"),
3839
Thaumcraft("thaumcraft.common.Thaumcraft"),
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Swansong
3+
*
4+
* Copyright 2025 Ven, FalsePattern
5+
*
6+
* This software is licensed under the Open Software License version
7+
* 3.0. The full text of this license can be found in https://opensource.org/licenses/OSL-3.0
8+
* or in the LICENSES directory which is distributed along with the software.
9+
*/
10+
11+
package com.ventooth.swansong.mixin.mixins.client.hooks;
12+
13+
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
14+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
15+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
16+
import com.llamalad7.mixinextras.sugar.Share;
17+
import com.llamalad7.mixinextras.sugar.ref.LocalIntRef;
18+
import com.ventooth.swansong.api.ShaderStateInfo;
19+
import com.ventooth.swansong.mixin.extensions.RendererLivingEntityExt;
20+
import com.ventooth.swansong.shader.ShaderEngine;
21+
import com.ventooth.swansong.shader.StateGraph;
22+
import lombok.val;
23+
import org.spongepowered.asm.mixin.Dynamic;
24+
import org.spongepowered.asm.mixin.Mixin;
25+
import org.spongepowered.asm.mixin.Unique;
26+
import org.spongepowered.asm.mixin.injection.At;
27+
import org.spongepowered.asm.mixin.injection.Slice;
28+
29+
import net.minecraft.client.model.ModelBase;
30+
import net.minecraft.client.renderer.entity.RendererLivingEntity;
31+
import net.minecraft.entity.Entity;
32+
33+
@Mixin(RendererLivingEntity.class)
34+
public abstract class RendererLivingEntityMixin_CustomPlayerModels {
35+
@Unique
36+
private static final String CPM_ASM_HOOK_METHOD = "Lcom/tom/cpmcore/CPMASMClientHooks;renderPass(Lnet/minecraft/client/model/ModelBase;Lnet/minecraft/entity/Entity;FFFFFFLnet/minecraft/client/renderer/entity/RendererLivingEntity;I)V";
37+
@Unique
38+
private static final String DYNAMIC_COMMENT = "Applied by: [com.tom.cpmcore.CPMTransformerService]";
39+
40+
@Dynamic(DYNAMIC_COMMENT)
41+
@WrapOperation(method = "doRender(Lnet/minecraft/entity/EntityLivingBase;DDDFF)V",
42+
at = @At(value = "INVOKE",
43+
target = CPM_ASM_HOOK_METHOD,
44+
remap = false,
45+
ordinal = 0),
46+
require = 1)
47+
private void hook_WrapSpiderEyes(ModelBase modelBase,
48+
Entity entity,
49+
float limbSwing,
50+
float limbSwingAmount,
51+
float ageInTicks,
52+
float netHeadYaw,
53+
float headPitch,
54+
float scale,
55+
RendererLivingEntity renderer,
56+
int callLoc,
57+
Operation<Void> original,
58+
@Share("pass_ref") LocalIntRef passRef) {
59+
//separated out here because intellij screams due to the unsafe cast when inlined
60+
val self = (RendererLivingEntity) (Object) this;
61+
if (ShaderEngine.graph.isManaged() &&
62+
RendererLivingEntityExt.isSpiderEyes(self, entity, modelBase, passRef.get())) {
63+
if (ShaderStateInfo.shadowPassActive()) {
64+
return;
65+
}
66+
ShaderEngine.graph.push(StateGraph.Stack.SpiderEyes);
67+
original.call(modelBase, entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, renderer, callLoc);
68+
ShaderEngine.graph.pop(StateGraph.Stack.SpiderEyes);
69+
} else {
70+
original.call(modelBase, entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, renderer, callLoc);
71+
}
72+
}
73+
74+
@Dynamic(DYNAMIC_COMMENT)
75+
@WrapWithCondition(method = "doRender(Lnet/minecraft/entity/EntityLivingBase;DDDFF)V",
76+
at = @At(value = "INVOKE",
77+
target = CPM_ASM_HOOK_METHOD,
78+
remap = false),
79+
slice = @Slice(from = @At(value = "INVOKE",
80+
target = "Lnet/minecraft/client/renderer/entity/RendererLivingEntity;renderEquippedItems(Lnet/minecraft/entity/EntityLivingBase;F)V")),
81+
require = 1)
82+
private boolean skip_VanillaMobHurtRender(ModelBase instance,
83+
Entity entity,
84+
float limbSwing,
85+
float limbSwingAmount,
86+
float ageInTicks,
87+
float netHeadYaw,
88+
float headPitch,
89+
float scale,
90+
RendererLivingEntity renderer,
91+
int callLoc) {
92+
return !ShaderEngine.isInitialized();
93+
}
94+
}

src/main/java/com/ventooth/swansong/mixin/mixins/client/hooks/RendererLivingEntityMixin_RequireModernWarfare.java renamed to src/main/java/com/ventooth/swansong/mixin/mixins/client/hooks/RendererLivingEntityMixin_ModernWarfare.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import net.minecraft.entity.Entity;
3232

3333
@Mixin(RendererLivingEntity.class)
34-
public abstract class RendererLivingEntityMixin_RequireModernWarfare {
34+
public abstract class RendererLivingEntityMixin_ModernWarfare {
3535
@Unique
3636
private static final String MW_RENDER_MODEL_INTERCEPTOR = "Lcom/vicmatskiv/weaponlib/compatibility/Interceptors;renderArmorLayer(Lnet/minecraft/client/model/ModelBase;Lnet/minecraft/entity/Entity;FFFFFF)V";
3737
@Unique

src/main/java/com/ventooth/swansong/mixin/mixins/client/hooks/RendererLivingEntityMixin_AvoidModernWarfare.java renamed to src/main/java/com/ventooth/swansong/mixin/mixins/client/hooks/RendererLivingEntityMixin_Vanilla.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import net.minecraft.entity.Entity;
3030

3131
@Mixin(RendererLivingEntity.class)
32-
public abstract class RendererLivingEntityMixin_AvoidModernWarfare {
32+
public abstract class RendererLivingEntityMixin_Vanilla {
3333
@WrapOperation(method = "doRender(Lnet/minecraft/entity/EntityLivingBase;DDDFF)V",
3434
at = @At(value = "INVOKE",
3535
target = "Lnet/minecraft/client/model/ModelBase;render(Lnet/minecraft/entity/Entity;FFFFFF)V",

0 commit comments

Comments
 (0)