Skip to content

Commit

Permalink
Back to working on this project, fifth or sixth times the charm i gue…
Browse files Browse the repository at this point in the history
…ss lol

- Updated to 1.20.2
  • Loading branch information
Trainguy9512 committed Oct 8, 2023
1 parent 5950866 commit b0a72fa
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 26 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Expand Up @@ -27,7 +27,9 @@ dependencies {

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modRuntimeOnly "com.terraformersmc:modmenu:5.0.2"

// mod menu (1.19)
//modRuntimeOnly "com.terraformersmc:modmenu:5.0.2"

// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Expand Up @@ -4,14 +4,14 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.5
loader_version=0.14.21
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.4
loader_version=0.14.22

# Mod Properties
mod_version = 2.0.0-alpha
maven_group = com.trainguy9512
archives_base_name = animation-overhaul

# Dependencies
fabric_version=0.76.1+1.19.3
fabric_version=0.89.3+1.20.2
Expand Up @@ -297,7 +297,7 @@ public void tick(LivingEntity livingEntity, AnimationDataContainer entityAnimati
&& !this.livingEntity.isPassenger()
);
setEntityAnimationVariable(IS_FALLING,
!this.livingEntity.isOnGround()
!this.livingEntity.onGround()
&& !this.livingEntity.onClimbable()
);
getAnimationState(JUMP_STATE_MACHINE)
Expand Down
Expand Up @@ -86,11 +86,11 @@ protected WalkAnimationState getWalkAnimationState(){
*/

protected float getWalkAnimationSpeed(){
return this.livingEntity.animationSpeed;
return this.livingEntity.walkAnimation.speed();
}

protected float getWalkAnimationPosition(){
return this.livingEntity.animationPosition;
return this.livingEntity.walkAnimation.position();
}

public void tick(LivingEntity livingEntity){
Expand Down
Expand Up @@ -47,7 +47,7 @@ public enum ModelPartLocators{
public static final ResourceLocation ANIM_TEST_WALK = TimelineGroupData.getNativeResourceLocation("player/sprint_normal");

private static final AnimationSequencePlayer ANIM_TEST_IDLE_SEQUENCE_PLAYER = AnimationSequencePlayer.of("anim_test_idle_sequence_player", ANIM_TEST_IDLE)
.setDefaultPlayRate(1F);
.setDefaultPlayRate(0.2F);
private static final AnimationSequencePlayer ANIM_TEST_WALK_SEQUENCE_PLAYER = AnimationSequencePlayer.of("anim_test_walk_sequence_player", ANIM_TEST_WALK)
.setDefaultPlayRate(1F);

Expand Down Expand Up @@ -104,7 +104,7 @@ protected LocatorSkeleton<ModelPartLocators> buildRig() {
@Override
public void tick(LivingEntity livingEntity, AnimationDataContainer entityAnimationData) {

boolean isWalking = this.getWalkAnimationSpeed() > 0.05;
boolean isWalking = this.getWalkAnimationSpeed() > 0.1;
getAnimationState(TEST_STATE_MACHINE)
.setTransitionCondition(TestStates.IDLE, TestStates.WALKING, isWalking)
.setTransitionCondition(TestStates.WALKING, TestStates.IDLE, !isWalking);
Expand Down
Expand Up @@ -2,9 +2,11 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.trainguy9512.animationoverhaul.access.LivingEntityAccess;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
import net.minecraft.world.entity.LivingEntity;
import org.joml.Quaternionf;
import org.joml.Vector3f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -13,7 +15,7 @@
@Mixin(InventoryScreen.class)
public class MixinInventoryScreen {
@Inject(method = "renderEntityInInventory", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderDispatcher;setRenderShadow(Z)V"))
private static void setRendererToEntity(int i, int j, int k, float f, float g, LivingEntity livingEntity, CallbackInfo ci){
private static void setRendererToEntity(GuiGraphics guiGraphics, float f, float g, int i, Vector3f vector3f, Quaternionf quaternionf, Quaternionf quaternionf2, LivingEntity livingEntity, CallbackInfo ci){
((LivingEntityAccess)livingEntity).setUseInventoryRenderer(true);
}
}
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.client.renderer.entity.layers.RenderLayer;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -32,12 +33,13 @@ public MixinItemInHandLayer(RenderLayerParent<T, M> renderLayerParent) {
super(renderLayerParent);
}

@Inject(method = "renderArmWithItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemInHandRenderer;renderItem(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/client/renderer/block/model/ItemTransforms$TransformType;ZLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V"))
private void transformItemInHandLayer(LivingEntity livingEntity, ItemStack itemStack, ItemTransforms.TransformType transformType, HumanoidArm humanoidArm, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci){
@Inject(method = "renderArmWithItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemInHandRenderer;renderItem(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemDisplayContext;ZLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V"))
private void transformItemInHandLayer(LivingEntity livingEntity, ItemStack itemStack, ItemDisplayContext itemDisplayContext, HumanoidArm humanoidArm, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci){
if(shouldTransformItemInHand(livingEntity)){


//TODO: Redo how hand stuff works, add override functions to living entity animators.
//update: gosh darnit 1.20 broke something else with this mixin
/*
poseStack.popPose();
poseStack.pushPose();
Expand Down
Expand Up @@ -21,6 +21,7 @@
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import org.spongepowered.asm.mixin.Final;
Expand All @@ -40,7 +41,7 @@ public abstract class MixinItemInHandRenderer {

//@Shadow public abstract void renderItem(LivingEntity livingEntity, ItemStack itemStack, ItemTransforms.TransformType transformType, boolean bl, PoseStack poseStack, MultiBufferSource multiBufferSource, int i);

@Shadow public abstract void renderItem(LivingEntity livingEntity, ItemStack itemStack, ItemTransforms.TransformType transformType, boolean bl, PoseStack poseStack, MultiBufferSource multiBufferSource, int i);
@Shadow public abstract void renderItem(LivingEntity livingEntity, ItemStack itemStack, ItemDisplayContext itemDisplayContext, boolean bl, PoseStack poseStack, MultiBufferSource multiBufferSource, int i);

@Inject(method = "renderHandsWithItems", at = @At("HEAD"), cancellable = true)
private void overwriteItemInHandRendering(float f, PoseStack poseStack, MultiBufferSource.BufferSource bufferSource, LocalPlayer localPlayer, int i, CallbackInfo ci){
Expand All @@ -56,7 +57,7 @@ private void overwriteItemInHandRendering(float f, PoseStack poseStack, MultiBuf
poseStack.mulPose(Axis.ZP.rotationDegrees(180));

AbstractClientPlayer abstractClientPlayer = this.minecraft.player;
RenderSystem.setShaderTexture(0, abstractClientPlayer.getSkinTextureLocation());
//RenderSystem.setShaderTexture(0, abstractClientPlayer.getSkin().texture());
PlayerRenderer playerRenderer = (PlayerRenderer)this.entityRenderDispatcher.getRenderer(abstractClientPlayer);
PlayerModel<AbstractClientPlayer> playerModel = playerRenderer.getModel();

Expand All @@ -65,8 +66,8 @@ private void overwriteItemInHandRendering(float f, PoseStack poseStack, MultiBuf
leftArmPose.transformModelPart(playerModel.leftArm);
playerModel.leftSleeve.copyFrom(playerModel.leftArm);

playerModel.rightArm.render(poseStack, bufferSource.getBuffer(RenderType.entitySolid(abstractClientPlayer.getSkinTextureLocation())), i, OverlayTexture.NO_OVERLAY);
playerModel.rightSleeve.render(poseStack, bufferSource.getBuffer(RenderType.entityTranslucent(abstractClientPlayer.getSkinTextureLocation())), i, OverlayTexture.NO_OVERLAY);
playerModel.rightArm.render(poseStack, bufferSource.getBuffer(RenderType.entitySolid(abstractClientPlayer.getSkin().texture())), i, OverlayTexture.NO_OVERLAY);
playerModel.rightSleeve.render(poseStack, bufferSource.getBuffer(RenderType.entityTranslucent(abstractClientPlayer.getSkin().texture())), i, OverlayTexture.NO_OVERLAY);
//playerModel.leftArm.render(poseStack, bufferSource.getBuffer(RenderType.entitySolid(abstractClientPlayer.getSkinTextureLocation())), i, OverlayTexture.NO_OVERLAY);
//playerModel.leftSleeve.render(poseStack, bufferSource.getBuffer(RenderType.entityTranslucent(abstractClientPlayer.getSkinTextureLocation())), i, OverlayTexture.NO_OVERLAY);

Expand Down Expand Up @@ -112,7 +113,7 @@ private void renderItemInHand(AbstractClientPlayer abstractClientPlayer, ItemSta
poseStack.mulPose(Axis.XP.rotationDegrees(-90.0f));
poseStack.mulPose(Axis.YP.rotationDegrees(180.0f));
poseStack.translate(0F, 2F/16F, -1F/16F);
this.renderItem(abstractClientPlayer, itemStack, humanoidArm == HumanoidArm.LEFT ? ItemTransforms.TransformType.THIRD_PERSON_LEFT_HAND : ItemTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, humanoidArm == HumanoidArm.LEFT, poseStack, multiBufferSource, i);
this.renderItem(abstractClientPlayer, itemStack, humanoidArm == HumanoidArm.LEFT ? ItemDisplayContext.THIRD_PERSON_LEFT_HAND : ItemDisplayContext.THIRD_PERSON_RIGHT_HAND, humanoidArm == HumanoidArm.LEFT, poseStack, multiBufferSource, i);
//this.renderItem(abstractClientPlayer, itemStack, humanoidArm == HumanoidArm.LEFT ? ItemDisplayContext.THIRD_PERSON_LEFT_HAND : ItemDisplayContext.THIRD_PERSON_RIGHT_HAND, humanoidArm == HumanoidArm.LEFT, poseStack, multiBufferSource, i);
poseStack.popPose();
}
Expand Down
Expand Up @@ -6,7 +6,6 @@
import com.trainguy9512.animationoverhaul.util.data.AnimationDataContainer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.components.DebugScreenOverlay;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
Expand All @@ -21,6 +20,8 @@
import java.text.DecimalFormat;
import java.util.*;

//TODO: will have to clean this mess up later, dunno what changed with 1.20 and i don't really care toooo much about the debug gui right now so meh
/*
@Mixin(DebugScreenOverlay.class)
public abstract class MixinDebugScreenOverlay extends GuiComponent {
Expand Down Expand Up @@ -140,3 +141,4 @@ private void testCompassGadget(PoseStack poseStack, CallbackInfo ci){
}
}
}
*/
@@ -1,18 +1,18 @@
package com.trainguy9512.animationoverhaul.mixin.debug;

import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.resources.PlayerSkin;
import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(AbstractClientPlayer.class)
public class MixinAbstractClientPlayer {
@Mixin(PlayerSkin.class)
public class MixinPlayerSkin {

private static final ResourceLocation debugCapeLocation = new ResourceLocation("textures/testcape.png");

@Inject(method = "getCloakTextureLocation", at = @At("HEAD"), cancellable = true)
@Inject(method = "capeTexture", at = @At("HEAD"), cancellable = true)
private void useDebugCapeTexture(CallbackInfoReturnable<ResourceLocation> cir){
cir.setReturnValue(debugCapeLocation);
}
Expand Down
10 changes: 8 additions & 2 deletions src/main/resources/fabric.mod.json
Expand Up @@ -29,9 +29,15 @@
"depends": {
"fabricloader": ">=0.14.11",
"fabric-api": "*",
"minecraft": "1.19.3",
"minecraft": "1.20.2",
"java": ">=17"
},
"suggests": {
}
},
"author": "",
"config": {},
"createAt": "",
"homepage": "",
"identifier": "",
"meta": {}
}
2 changes: 1 addition & 1 deletion src/main/resources/modid.mixins.json
Expand Up @@ -16,7 +16,7 @@
"MixinItemInHandLayer",
"MixinLivingEntity",
"MixinLivingEntityRenderer",
"debug.MixinDebugScreenOverlay",
"debug.MixinPlayerSkin",
"models.MixinPlayerModel"
],
"injectors": {
Expand Down

0 comments on commit b0a72fa

Please sign in to comment.