Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Trainguy9512 committed Mar 10, 2024
1 parent b6b5f57 commit 14ac0d8
Show file tree
Hide file tree
Showing 23 changed files with 61 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.trainguy9512.animationoverhaul;


import com.trainguy9512.animationoverhaul.animation.entity.PlayerPartAnimator;
import com.trainguy9512.animationoverhaul.util.data.LivingEntityAnimatorRegistry;
import com.trainguy9512.animationoverhaul.util.data.TimelineGroupDataLoader;
import com.trainguy9512.animationoverhaul.animation.data.LivingEntityAnimatorRegistry;
import com.trainguy9512.animationoverhaul.animation.data.TimelineGroupDataLoader;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.minecraft.server.packs.PackType;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.trainguy9512.animationoverhaul.AnimationOverhaulMain;
import com.trainguy9512.animationoverhaul.animation.entity.LivingEntityAnimator;
import com.trainguy9512.animationoverhaul.animation.pose.BakedAnimationPose;
import com.trainguy9512.animationoverhaul.util.data.AnimationDataContainer;
import com.trainguy9512.animationoverhaul.animation.data.AnimationDataContainer;
import net.minecraft.client.model.EntityModel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.trainguy9512.animationoverhaul.util.data;
package com.trainguy9512.animationoverhaul.animation.data;

import com.google.common.collect.Maps;
import com.trainguy9512.animationoverhaul.animation.pose.AnimationPose;
Expand All @@ -12,9 +12,9 @@

