Skip to content

Commit

Permalink
turtle changes!
Browse files Browse the repository at this point in the history
  • Loading branch information
N1nn1 committed May 6, 2024
1 parent 406bbd7 commit 3f00ed6
Show file tree
Hide file tree
Showing 18 changed files with 179 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void setupAnim(Sunfish entity, float limbSwing, float limbSwingAmount, fl
} else {
if (!entity.isInWaterOrBubble()) this.all.zRot = pi/2;
else this.all.zRot = 0;
this.all.y = Mth.cos(animationProgress * 0.2F) * 1.5F * 0.25F + (entity.getSunfishAge() == -2 ? 22.5F : 19.0F);
this.all.y = Mth.sin(animationProgress * 0.2F) * 1.5F * 0.5F + (entity.getSunfishAge() == -2 ? 22.5F : 19.0F);
this.all.yRot = Mth.cos(animationProgress * 0.2F) * 0.4F * 0.25F;
this.tailFin.yRot = Mth.cos(animationProgress * 0.4F) * 0.8F * 0.25F;
this.leftFin.yRot = Mth.cos(animationProgress * 0.4F) * 0.8F * 0.25F + 0.8F;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public ParrotOnShoulderLayerMixin(RenderLayerParent<T, PlayerModel<T>> renderLay

@Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/world/entity/player/Player;FFFFZ)V", at = @At("HEAD"), cancellable = true)
private void S$render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, T player, float f, float g, float h, float j, boolean bl, CallbackInfo ci) {
if (Minecraft.getInstance().getResourceManager().getResource(new ResourceLocation("textures/entity/parrot/remodel_enabler.txt")).isPresent()) this.model = this.remodel;
if (Minecraft.getInstance().getResourceManager().getResource(new ResourceLocation("tweaks/parrot_remodel.txt")).isPresent()) this.model = this.remodel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public ParrotRendererMixin(EntityRendererProvider.Context context, ParrotModel e

@Override
public void render(Parrot mob, float f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i) {
if (Minecraft.getInstance().getResourceManager().getResource(new ResourceLocation("textures/entity/parrot/remodel_enabler.txt")).isPresent()) this.model = this.remodel;
if (Minecraft.getInstance().getResourceManager().getResource(new ResourceLocation("tweaks/parrot_remodel.txt")).isPresent()) this.model = this.remodel;
super.render(mob, f, g, poseStack, multiBufferSource, i);
}
}
164 changes: 164 additions & 0 deletions src/main/java/com/ninni/spawn/mixin/client/TurtleModelMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
package com.ninni.spawn.mixin.client;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.QuadrupedModel;
import net.minecraft.client.model.TurtleModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.animal.Turtle;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(TurtleModel.class)
public abstract class TurtleModelMixin<T extends Turtle> extends QuadrupedModel<T> {

@Shadow @Final private ModelPart eggBelly;

protected TurtleModelMixin(ModelPart modelPart, boolean bl, float f, float g, float h, float i, int j) {
super(modelPart, bl, f, g, h, i, j);
}

@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int i, int j, float f, float g, float h, float k) {
if (Minecraft.getInstance().getResourceManager().getResource(new ResourceLocation("tweaks/turtle_baby_head_scale.txt")).isPresent()) {

if (this.young) {
poseStack.pushPose();
float scaleHead = 0.4f;
poseStack.scale(scaleHead, scaleHead, scaleHead);
poseStack.translate(0.0f, 2.2, 4.0f / 16.0f);
this.headParts().forEach(modelPart -> modelPart.render(poseStack, vertexConsumer, i, j, f, g, h, k));
poseStack.popPose();

poseStack.pushPose();
float scaleBody = 0.2f;
poseStack.scale(scaleBody, scaleBody, scaleBody);
poseStack.translate(0.0f, 6, 0.0f);
this.bodyParts().forEach(modelPart -> modelPart.render(poseStack, vertexConsumer, i, j, f, g, h, k));
poseStack.popPose();
} else {
super.renderToBuffer(poseStack, vertexConsumer, i, j, f, g, h, k);
}
} else {
super.renderToBuffer(poseStack, vertexConsumer, i, j, f, g, h, k);
}

}

@Inject(method = "setupAnim(Lnet/minecraft/world/entity/animal/Turtle;FFFFF)V", at = @At("HEAD"), cancellable = true)
private void setupAnim(T turtle, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch, CallbackInfo ci) {
if (Minecraft.getInstance().getResourceManager().getResource(new ResourceLocation("tweaks/turtle_animations.txt")).isPresent()) {
ci.cancel();

float pi = (float) Math.PI;
limbDistance = Mth.clamp(limbDistance, -0.45F, 0.45F);
this.head.xRot = headPitch * (pi / 180);
this.head.yRot = headYaw * (pi / 180);
float o = Math.min(limbDistance / 0.1f, 1.0f);

if (!turtle.isInWaterOrBubble()) {

//idle anim

this.body.y = 11;
this.head.y = 19;
this.head.z = -10;
this.leftFrontLeg.y = 21;
this.rightFrontLeg.y =21;
this.leftHindLeg.y = 22;
this.rightHindLeg.y = 22;

this.body.xRot = pi/2 - 0.05f;

this.leftFrontLeg.zRot = 0.15f;
this.leftFrontLeg.z = -8.0f;
this.leftFrontLeg.x = 6.0f;
this.leftFrontLeg.yRot = -0.4f;

this.rightFrontLeg.zRot = -0.15f;
this.rightFrontLeg.z = -8.0f;
this.rightFrontLeg.x = -6.0f;
this.rightFrontLeg.yRot = 0.4f;

this.leftHindLeg.yRot = 0.4f;
this.leftHindLeg.zRot = 0.15f;
this.leftHindLeg.xRot = 0;

this.rightHindLeg.yRot = -0.4f;
this.rightHindLeg.zRot = -0.15f;
this.rightHindLeg.xRot = 0;

//move anim
float k = turtle.isLayingEgg() ? 4.0f : 1.0f;
float l = turtle.isLayingEgg() ? 2.0f : 1.0f;

this.rightFrontLeg.yRot += Mth.cos(k * limbAngle * 5.0f + pi) * 8.0f * limbDistance * l;
this.rightFrontLeg.zRot += Mth.sin(limbAngle * 5.0f + pi) * 6.0f * limbDistance + (0.4f * o);

this.leftFrontLeg.yRot += Mth.cos(k * limbAngle * 5.0f) * 8.0f * limbDistance * l;
this.leftFrontLeg.zRot += Mth.sin(limbAngle * 5.0f) * 6.0f * limbDistance - (0.4f * o);

this.body.y += Mth.sin(limbAngle * 5.0f) * 6.0f * limbDistance;

this.rightHindLeg.yRot += Mth.sin(limbAngle * 5.0f + pi) * 3.0f * limbDistance;
this.leftHindLeg.yRot += Mth.sin(limbAngle * 5.0f) * 3.0f * limbDistance;

} else {

//idle anim
this.body.y = Mth.sin(animationProgress * 0.1F) * 0.25F + 11;
this.head.y = Mth.cos(animationProgress * 0.1F) * 0.25F + 19;
this.head.z = -10 + Mth.sin(animationProgress * 0.1F) * 1.5F * -0.2F;
this.leftFrontLeg.y = Mth.sin(animationProgress * 0.1F) * 3 * 0.25F + 23;
this.rightFrontLeg.y = Mth.sin(animationProgress * 0.1F) * 3 * 0.25F + 23;
this.leftHindLeg.y = Mth.sin(animationProgress * 0.1F) * 2.5F * 0.25F + 22;
this.rightHindLeg.y = Mth.sin(animationProgress * 0.1F) * 2.5F * 0.25F + 22;

this.body.xRot = pi/2 - Mth.sin(animationProgress * 0.1F) * 0.5F * 0.1F;

this.leftFrontLeg.zRot = Mth.cos(animationProgress * 0.1F) * 0.5F * -0.25F + 0.4f;
this.leftFrontLeg.z = -8.0f;
this.leftFrontLeg.x = 6.0f;
this.leftFrontLeg.yRot = -0.2f;

this.rightFrontLeg.zRot = Mth.cos(animationProgress * 0.1F + pi) * 0.5F * -0.25F - 0.4f;
this.rightFrontLeg.z = -8.0f;
this.rightFrontLeg.x = -6.0f;
this.rightFrontLeg.yRot = 0.2f;

this.leftHindLeg.yRot = 0.2f;
this.leftHindLeg.zRot = 0f;
this.leftHindLeg.xRot = Mth.cos(animationProgress * 0.1F + 0.2f) * 0.25F;

this.rightHindLeg.yRot = -0.2f;
this.rightHindLeg.zRot = 0f;
this.rightHindLeg.xRot = Mth.cos(animationProgress * 0.1F+ 0.4f) * 0.25F;

//swim anim

this.body.y += Mth.sin(limbAngle * 0.4F) * 0.25F * limbDistance;
this.head.y += Mth.cos(limbAngle * 0.4F) * 0.25F * limbDistance;
this.head.z += Mth.sin(limbAngle * 0.4F) * 1.5F * -limbDistance;
this.leftHindLeg.y += Mth.sin(limbAngle * 0.4F) * 8 * limbDistance;
this.rightHindLeg.y += Mth.sin(limbAngle * 0.4F) * 8 * limbDistance;

this.body.xRot += - Mth.sin(limbAngle * 0.4F) * 0.25F * limbDistance;

this.leftFrontLeg.zRot += Mth.cos(limbAngle * 0.4F) * 1.75F * limbDistance;
this.rightFrontLeg.zRot += Mth.cos(limbAngle * 0.4F + pi) * 1.75F * limbDistance;

this.leftHindLeg.xRot += Mth.cos(limbAngle * 0.4F + 0.2f) * 0.5f * limbDistance;
this.rightHindLeg.xRot += Mth.cos(limbAngle * 0.4F + 0.4f) * 0.5f * limbDistance;

}
this.eggBelly.visible = !this.young && turtle.hasEgg();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void serverInit() {

public static void addResourcePacks() {
ModContainer modContainer = FabricLoader.getInstance().getModContainer(MOD_ID).orElseThrow(() -> new IllegalStateException("Spawn's ModContainer couldn't be found!"));
ResourceManagerHelper.registerBuiltinResourcePack(new ResourceLocation(MOD_ID, "remodeled_parrots"), modContainer, "Remodeled Parrots", ResourcePackActivationType.DEFAULT_ENABLED);
ResourceManagerHelper.registerBuiltinResourcePack(new ResourceLocation(MOD_ID, "animal_tweaks"), modContainer, "Animal Tweaks", ResourcePackActivationType.DEFAULT_ENABLED);
}

private static void registerBiomeModifications() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Include this file in your resource pack to enable a new parrot model and animations if Spawn is installed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Include this file in your resource pack to enable new turtle animations if Spawn is installed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Include this file in your resource pack to enable baby turtle head scaling if Spawn is installed.
6 changes: 6 additions & 0 deletions src/main/resources/resourcepacks/animal_tweaks/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"pack": {
"pack_format": 15,
"description": "§7Minecraft Animal Remodels and New Animations!"
}
}

This file was deleted.

This file was deleted.

3 changes: 2 additions & 1 deletion src/main/resources/spawn.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"client.BlockEntityWithoutLevelRendererMixin",
"client.ParrotOnShoulderLayerMixin",
"client.ParrotRendererMixin",
"client.PufferfishRendererMixin"
"client.PufferfishRendererMixin",
"client.TurtleModelMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 3f00ed6

Please sign in to comment.