From 24c13dab8928a0db27545cead5f86cc06e18b823 Mon Sep 17 00:00:00 2001 From: jacquerol Date: Mon, 21 Nov 2022 00:37:36 -0300 Subject: [PATCH] Added PlayerEntityRendererMixin - Added crossbow animation to potato cannon and zapper - Updated potato cannon model to fit animation --- .../mixin/PlayerEntityRendererMixin.java | 31 +++++++++++++++++++ .../models/item/potato_cannon/item.json | 16 +++++----- src/main/resources/create.mixins.json | 2 +- 3 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/simibubi/create/foundation/mixin/PlayerEntityRendererMixin.java diff --git a/src/main/java/com/simibubi/create/foundation/mixin/PlayerEntityRendererMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/PlayerEntityRendererMixin.java new file mode 100644 index 000000000..f3ceebfca --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/mixin/PlayerEntityRendererMixin.java @@ -0,0 +1,31 @@ +package com.simibubi.create.foundation.mixin; + +import com.simibubi.create.content.curiosities.zapper.ZapperItem; + +import net.minecraft.world.item.Item; + +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; + +import com.simibubi.create.content.curiosities.weapons.PotatoCannonItem; +import net.minecraft.client.model.HumanoidModel; +import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.client.renderer.entity.player.PlayerRenderer; +import net.minecraft.world.InteractionHand; + +@Mixin(PlayerRenderer.class) +public class PlayerEntityRendererMixin { + @Inject( + method = "getArmPose", + at = @At("HEAD"), + cancellable = true + ) + private static void getArmPose(AbstractClientPlayer player, InteractionHand hand, CallbackInfoReturnable ci) { + Item handItem = player.getItemInHand(hand).getItem(); + if (!player.swinging && (handItem instanceof PotatoCannonItem || handItem instanceof ZapperItem)) + ci.setReturnValue(HumanoidModel.ArmPose.CROSSBOW_HOLD); + } +} + diff --git a/src/main/resources/assets/create/models/item/potato_cannon/item.json b/src/main/resources/assets/create/models/item/potato_cannon/item.json index 282afdd16..a7388ac31 100644 --- a/src/main/resources/assets/create/models/item/potato_cannon/item.json +++ b/src/main/resources/assets/create/models/item/potato_cannon/item.json @@ -96,18 +96,20 @@ ], "display": { "thirdperson_righthand": { - "translation": [0, 2, 0] + "rotation": [0, -15, 0], + "translation": [0, 0, -4] }, "thirdperson_lefthand": { - "translation": [0, 2, 0] + "rotation": [0, -15, 0], + "translation": [0, 0, -4] }, "firstperson_righthand": { - "rotation": [5, 4, 5], - "translation": [0.25, 4, 0.75] + "rotation": [5, 5, 5], + "translation": [0.25, 5, 0.75] }, "firstperson_lefthand": { - "rotation": [5, 4, 5], - "translation": [0.25, 4, 0.75] + "rotation": [5, 5, 5], + "translation": [0.25, 5, 0.75] }, "ground": { "rotation": [0, 0, 90], @@ -129,4 +131,4 @@ "scale": [0.72, 0.72, 0.72] } } -} \ No newline at end of file +} diff --git a/src/main/resources/create.mixins.json b/src/main/resources/create.mixins.json index 14c2d3a77..89ebb960b 100644 --- a/src/main/resources/create.mixins.json +++ b/src/main/resources/create.mixins.json @@ -9,7 +9,6 @@ "ContraptionDriverInteractMixin", "CustomItemUseEffectsMixin", "MapItemSavedDataMixin", - "ContraptionDriverInteractMixin", "accessor.AbstractProjectileDispenseBehaviorAccessor", "accessor.DispenserBlockAccessor", "accessor.FallingBlockEntityAccessor", @@ -25,6 +24,7 @@ "HeavyBootsOnPlayerMixin", "LevelRendererMixin", "MapRendererMapInstanceMixin", + "PlayerEntityRendererMixin", "ModelDataRefreshMixin", "WindowResizeMixin", "accessor.AgeableListModelAccessor",