diff --git a/build.gradle b/build.gradle index fea88cc..c818947 100644 --- a/build.gradle +++ b/build.gradle @@ -58,6 +58,15 @@ repositories { name "Modrinth" url "https://api.modrinth.com/maven" } // Needs for Replay Mod + + maven { + name = 'GeckoLib' + url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/' + content { + includeGroupByRegex("software\\.bernie.*") + includeGroup("com.eliotlash.mclib") + } + } } dependencies { @@ -92,6 +101,8 @@ dependencies { exclude(group: "net.fabricmc.fabric-api") } + modImplementation("software.bernie.geckolib:geckolib-fabric-${mcVersion}:${prop("dep.geckolib")}") + if (!(stonecutter.compare("1.20.5", mcVersion) == 0)) { // Replay Mod modImplementation("maven.modrinth:replaymod:${findProperty("dep.replaymod")}") diff --git a/gradle.properties b/gradle.properties index 2740580..02af759 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,7 +22,8 @@ lombok_version = 1.18.32 # Multi-Versions Properties # Verified version: 1.20 1.20.1 1.20.2 1.20.3 1.20.4 1.20.5 1.20.6 1.21 -multi_versions = 1.16.5 1.17 1.17.1 1.18 1.18.1 1.18.2 1.19 1.19.1 1.19.2 1.19.3 1.19.4 1.20 1.20.1 1.20.3 1.20.4 1.20.5 1.20.6 1.21 1.21.1 1.21.2 1.21.3 +# multi_versions = 1.16.5 1.17 1.17.1 1.18 1.18.1 1.18.2 1.19 1.19.1 1.19.2 1.19.3 1.19.4 1.20 1.20.1 1.20.3 1.20.4 1.20.5 1.20.6 1.21 1.21.1 1.21.2 1.21.3 +multi_versions = 1.20.1 1.21.3 # Build Dependencies build.yarn = [VERSIONED] @@ -35,6 +36,9 @@ dep.yacl = [VERSIONED] dep.modmenu = [VERSIONED] dep.cloth-config = [VERSIONED] dep.replaymod = [VERSIONED] +dep.geckolib = [VERSIONED] + +# TODO ?????? GeckoLib ?? ??????, ? ??????? ?? ?? ?????? (???????? 1.21.2) # # # # # # # # # # # # # # # Publication Properties # diff --git a/src/main/java/net/lopymine/patpat/mixin/GeoEntityRendererMixin.java b/src/main/java/net/lopymine/patpat/mixin/GeoEntityRendererMixin.java new file mode 100644 index 0000000..952618a --- /dev/null +++ b/src/main/java/net/lopymine/patpat/mixin/GeoEntityRendererMixin.java @@ -0,0 +1,37 @@ +package net.lopymine.patpat.mixin; + +// TODO Отключить класс из версий, в которых GeckoLib не создан (например 1.21.2) + +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.*; +import org.spongepowered.asm.mixin.*; +import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import software.bernie.geckolib.renderer.GeoEntityRenderer; + +import net.lopymine.patpat.renderer.PatAnimationRenderer; + + +//? >=1.21.2 { +import net.minecraft.client.render.entity.state.EntityRenderState; +import net.lopymine.patpat.utils.mixin.EntityRenderStateWithParent; +//?} + +@Mixin(GeoEntityRenderer.class) +public abstract class GeoEntityRendererMixin { + + //? <1.21.2 { + /*@Inject(at=@At(value = "HEAD"), method = "render") + private void render(Entity entity, float entityYaw, float partialTick, MatrixStack matrixStack, VertexConsumerProvider bufferSource, int packedLight, CallbackInfo ci) { + *///?} else { + @Inject(at = @At(value = "HEAD"), method = "render") + private void render(EntityRenderState entityRenderState, MatrixStack matrixStack, VertexConsumerProvider bufferSource, int packedLight, CallbackInfo ci) { + Entity entity = ((EntityRenderStateWithParent) entityRenderState).patPat$getEntity(); + //?} + if (!(entity instanceof LivingEntity livingEntity)) { + return; + } + PatAnimationRenderer.scaleEntityIfPatted(livingEntity, matrixStack); + } +} diff --git a/src/main/java/net/lopymine/patpat/mixin/LivingEntityRendererMixin.java b/src/main/java/net/lopymine/patpat/mixin/LivingEntityRendererMixin.java index d9ca763..439014a 100644 --- a/src/main/java/net/lopymine/patpat/mixin/LivingEntityRendererMixin.java +++ b/src/main/java/net/lopymine/patpat/mixin/LivingEntityRendererMixin.java @@ -8,8 +8,7 @@ import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.lopymine.patpat.entity.PatEntity; -import net.lopymine.patpat.manager.client.PatPatClientManager; +import net.lopymine.patpat.renderer.PatAnimationRenderer; //? >=1.21.2 { import net.minecraft.entity.Entity; @@ -31,16 +30,6 @@ private void render(LivingEntityRenderState livingEntityRenderState, MatrixStack return; } //?} - PatEntity patEntity = PatPatClientManager.getPatEntity(livingEntity); - if (patEntity == null) { - return; - } - - if (PatPatClientManager.expired(patEntity)) { - PatPatClientManager.removePatEntity(patEntity); - return; - } - - matrixStack.scale(1F, PatPatClientManager.getAnimationProgress(patEntity), 1F); + PatAnimationRenderer.scaleEntityIfPatted(livingEntity, matrixStack); } } diff --git a/src/main/java/net/lopymine/patpat/renderer/PatAnimationRenderer.java b/src/main/java/net/lopymine/patpat/renderer/PatAnimationRenderer.java new file mode 100644 index 0000000..deab857 --- /dev/null +++ b/src/main/java/net/lopymine/patpat/renderer/PatAnimationRenderer.java @@ -0,0 +1,24 @@ +package net.lopymine.patpat.renderer; + +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.LivingEntity; + +import net.lopymine.patpat.entity.PatEntity; +import net.lopymine.patpat.manager.client.PatPatClientManager; + +public class PatAnimationRenderer { + + public static void scaleEntityIfPatted(LivingEntity livingEntity, MatrixStack matrixStack){ + PatEntity patEntity = PatPatClientManager.getPatEntity(livingEntity); + if (patEntity == null) { + return; + } + + if (PatPatClientManager.expired(patEntity)) { + PatPatClientManager.removePatEntity(patEntity); + return; + } + + matrixStack.scale(1F, PatPatClientManager.getAnimationProgress(patEntity), 1F); + } +} diff --git a/src/main/resources/patpat.mixins.json5 b/src/main/resources/patpat.mixins.json5 index c11b34f..4356001 100644 --- a/src/main/resources/patpat.mixins.json5 +++ b/src/main/resources/patpat.mixins.json5 @@ -13,6 +13,7 @@ /*? >=1.21.2*/ "EntityRenderStateMixin", "MinecraftClientMixin", + "GeoEntityRendererMixin", "CameraMixin" ], "injectors": { diff --git a/versions/1.20.1/gradle.properties b/versions/1.20.1/gradle.properties index aa32405..4f10f4a 100644 --- a/versions/1.20.1/gradle.properties +++ b/versions/1.20.1/gradle.properties @@ -13,3 +13,5 @@ dep.modmenu=7.2.2 dep.yacl=3.6.1+1.20.1-fabric # replaymod, check https://modrinth.com/mod/replaymod/versions?g=1.20.1 dep.replaymod=1.20.1-2.6.20 +# geckolib, check https://modrinth.com/mod/geckolib/versions?g=1.20.1 +dep.geckolib=4.4.9 diff --git a/versions/1.21.3/gradle.properties b/versions/1.21.3/gradle.properties index cc52af8..ccc26a0 100644 --- a/versions/1.21.3/gradle.properties +++ b/versions/1.21.3/gradle.properties @@ -2,7 +2,7 @@ # Fabric Properties, check https://fabricmc.net/develop/ build.yarn=1.21.3+build.2 -build.fabric_api=0.107.0+1.21.3 +build.fabric_api=0.109.0+1.21.3 # Additional Dependencies Properties # cloth-config, check https://modrinth.com/mod/cloth-config/versions?g=1.21.3 @@ -13,3 +13,5 @@ dep.modmenu=12.0.0-beta.1 dep.yacl=3.6.1+1.21.2-fabric # replaymod, check https://modrinth.com/mod/replaymod/versions?g=1.21.3 dep.replaymod=1.21.2-2.6.20 +# geckolib, check https://modrinth.com/mod/geckolib/versions?g=1.21.3 +dep.geckolib=4.7.1