-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de94a78
commit 941c391
Showing
19 changed files
with
333 additions
and
510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
src/main/java/com/trainguy9512/animationoverhaul/animation/LivingEntityAnimatorRegistry.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...ain/java/com/trainguy9512/animationoverhaul/animation/animator/JointAnimatorRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.trainguy9512.animationoverhaul.animation.animator; | ||
|
||
import com.google.common.collect.Maps; | ||
import com.trainguy9512.animationoverhaul.animation.animator.entity.EntityJointAnimator; | ||
import com.trainguy9512.animationoverhaul.animation.animator.entity.LivingEntityJointAnimator; | ||
import com.trainguy9512.animationoverhaul.animation.pose.JointSkeleton; | ||
import net.minecraft.client.player.LocalPlayer; | ||
import net.minecraft.client.renderer.entity.state.PlayerRenderState; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.EntityType; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.HashMap; | ||
|
||
public class JointAnimatorRegistry { | ||
|
||
private static final HashMap<EntityType<?>, EntityJointAnimator<?, ?>> THIRD_PERSON_ENTITY_JOINT_ANIMATORS = Maps.newHashMap(); | ||
private static final HashMap<EntityType<?>, JointSkeleton> THIRD_PERSON_ENTITY_JOINT_SKELETONS = Maps.newHashMap(); | ||
|
||
private static LivingEntityJointAnimator<LocalPlayer, PlayerRenderState> FIRST_PERSON_PLAYER_JOINT_ANIMATOR = null; | ||
private static JointSkeleton FIRST_PERSON_PLAYER_JOINT_SKELETON = null; | ||
|
||
/** | ||
* Registers a joint animator for use on third person living entities. | ||
* @param entityType Type of entity associated with the living entity | ||
* @param entityJointAnimator Newly constructed entity joint animator object | ||
*/ | ||
public static <T extends Entity> void registerEntityJointAnimator(EntityType<T> entityType, EntityJointAnimator<T, ?> entityJointAnimator){ | ||
THIRD_PERSON_ENTITY_JOINT_ANIMATORS.put(entityType, entityJointAnimator); | ||
THIRD_PERSON_ENTITY_JOINT_SKELETONS.put(entityType, entityJointAnimator.buildSkeleton()); | ||
} | ||
|
||
|
||
public static void registerFirstPersonPlayerJointAnimator(LivingEntityJointAnimator<LocalPlayer, PlayerRenderState> firstPersonPlayerJointAnimator){ | ||
FIRST_PERSON_PLAYER_JOINT_ANIMATOR = firstPersonPlayerJointAnimator; | ||
FIRST_PERSON_PLAYER_JOINT_SKELETON = firstPersonPlayerJointAnimator.buildSkeleton(); | ||
} | ||
|
||
/** | ||
* Returns whether the provided entity type has a registered joint animator. | ||
* @param entityType Entity type | ||
*/ | ||
public static boolean entityTypeRegisteredWithJointAnimator(EntityType<?> entityType){ | ||
return THIRD_PERSON_ENTITY_JOINT_ANIMATORS.containsKey(entityType); | ||
} | ||
|
||
/** | ||
* Returns the entity joint animator for the provided entity type. If the entity type does not have a joint animator registered, null is returned. | ||
* @param entityType Entity type | ||
* @return Entity joint animator | ||
*/ | ||
@Nullable | ||
@SuppressWarnings("unchecked") | ||
public static <T extends Entity> EntityJointAnimator<T, ?> getThirdPersonJointAnimator(EntityType<T> entityType){ | ||
return (EntityJointAnimator<T, ?>) THIRD_PERSON_ENTITY_JOINT_ANIMATORS.get(entityType); | ||
} | ||
|
||
/** | ||
* Returns a joint skeleton for the provided entity type. If the entity type does not have a joint animator registered, null is returned. | ||
* @param entityType Entity type | ||
* @return Joint skeleton | ||
*/ | ||
@Nullable | ||
public static JointSkeleton getThirdPersonJointSkeleton(EntityType<?> entityType){ | ||
return THIRD_PERSON_ENTITY_JOINT_SKELETONS.get(entityType); | ||
} | ||
|
||
/** | ||
* Returns the first person player joint animator, if it has been registered. If not, it returns null. | ||
*/ | ||
@Nullable | ||
public static LivingEntityJointAnimator<LocalPlayer, PlayerRenderState> getFirstPersonPlayerJointAnimator(){ | ||
return FIRST_PERSON_PLAYER_JOINT_ANIMATOR; | ||
} | ||
|
||
/** | ||
* Returns the first person player joint skeleton, if it has been registered. If not, it returns null. | ||
*/ | ||
@Nullable | ||
public static JointSkeleton getFirstPersonPlayerJointSkeleton(){ | ||
return FIRST_PERSON_PLAYER_JOINT_SKELETON; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.