Skip to content

Commit

Permalink
Merge branch 'vanillaHandsRework' into vanillaHandsRework
Browse files Browse the repository at this point in the history
  • Loading branch information
YoungSoulluoS authored Mar 21, 2024
2 parents ca5143c + fb0de4e commit e66c92a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class FirstPersonSettings {
public VanillaHands vanillaHandsMode = VanillaHands.OFF;
public boolean dynamicMode = true;


public Set<String> autoVanillaHands = new HashSet<>(Arrays.asList("antiqueatlas:antique_atlas",
"twilightforest:filled_magic_map", "twilightforest:filled_maze_map", "twilightforest:filled_ore_map",
"create:potato_cannon", "create:extendo_grip", "create:handheld_worldshaper", "map_atlases:atlas"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package dev.tr7zw.firstperson.versionless.config;

public enum VanillaHands {
OFF, ALL, ALL_DOUBLE, ITEMS;
OFF, ALL, ALL_DOUBLE, ITEMS;
}
6 changes: 3 additions & 3 deletions src/main/java/dev/tr7zw/firstperson/LogicHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public boolean hideArmsAndItems(LivingEntity livingEntity) {
* @return
*/
public boolean hideArmsAndItems(ItemStack mainhand, ItemStack offhand) {
if(lookingDown()) {
if (lookingDown()) {
return false;
}
return fpm.getConfig().vanillaHandsMode != VanillaHands.OFF || autoVanillaHandItems.contains(mainhand.getItem())
Expand All @@ -228,15 +228,15 @@ public boolean hideArmsAndItems(ItemStack mainhand, ItemStack offhand) {
public boolean dynamicHandsEnabled() {
return dynamicHandsEnabled(client.player);
}

public boolean dynamicHandsEnabled(LivingEntity livingEntity) {
if (livingEntity instanceof PlayerAccess playerAccess) {
return dynamicHandsEnabled(playerAccess.getInventory().getSelected(),
playerAccess.getInventory().offhand.get(0));
}
return false;
}

/**
* True is dynamic hands is enabled and could apply at this moment
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ private void renderArmWithItem(LivingEntity livingEntity, ItemStack itemStack, I
//#endif
//spotless:on
if (livingEntity instanceof LocalPlayer && FirstPersonModelCore.instance.isRenderingPlayer()) {
if (FirstPersonModelCore.instance.getLogicHandler().hideArmsAndItems(livingEntity) && !FirstPersonModelCore.instance.getLogicHandler().lookingDown()) {
if (FirstPersonModelCore.instance.getLogicHandler().hideArmsAndItems(livingEntity)
&& !FirstPersonModelCore.instance.getLogicHandler().lookingDown()) {
ci.cancel();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import dev.tr7zw.firstperson.FirstPersonModelCore;
import dev.tr7zw.firstperson.versionless.config.VanillaHands;
import dev.tr7zw.util.NMSHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.player.LocalPlayer;
Expand Down Expand Up @@ -91,12 +92,12 @@ public abstract void renderPlayerArm(PoseStack matrices, MultiBufferSource verte
*/

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getAttackStrengthScale(F)F", shift = At.Shift.BEFORE), method = "tick", cancellable = true)
public void tick(CallbackInfo ci) {//TODO DYNAMIC HAND
public void tick(CallbackInfo ci) {// TODO DYNAMIC HAND
if (FirstPersonModelCore.instance.isEnabled()
&& FirstPersonModelCore.instance.getLogicHandler().showVanillaHands()
&& FirstPersonModelCore.instance.getLogicHandler().dynamicHandsEnabled()) {
LocalPlayer localPlayer = Minecraft.getInstance().player;
float f = localPlayer.getXRot();
float f = NMSHelper.getXRot(localPlayer);
if (f > 15) {
if (f < 30) {
this.mainHandHeight = 15 / f;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.tr7zw.firstperson.mixins;

import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
import net.minecraft.world.item.Items;
import org.joml.Vector3f;
Expand All @@ -19,6 +18,7 @@
import dev.tr7zw.firstperson.access.PlayerAccess;
import dev.tr7zw.firstperson.access.PlayerModelAccess;
import dev.tr7zw.firstperson.versionless.mixinbase.ModelPartBase;
import dev.tr7zw.util.NMSHelper;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.HeadedModel;
import net.minecraft.client.model.HumanoidModel;
Expand Down Expand Up @@ -57,13 +57,15 @@ public void renderPostAnim(LivingEntity livingEntity, float f, float g, PoseStac
if (FirstPersonModelCore.instance.getLogicHandler().hideArmsAndItems(livingEntity)) {
((ModelPartBase) (Object) humanModel.leftArm).setHidden();
((ModelPartBase) (Object) humanModel.rightArm).setHidden();
} else if(FirstPersonModelCore.instance.getLogicHandler().dynamicHandsEnabled()) {//TODO VANILLA HANDS ITEM
float offset = Mth.clamp(-Minecraft.getInstance().player.getXRot() / 20 + 2, -0.0f, 0.7f);
} else if (FirstPersonModelCore.instance.getLogicHandler().dynamicHandsEnabled()) {// TODO VANILLA HANDS
// ITEM
float offset = Mth.clamp(-NMSHelper.getXRot(Minecraft.getInstance().player) / 20 + 2, -0.0f, 0.7f);
humanModel.rightArm.offsetRotation(new Vector3f(offset, 0, 0));
humanModel.leftArm.offsetRotation(new Vector3f(offset, 0, 0));

if (!FirstPersonModelCore.instance.getLogicHandler().lookingDown()) {//TODO DYNAMIC HAND
if (!playerAccess.getInventory().offhand.get(0).isEmpty() || livingEntity.getMainHandItem().getItem().equals(Items.FILLED_MAP)) {
if (!FirstPersonModelCore.instance.getLogicHandler().lookingDown()) {// TODO DYNAMIC HAND
if (!playerAccess.getInventory().offhand.get(0).isEmpty()
|| livingEntity.getMainHandItem().getItem().equals(Items.FILLED_MAP)) {
((ModelPartBase) (Object) humanModel.leftArm).setHidden();
}
if (!playerAccess.getInventory().getSelected().isEmpty()) {
Expand All @@ -79,16 +81,18 @@ public void renderPostAnim(LivingEntity livingEntity, float f, float g, PoseStac
headShouldBeHidden = true;
((ModelPartBase) (Object) playerModel.hat).setHidden();
if (livingEntity instanceof PlayerAccess playerAccess) {
if(FirstPersonModelCore.instance.getLogicHandler().hideArmsAndItems(livingEntity)) {
if (FirstPersonModelCore.instance.getLogicHandler().hideArmsAndItems(livingEntity)) {
((ModelPartBase) (Object) playerModel.leftSleeve).setHidden();
((ModelPartBase) (Object) playerModel.rightSleeve).setHidden();
} else if(FirstPersonModelCore.instance.getLogicHandler().dynamicHandsEnabled()) {//TODO VANILLA HANDS ITEM
float offset = Mth.clamp(-Minecraft.getInstance().player.getXRot()/20+2,-0.0f,0.7f);
playerModel.rightSleeve.offsetRotation(new Vector3f(offset,0,0));
playerModel.leftSleeve.offsetRotation(new Vector3f(offset,0,0));
} else if (FirstPersonModelCore.instance.getLogicHandler().dynamicHandsEnabled()) {// TODO VANILLA HANDS
// ITEM
float offset = Mth.clamp(-NMSHelper.getXRot(Minecraft.getInstance().player) / 20 + 2, -0.0f, 0.7f);
playerModel.rightSleeve.offsetRotation(new Vector3f(offset, 0, 0));
playerModel.leftSleeve.offsetRotation(new Vector3f(offset, 0, 0));

if (!FirstPersonModelCore.instance.getLogicHandler().lookingDown()) {//TODO DYNAMIC HAND
if (!playerAccess.getInventory().offhand.get(0).isEmpty() || livingEntity.getMainHandItem().getItem().equals(Items.FILLED_MAP)) {
if (!FirstPersonModelCore.instance.getLogicHandler().lookingDown()) {// TODO DYNAMIC HAND
if (!playerAccess.getInventory().offhand.get(0).isEmpty()
|| livingEntity.getMainHandItem().getItem().equals(Items.FILLED_MAP)) {
((ModelPartBase) (Object) playerModel.leftSleeve).setHidden();
}
if (!playerAccess.getInventory().getSelected().isEmpty()) {
Expand Down Expand Up @@ -125,12 +129,13 @@ public void renderReturn(LivingEntity livingEntity, float f, float g, PoseStack
((ModelPartBase) (Object) headed.getHead()).showAgain();
}
if (model instanceof HumanoidModel<?> humanModel) {
if(FirstPersonModelCore.instance.getLogicHandler().showVanillaHands()
if (FirstPersonModelCore.instance.getLogicHandler().showVanillaHands()
&& !FirstPersonModelCore.instance.getLogicHandler().showVanillaHands()) {
((ModelPartBase) (Object) humanModel.leftArm).showAgain();
((ModelPartBase) (Object) humanModel.rightArm).showAgain();
} else if (FirstPersonModelCore.instance.getLogicHandler().dynamicHandsEnabled()) {//TODO VANILLA HANDS ITEM
if (!FirstPersonModelCore.instance.getLogicHandler().lookingDown()) {//TODO DYNAMIC HAND
} else if (FirstPersonModelCore.instance.getLogicHandler().dynamicHandsEnabled()) {// TODO VANILLA HANDS
// ITEM
if (!FirstPersonModelCore.instance.getLogicHandler().lookingDown()) {// TODO DYNAMIC HAND
((ModelPartBase) (Object) humanModel.leftArm).showAgain();
((ModelPartBase) (Object) humanModel.rightArm).showAgain();
} else {
Expand All @@ -149,7 +154,8 @@ public void renderReturn(LivingEntity livingEntity, float f, float g, PoseStack
if (FirstPersonModelCore.instance.getLogicHandler().showVanillaHands()) {
((ModelPartBase) (Object) playerModel.leftSleeve).showAgain();
((ModelPartBase) (Object) playerModel.rightSleeve).showAgain();
} else if (FirstPersonModelCore.instance.getLogicHandler().dynamicHandsEnabled()) {//TODO VANILLA HANDS ITEM
} else if (FirstPersonModelCore.instance.getLogicHandler().dynamicHandsEnabled()) {// TODO VANILLA HANDS
// ITEM
if (!livingEntity.getOffhandItem().isEmpty())
((ModelPartBase) (Object) playerModel.leftSleeve).showAgain();
if (!livingEntity.getMainHandItem().isEmpty())
Expand Down

0 comments on commit e66c92a

Please sign in to comment.