diff --git a/build.gradle b/build.gradle index 741bdb5..de2432d 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ architectury { minecraft = rootProject.minecraft_version } -project.mod_version = mod_version + "+1.20.6" +project.mod_version = mod_version + "+" + minecraft_version allprojects { apply plugin: "java" diff --git a/gradle.properties b/gradle.properties index 1d0cb73..5c02524 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ org.gradle.jvmargs=-Xmx4G -minecraft_version=1.20.6 +minecraft_version=1.21 archives_base_name=player-animation-lib #Major: API break, Minor: non-breaking but significant, Patch: minor bugfix/change + MC implementation fix @@ -9,9 +9,9 @@ maven_group=dev.kosmx.player-anim fabric_loader_version=0.15.11 -fabric_api_version=0.100.2+1.20.6 +fabric_api_version=0.100.4+1.21 -forge_version=20.6.119 +forge_version=21.0.61-beta # from localmaven TODO change -bendy_lib=4.1.0 +bendy_lib=5.0-rc2 diff --git a/minecraft/common/src/main/java/dev/kosmx/playerAnim/minecraftApi/PlayerAnimationRegistry.java b/minecraft/common/src/main/java/dev/kosmx/playerAnim/minecraftApi/PlayerAnimationRegistry.java index 129fbc0..eedb65a 100644 --- a/minecraft/common/src/main/java/dev/kosmx/playerAnim/minecraftApi/PlayerAnimationRegistry.java +++ b/minecraft/common/src/main/java/dev/kosmx/playerAnim/minecraftApi/PlayerAnimationRegistry.java @@ -102,7 +102,7 @@ public static void resourceLoaderCallback(@NotNull ResourceManager manager, Logg for (var animation : AnimationSerializing.deserializeAnimation(input)) { //Save the animation for later use. - animations.put(new ResourceLocation(resource.getKey().getNamespace(), PlayerAnimationRegistry.serializeTextToString((String) animation.extraData.get("name")).toLowerCase(Locale.ROOT)), animation); + animations.put(ResourceLocation.fromNamespaceAndPath(resource.getKey().getNamespace(), PlayerAnimationRegistry.serializeTextToString((String) animation.extraData.get("name")).toLowerCase(Locale.ROOT)), animation); } } catch(IOException e) { logger.error("Error while loading payer animation: " + resource.getKey()); diff --git a/minecraft/common/src/main/java/dev/kosmx/playerAnim/mixin/BipedEntityModelMixin.java b/minecraft/common/src/main/java/dev/kosmx/playerAnim/mixin/BipedEntityModelMixin.java index c07b182..e62ff47 100644 --- a/minecraft/common/src/main/java/dev/kosmx/playerAnim/mixin/BipedEntityModelMixin.java +++ b/minecraft/common/src/main/java/dev/kosmx/playerAnim/mixin/BipedEntityModelMixin.java @@ -60,16 +60,16 @@ private void copyMutatedAttributes(HumanoidModel bipedEntityModel, CallbackIn @Intrinsic(displace = true) @Override - public void renderToBuffer(PoseStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha){ + public void renderToBuffer(PoseStack matrices, VertexConsumer vertices, int light, int overlay, int color){ if(Helper.isBendEnabled() && this.animation.get() != null && this.animation.get().isActive()){ this.headParts().forEach((part)->{ if(! ((IUpperPartHelper) part).isUpperPart()){ - part.render(matrices, vertices, light, overlay, red, green, blue, alpha); + part.render(matrices, vertices, light, overlay, color); } }); this.bodyParts().forEach((part)->{ if(! ((IUpperPartHelper) part).isUpperPart()){ - part.render(matrices, vertices, light, overlay, red, green, blue, alpha); + part.render(matrices, vertices, light, overlay, color); } }); @@ -78,16 +78,16 @@ public void renderToBuffer(PoseStack matrices, VertexConsumer vertices, int ligh IBendHelper.rotateMatrixStack(matrices, emoteSupplier.get().getBend("body")); this.headParts().forEach((part)->{ if(((IUpperPartHelper) part).isUpperPart()){ - part.render(matrices, vertices, light, overlay, red, green, blue, alpha); + part.render(matrices, vertices, light, overlay, color); } }); this.bodyParts().forEach((part)->{ if(((IUpperPartHelper) part).isUpperPart()){ - part.render(matrices, vertices, light, overlay, red, green, blue, alpha); + part.render(matrices, vertices, light, overlay, color); } }); matrices.popPose(); - } else super.renderToBuffer(matrices, vertices, light, overlay, red, green, blue, alpha); + } else super.renderToBuffer(matrices, vertices, light, overlay, color); } @Final diff --git a/minecraft/common/src/main/java/dev/kosmx/playerAnim/mixin/firstPerson/LevelRendererMixin.java b/minecraft/common/src/main/java/dev/kosmx/playerAnim/mixin/firstPerson/LevelRendererMixin.java index 3fbc3cb..af85199 100644 --- a/minecraft/common/src/main/java/dev/kosmx/playerAnim/mixin/firstPerson/LevelRendererMixin.java +++ b/minecraft/common/src/main/java/dev/kosmx/playerAnim/mixin/firstPerson/LevelRendererMixin.java @@ -4,6 +4,7 @@ import dev.kosmx.playerAnim.api.firstPerson.FirstPersonMode; import dev.kosmx.playerAnim.impl.IAnimatedPlayer; import net.minecraft.client.Camera; +import net.minecraft.client.DeltaTracker; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.LevelRenderer; @@ -27,7 +28,7 @@ public class LevelRendererMixin { // @Redirect(at = @At(target = "Lnet/minecraft/client/Camera;isDetached()Z")) is forbidden @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;isDetached()Z")) - private void fakeThirdPersonMode(float f, long l, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) { + private void fakeThirdPersonMode(DeltaTracker deltaTracker, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) { // mods may need to redirect that method, I want to avoid compatibility issues as long as possible defaultCameraState = camera.isDetached(); if (camera.getEntity() instanceof IAnimatedPlayer player && player.playerAnimator_getAnimation().getFirstPersonMode() == FirstPersonMode.THIRD_PERSON_MODEL) { @@ -36,7 +37,7 @@ private void fakeThirdPersonMode(float f, long l, boolean bl, Camera camera, Gam } } @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;isDetached()Z", shift = At.Shift.AFTER)) - private void resetThirdPerson(float f, long l, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) { + private void resetThirdPerson(DeltaTracker deltaTracker, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) { ((CameraAccessor)camera).setDetached(defaultCameraState); } diff --git a/minecraft/fabric/src/main/java/dev/kosmx/playerAnim/fabric/client/FabricClientInitializer.java b/minecraft/fabric/src/main/java/dev/kosmx/playerAnim/fabric/client/FabricClientInitializer.java index afc6dae..dba06fd 100644 --- a/minecraft/fabric/src/main/java/dev/kosmx/playerAnim/fabric/client/FabricClientInitializer.java +++ b/minecraft/fabric/src/main/java/dev/kosmx/playerAnim/fabric/client/FabricClientInitializer.java @@ -33,7 +33,7 @@ public void onInitializeClient() { ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(new SimpleSynchronousResourceReloadListener() { @Override public ResourceLocation getFabricId() { - return new ResourceLocation("playeranimator", "animation"); + return ResourceLocation.fromNamespaceAndPath("playeranimator", "animation"); } @Override diff --git a/minecraft/fabric/src/main/resources/fabric.mod.json b/minecraft/fabric/src/main/resources/fabric.mod.json index e0e6cc1..d8ca7d0 100644 --- a/minecraft/fabric/src/main/resources/fabric.mod.json +++ b/minecraft/fabric/src/main/resources/fabric.mod.json @@ -23,7 +23,7 @@ "playerAnimator-common.mixins.json" ], "depends": { - "minecraft": "~1.20", + "minecraft": "~1.21", "fabric-resource-loader-v0": "*" }, "breaks": { diff --git a/minecraft/fabric/src/testmod/java/dev/kosmx/animatorTestmod/PlayerAnimTestmod.java b/minecraft/fabric/src/testmod/java/dev/kosmx/animatorTestmod/PlayerAnimTestmod.java index 14b0dc9..21dc0f7 100644 --- a/minecraft/fabric/src/testmod/java/dev/kosmx/animatorTestmod/PlayerAnimTestmod.java +++ b/minecraft/fabric/src/testmod/java/dev/kosmx/animatorTestmod/PlayerAnimTestmod.java @@ -41,7 +41,7 @@ public void onInitializeClient() { LOGGER.warn("Testmod is loading :D"); //You might use the EVENT to register new animations, or you can use Mixin. - PlayerAnimationFactory.ANIMATION_DATA_FACTORY.registerFactory(new ResourceLocation("testmod", "animation"), 42, (player) -> { + PlayerAnimationFactory.ANIMATION_DATA_FACTORY.registerFactory(ResourceLocation.fromNamespaceAndPath("testmod", "animation"), 42, (player) -> { if (player instanceof LocalPlayer) { //animationStack.addAnimLayer(42, testAnimation); //Add and save the animation container for later use. ModifierLayer testAnimation = new ModifierLayer<>(); @@ -56,7 +56,7 @@ public void onInitializeClient() { PlayerAnimationAccess.REGISTER_ANIMATION_EVENT.register((player, animationStack) -> { ModifierLayer layer = new ModifierLayer<>(); animationStack.addAnimLayer(69, layer); - PlayerAnimationAccess.getPlayerAssociatedData(player).set(new ResourceLocation("testmod", "test"), layer); + PlayerAnimationAccess.getPlayerAssociatedData(player).set(ResourceLocation.fromNamespaceAndPath("testmod", "test"), layer); }); //You can add modifiers to the ModifierLayer. @@ -69,9 +69,9 @@ public static void playTestAnimation() { ModifierLayer testAnimation; if (new Random().nextBoolean()) { - testAnimation = (ModifierLayer) PlayerAnimationAccess.getPlayerAssociatedData(Minecraft.getInstance().player).get(new ResourceLocation("testmod", "animation")); + testAnimation = (ModifierLayer) PlayerAnimationAccess.getPlayerAssociatedData(Minecraft.getInstance().player).get(ResourceLocation.fromNamespaceAndPath("testmod", "animation")); } else { - testAnimation = (ModifierLayer) PlayerAnimationAccess.getPlayerAssociatedData(Minecraft.getInstance().player).get(new ResourceLocation("testmod", "test")); + testAnimation = (ModifierLayer) PlayerAnimationAccess.getPlayerAssociatedData(Minecraft.getInstance().player).get(ResourceLocation.fromNamespaceAndPath("testmod", "test")); } if (testAnimation.getAnimation() != null && new Random().nextBoolean()) { @@ -81,7 +81,7 @@ public static void playTestAnimation() { //Fade from current animation to a new one. //Will not fade if there is no animation currently. testAnimation.replaceAnimationWithFade(AbstractFadeModifier.functionalFadeIn(20, (modelName, type, value) -> value), - new KeyframeAnimationPlayer(PlayerAnimationRegistry.getAnimation(new ResourceLocation("testmod", "two_handed_slash_vertical_right"))) + new KeyframeAnimationPlayer(PlayerAnimationRegistry.getAnimation(ResourceLocation.fromNamespaceAndPath("testmod", "two_handed_slash_vertical_right"))) .setFirstPersonMode(FirstPersonMode.THIRD_PERSON_MODEL) .setFirstPersonConfiguration(new FirstPersonConfiguration().setShowRightArm(true).setShowLeftItem(false)) ); diff --git a/minecraft/forge/src/main/resources/META-INF/neoforge.mods.toml b/minecraft/forge/src/main/resources/META-INF/neoforge.mods.toml index 5fa098b..f299edf 100644 --- a/minecraft/forge/src/main/resources/META-INF/neoforge.mods.toml +++ b/minecraft/forge/src/main/resources/META-INF/neoforge.mods.toml @@ -18,6 +18,6 @@ config = "playerAnimator-common.mixins.json" modId = "minecraft" type = "required" mandatory = true -versionRange = "[1.20.6,)" +versionRange = "[1.21,)" ordering = "NONE" side = "BOTH"