public class AnimationDataContainer {

private final HashMap<DataKey<?>, Variable<?>> entityAnimationVariables;
private final HashMap<DataKey<?>, AnimationVariable<?>> entityAnimationVariables;
private final HashMap<String, SampleableAnimationState> entitySampleableAnimationStates;
private CachedPoseContainer cachedPoseContainer = new CachedPoseContainer();
private final CachedPoseContainer cachedPoseContainer = new CachedPoseContainer();

public AnimationDataContainer(){
this.entityAnimationVariables = Maps.newHashMap();
Expand Down Expand Up @@ -83,17 +83,17 @@ public AnimationPose<?> getCachedPose(String identifier, LocatorSkeleton<?> loca
}
}

public <D> Variable<D> get(DataKey<D> dataKey){
public <D> AnimationVariable<D> get(DataKey<D> dataKey){
if(!entityAnimationVariables.containsKey(dataKey)){
entityAnimationVariables.put(dataKey, new Variable<>(dataKey));
entityAnimationVariables.put(dataKey, new AnimationVariable<>(dataKey));
}
return (Variable<D>) entityAnimationVariables.get(dataKey);
return (AnimationVariable<D>) entityAnimationVariables.get(dataKey);
}

public TreeMap<String, Variable<?>> getDebugData(){
TreeMap<String, Variable<?>> finalList = Maps.newTreeMap();
public TreeMap<String, AnimationVariable<?>> getDebugData(){
TreeMap<String, AnimationVariable<?>> finalList = Maps.newTreeMap();
for(DataKey<?> dataKey : this.entityAnimationVariables.keySet()){
Variable<?> data = entityAnimationVariables.get(dataKey);
AnimationVariable<?> data = entityAnimationVariables.get(dataKey);

String[] typeSplitted = data.get().getClass().toString().split("\\.");
String type = typeSplitted[typeSplitted.length - 1];
Expand Down Expand Up @@ -161,7 +161,7 @@ public float getDataValueEasedCondition(AnimationDataContainer.DataKey<Float> da
public void incrementInTicksFromCondition(DataKey<Float> dataKey, boolean condition, float ticksToIncrement, float ticksToDecrement){
ticksToIncrement = Math.max(1, ticksToIncrement);
ticksToDecrement = Math.max(1, ticksToDecrement);
Variable<Float> data = this.get(dataKey);
AnimationVariable<Float> data = this.get(dataKey);
data.set(Mth.clamp((data.get()) + (condition ? 1/ticksToIncrement : -1/ticksToDecrement), 0, 1));
}

Expand All @@ -186,7 +186,7 @@ public void incrementInFramesFromCondition(DataKey<Float> dataKey, boolean condi
* @param ticksToIncrement Time in ticks to increment from 0 to 1
*/
public void incrementInTicksOrResetFromCondition(DataKey<Float> dataKey, boolean condition, float ticksToIncrement){
Variable<Float> data = this.get(dataKey);
AnimationVariable<Float> data = this.get(dataKey);
if(condition){
data.set(0F);
data.set(0F);
Expand Down Expand Up @@ -218,8 +218,8 @@ public void incrementInFramesOrResetFromCondition(DataKey<Float> dataKey, boolea
* @param random Java random object used to pick a random index within numberOfAnimations
*/
public void incrementInTicksOrResetRandomFromCondition(DataKey<Float> dataKeyMain, DataKey<Integer> dataKeyIndex, int numberOfAnimations, boolean condition, float ticksToIncrement, Random random){
Variable<Float> dataMain = this.get(dataKeyMain);
Variable<Integer> dataIndex = this.get(dataKeyIndex);
AnimationVariable<Float> dataMain = this.get(dataKeyMain);
AnimationVariable<Integer> dataIndex = this.get(dataKeyIndex);
if(condition){
dataMain.set(0F);
dataMain.set(0F);
Expand Down Expand Up @@ -258,13 +258,13 @@ public String getIdentifier(){
}
}

public static class Variable<D>{
public static class AnimationVariable<D>{

private D value;
private D valueOld;
private final D defaultValue;

public Variable(DataKey<D> dataKey){
public AnimationVariable(DataKey<D> dataKey){
this.value = dataKey.defaultValue;
this.valueOld = dataKey.defaultValue;
this.defaultValue = dataKey.defaultValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.trainguy9512.animationoverhaul.animation.data;

import java.util.function.Supplier;

public class AnimationDataKey<D> {

private final Supplier<D> defaultValue;

public AnimationDataKey(Supplier<D> defaultValue) {
this.defaultValue = defaultValue;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.trainguy9512.animationoverhaul.util.data;
package com.trainguy9512.animationoverhaul.animation.data;

import com.google.common.collect.Maps;
import com.trainguy9512.animationoverhaul.animation.entity.LivingEntityAnimator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.trainguy9512.animationoverhaul.util.data;
package com.trainguy9512.animationoverhaul.animation.data;

import com.google.common.collect.Maps;
import com.trainguy9512.animationoverhaul.AnimationOverhaulMain;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.trainguy9512.animationoverhaul.util.data;
package com.trainguy9512.animationoverhaul.animation.data;

import com.google.common.collect.Maps;
import com.google.gson.Gson;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.trainguy9512.animationoverhaul.util.data;
package com.trainguy9512.animationoverhaul.animation.data;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package com.trainguy9512.animationoverhaul.animation.entity;

import com.trainguy9512.animationoverhaul.AnimationOverhaulMain;
import com.trainguy9512.animationoverhaul.animation.pose.AnimationPose;
import com.trainguy9512.animationoverhaul.animation.pose.BakedAnimationPose;
import com.trainguy9512.animationoverhaul.animation.pose.sample.*;
import com.trainguy9512.animationoverhaul.util.animation.LocatorSkeleton;
import com.trainguy9512.animationoverhaul.util.data.AnimationDataContainer;
import com.trainguy9512.animationoverhaul.util.data.TimelineGroupData;
import com.trainguy9512.animationoverhaul.animation.data.AnimationDataContainer;
import com.trainguy9512.animationoverhaul.animation.data.TimelineGroupData;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.PlayerModel;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.AnimationState;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import org.joml.Vector3f;
Expand Down Expand Up @@ -328,9 +326,12 @@ private AnimationPose<FPPlayerLocators> getStaticMainBasicItemPose(){
*/


public void tick(LivingEntity livingEntity, AnimationDataContainer entityAnimationData){




this.setEntityAnimationVariable(TIME_TEST, this.getEntityAnimationVariable(TIME_TEST) + 1);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.trainguy9512.animationoverhaul.animation.pose.BakedAnimationPose;
import com.trainguy9512.animationoverhaul.animation.pose.sample.*;
import com.trainguy9512.animationoverhaul.util.animation.LocatorSkeleton;
import com.trainguy9512.animationoverhaul.util.data.AnimationDataContainer;
import com.trainguy9512.animationoverhaul.animation.data.AnimationDataContainer;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.world.entity.LivingEntity;
Expand Down Expand Up @@ -54,7 +54,7 @@ protected AnimationDataContainer getEntityAnimationData(){
return this.entityAnimationData;
}

protected <D> AnimationDataContainer.Variable<D> getEntityAnimationVariableObject(AnimationDataContainer.DataKey<D> dataKey){
protected <D> AnimationDataContainer.AnimationVariable<D> getEntityAnimationVariableObject(AnimationDataContainer.DataKey<D> dataKey){
return getEntityAnimationData().get(dataKey);
}

Expand Down Expand Up @@ -90,7 +90,12 @@ protected float getWalkAnimationSpeed(){
}

protected float getWalkAnimationPosition(){




return this.livingEntity.walkAnimation.position();

}

public void tick(LivingEntity livingEntity){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
package com.trainguy9512.animationoverhaul.animation.entity;

import com.trainguy9512.animationoverhaul.AnimationOverhaulMain;
import com.trainguy9512.animationoverhaul.animation.pose.AnimationPose;
import com.trainguy9512.animationoverhaul.animation.pose.sample.AnimationBlendSpacePlayer;
import com.trainguy9512.animationoverhaul.animation.pose.sample.AnimationSequencePlayer;
import com.trainguy9512.animationoverhaul.animation.pose.sample.AnimationStateMachine;
import com.trainguy9512.animationoverhaul.util.animation.LocatorSkeleton;
import com.trainguy9512.animationoverhaul.util.data.AnimationDataContainer;
import com.trainguy9512.animationoverhaul.util.data.TimelineGroupData;
import com.trainguy9512.animationoverhaul.util.time.TickTimeUtils;
import com.trainguy9512.animationoverhaul.animation.data.AnimationDataContainer;
import net.minecraft.client.model.PlayerModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;

import java.util.List;

public class PlayerPartAnimator extends LivingEntityAnimator<Player, PlayerModel<Player>, PlayerPartAnimator.ModelPartLocators> {

private static final String MODEL_PART_ROOT = "root";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.trainguy9512.animationoverhaul.animation.pose;

import com.mojang.blaze3d.vertex.PoseStack;
import com.trainguy9512.animationoverhaul.util.data.TimelineGroupData;
import com.trainguy9512.animationoverhaul.util.data.TransformChannel;
import com.trainguy9512.animationoverhaul.animation.data.TimelineGroupData;
import com.trainguy9512.animationoverhaul.animation.data.TransformChannel;
import com.trainguy9512.animationoverhaul.util.time.ChannelTimeline;
import com.trainguy9512.animationoverhaul.util.time.Easing;
import net.minecraft.client.model.geom.ModelPart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.trainguy9512.animationoverhaul.animation.pose.AnimationPose;
import com.trainguy9512.animationoverhaul.util.animation.LocatorSkeleton;
import com.trainguy9512.animationoverhaul.util.data.AnimationDataContainer;
import com.trainguy9512.animationoverhaul.util.data.TimelineGroupData;
import com.trainguy9512.animationoverhaul.animation.data.AnimationDataContainer;
import com.trainguy9512.animationoverhaul.animation.data.TimelineGroupData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.trainguy9512.animationoverhaul.animation.pose.AnimationPose;
import com.trainguy9512.animationoverhaul.util.animation.LocatorSkeleton;
import com.trainguy9512.animationoverhaul.util.data.TimelineGroupData;
import com.trainguy9512.animationoverhaul.animation.data.TimelineGroupData;
import com.trainguy9512.animationoverhaul.util.time.Easing;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.trainguy9512.animationoverhaul.animation.pose.AnimationPose;
import com.trainguy9512.animationoverhaul.util.animation.LocatorSkeleton;
import com.trainguy9512.animationoverhaul.util.data.AnimationDataContainer;
import com.trainguy9512.animationoverhaul.animation.data.AnimationDataContainer;
import net.minecraft.util.Mth;
import java.util.ArrayList;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
import com.google.common.collect.Maps;
import com.trainguy9512.animationoverhaul.animation.pose.AnimationPose;
import com.trainguy9512.animationoverhaul.util.animation.LocatorSkeleton;
import com.trainguy9512.animationoverhaul.util.data.AnimationDataContainer;
import com.trainguy9512.animationoverhaul.util.data.TimelineGroupData;
import com.trainguy9512.animationoverhaul.util.time.TickTimeUtils;
import com.trainguy9512.animationoverhaul.animation.data.AnimationDataContainer;
import com.trainguy9512.animationoverhaul.animation.data.TimelineGroupData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;

import java.util.HashMap;
import java.util.List;

public class AnimationSequencePlayer extends TimeBasedAnimationState {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.trainguy9512.animationoverhaul.AnimationOverhaulMain;
import com.trainguy9512.animationoverhaul.animation.pose.AnimationPose;
import com.trainguy9512.animationoverhaul.util.animation.LocatorSkeleton;
import com.trainguy9512.animationoverhaul.util.data.AnimationDataContainer;
import com.trainguy9512.animationoverhaul.animation.data.AnimationDataContainer;
import com.trainguy9512.animationoverhaul.util.time.Easing;
import net.minecraft.util.Mth;
import org.jetbrains.annotations.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.trainguy9512.animationoverhaul.animation.pose.AnimationPose;
import com.trainguy9512.animationoverhaul.util.animation.LocatorSkeleton;
import com.trainguy9512.animationoverhaul.util.data.AnimationDataContainer;
import com.trainguy9512.animationoverhaul.animation.data.AnimationDataContainer;

public class SampleableAnimationState {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.trainguy9512.animationoverhaul.animation.pose.AnimationPose;
import com.trainguy9512.animationoverhaul.util.animation.LocatorSkeleton;
import com.trainguy9512.animationoverhaul.util.data.AnimationDataContainer;
import com.trainguy9512.animationoverhaul.animation.data.AnimationDataContainer;

public class TestReferenceSampler extends SampleableAnimationState {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
package com.trainguy9512.animationoverhaul.mixin.debug;

import com.mojang.blaze3d.vertex.PoseStack;
import com.trainguy9512.animationoverhaul.AnimationOverhaulMain;
import com.trainguy9512.animationoverhaul.animation.AnimatorDispatcher;
import com.trainguy9512.animationoverhaul.util.data.AnimationDataContainer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.components.DebugScreenOverlay;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.phys.HitResult;
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;

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.joml.Quaternionf;
import org.joml.Vector3f;

@Deprecated
public class RotationMatrix {
public float[][] matrixGrid;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.trainguy9512.animationoverhaul.util.time;

import com.trainguy9512.animationoverhaul.util.data.TransformChannel;
import com.trainguy9512.animationoverhaul.animation.data.TransformChannel;
import net.minecraft.util.Mth;
import org.joml.Quaternionf;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.trainguy9512.animationoverhaul.util.time;

import com.trainguy9512.animationoverhaul.util.data.TimelineGroupData;
import com.trainguy9512.animationoverhaul.animation.data.TimelineGroupData;
import net.minecraft.util.Mth;

@Deprecated
Expand Down

0 comments on commit 14ac0d8

Please sign in to comment.