diff --git a/build.gradle.kts b/build.gradle.kts index 5a40ee34..afb8465a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -95,10 +95,26 @@ dependencies { //region MOD DEPENDENCIES fun modImpl(modPrefix: String, vararg versions: Pair): Boolean { - for ((versionMC, versionMod) in versions) { + for ((versionMC, implVersionMod) in versions) { if (platform.mcVersion >= versionMC) { - if (versionMod != null) { - modImplementation("$modPrefix$versionMod") { + if (implVersionMod != null) { + modImplementation("$modPrefix$implVersionMod") { + exclude("net.fabricmc.fabric-api") + isTransitive = true + } + return true + } + break + } + } + return false + } + + fun modComp(modPrefix: String, vararg versions: Pair): Boolean { + for ((versionMC, compVersionMod) in versions) { + if (platform.mcVersion >= versionMC) { + if (compVersionMod != null) { + compileOnly("$modPrefix$compVersionMod") { exclude("net.fabricmc.fabric-api") isTransitive = true } @@ -166,15 +182,22 @@ dependencies { } if (!platform.isForge) { - if (mcVersion >= 12109) { - compileOnly("com.zigythebird.playeranim:PlayerAnimationLibCommon:1.1.0+alpha.1+mc.1.21.9") - compileOnly("com.zigythebird.playeranim:PlayerAnimationLibCore:1.1.0+alpha.1+mc.1.21.9") - } else if (mcVersion >= 12100) { - compileOnly("com.zigythebird.playeranim:PlayerAnimationLibCommon:1.0.14+mc.1.21.1") - compileOnly("com.zigythebird.playeranim:PlayerAnimationLibCore:1.0.14+mc.1.21.1") - } + val playerAnimVersions = arrayOf( + 12109 to "1.1.0+alpha.1+mc.1.21.9", + 12100 to "1.0.14+mc.1.21.1" + ) + modComp("com.zigythebird.playeranim:PlayerAnimationLibCommon:", *playerAnimVersions) + modComp("com.zigythebird.playeranim:PlayerAnimationLibCore:", *playerAnimVersions) } + modComp("maven.modrinth:real-camera:", + 26_01_00 to ver("8iDFFsGL", null, "tPhOLg40"), + 1_21_04 to ver("ERGbfBFO", null, "j9j0EChP"), + 1_21_02 to ver("ERGbfBFO", null, "j9j0EChP"), + 1_21_00 to ver("ERGbfBFO", null, "j9j0EChP"), + 1_20_01 to ver("GtVt9wyh", "zxrGLIlw", null), + ) + //endregion if (platform.isNeoForge && mcVersion < 12002) { // NeoForge 20.2.84+ added it themselves diff --git a/src/main/java/traben/entity_model_features/mixin/Plugin.java b/src/main/java/traben/entity_model_features/mixin/Plugin.java index 97e87d25..aa2faa59 100644 --- a/src/main/java/traben/entity_model_features/mixin/Plugin.java +++ b/src/main/java/traben/entity_model_features/mixin/Plugin.java @@ -58,4 +58,4 @@ public void preApply(final String targetClassName, final ClassNode targetClass, public void postApply(final String targetClassName, final ClassNode targetClass, final String mixinClassName, final IMixinInfo mixinInfo) { } -} +} \ No newline at end of file diff --git a/src/main/java/traben/entity_model_features/mixin/mixins/mod_compat/MixinRealCameraCore.java b/src/main/java/traben/entity_model_features/mixin/mixins/mod_compat/MixinRealCameraCore.java new file mode 100644 index 00000000..a97a58c8 --- /dev/null +++ b/src/main/java/traben/entity_model_features/mixin/mixins/mod_compat/MixinRealCameraCore.java @@ -0,0 +1,29 @@ +package traben.entity_model_features.mixin.mixins.mod_compat; + +import net.minecraft.client.Minecraft; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import traben.entity_model_features.mod_compat.RealCameraCompat; + +@Pseudo +@Mixin(targets = "com.xtracr.realcamera.RealCameraCore", remap = false) +public class MixinRealCameraCore { + // This method is used to get the vertex catcher + // It does NOT render the entity in the world +//#if MC == 1.20.1 && !NEOFORGE || MC >= 1.21.1 && MC <= 1.21.4 && !FORGE || MC == 26.1 && !FORGE +//$$ @Inject(method = "computeCamera", at = @At("HEAD")) +//$$ private static void EFM$onComputeCameraHead(Minecraft client, float partialTicks, CallbackInfo ci) { +//$$ RealCameraCompat.isComputeCameraRendering = true; +//$$ } +//$$ +//$$ @Inject(method = "computeCamera", at = @At("RETURN")) +//$$ private static void EFM$onComputeCameraReturn(Minecraft client, float partialTicks, CallbackInfo ci) { +//$$ RealCameraCompat.isComputeCameraRendering = false; +//$$ } +//#endif +} + diff --git a/src/main/java/traben/entity_model_features/mod_compat/RealCameraCompat.java b/src/main/java/traben/entity_model_features/mod_compat/RealCameraCompat.java new file mode 100644 index 00000000..5987cc3a --- /dev/null +++ b/src/main/java/traben/entity_model_features/mod_compat/RealCameraCompat.java @@ -0,0 +1,9 @@ +package traben.entity_model_features.mod_compat; + +public class RealCameraCompat { + public static boolean isComputeCameraRendering = false; + + public static boolean isShouldRenderEntity() { + return !isComputeCameraRendering; + } +} \ No newline at end of file diff --git a/src/main/java/traben/entity_model_features/models/animation/math/asm/ASMAnimationHandler.java b/src/main/java/traben/entity_model_features/models/animation/math/asm/ASMAnimationHandler.java index 416bb91d..961b818a 100644 --- a/src/main/java/traben/entity_model_features/models/animation/math/asm/ASMAnimationHandler.java +++ b/src/main/java/traben/entity_model_features/models/animation/math/asm/ASMAnimationHandler.java @@ -10,6 +10,7 @@ import traben.entity_model_features.models.animation.math.expression_tree.MathValue; import traben.entity_model_features.models.animation.math.variables.VariableRegistry; import traben.entity_model_features.models.animation.math.variables.factories.GlobalVariableFactory; +import traben.entity_model_features.mod_compat.RealCameraCompat; import traben.entity_model_features.utils.EMFUtils; import traben.entity_texture_features.utils.ETFLruCache; @@ -61,8 +62,9 @@ protected void animateInner(ModelPart[] pausedParts) throws Throwable { if (logsASM) asmLog(asmVariableHandler, vars, "Start ASM anim with variable state:"); compiledAnimationExecutor.execute(vars.floats(), vars.bools()); - - varConsumer.accept(vars, true); + //Default is TRUE + boolean shouldUpdateVars = RealCameraCompat.isShouldRenderEntity(); + varConsumer.accept(vars, shouldUpdateVars); if (lod && state != null) lastResultsPerEntity.put(state.uuid(), vars); if (logsASM) asmLog(asmVariableHandler, vars, "End ASM anim with variable state:"); @@ -255,4 +257,4 @@ private interface VarConsumer { } private record AnimVars(float[] floats, boolean[] bools) { } -} +} \ No newline at end of file diff --git a/src/main/resources/entity_model_features.mixins.json b/src/main/resources/entity_model_features.mixins.json index 7b74e758..b0f69eec 100644 --- a/src/main/resources/entity_model_features.mixins.json +++ b/src/main/resources/entity_model_features.mixins.json @@ -26,6 +26,7 @@ "exporting.MixinBabyModelTransform", "exporting.MixinEntityModelSet", "exporting.MixinMeshTransformer", + "mod_compat.MixinRealCameraCore", "rendering.Mixin_SpecialModelRenderers_SetCurrentSpecifiedModel", "rendering.MixinBannerRenderer", "rendering.MixinBlockEntityRenderDispatcher",