mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 08:14:23 +01:00
Fixed spyglass positioning
This commit is contained in:
parent
dc34a8098a
commit
dc20a7f087
3 changed files with 19 additions and 18 deletions
|
@ -534,18 +534,8 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
UseAction action = state.attributes.heldStack.getUseAction();
|
||||
|
||||
if (action == UseAction.SPYGLASS && state.attributes.itemUseTime > 0) {
|
||||
|
||||
Arm main = state.attributes.mainArm;
|
||||
if (state.attributes.activeHand == Hand.OFF_HAND) {
|
||||
main = main.getOpposite();
|
||||
}
|
||||
if (main == arm) {
|
||||
matrices.translate(left * -0.05F, 0.5F, 0.2F);
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-60));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
matrices.translate(-left * 0.1F, 0.45F, 0);
|
||||
|
||||
|
|
|
@ -87,11 +87,15 @@ public class UnicornModel<T extends PonyRenderState> extends EarthPonyModel<T> {
|
|||
|
||||
float left = arm == Arm.LEFT ? -1 : 1;
|
||||
|
||||
UseAction action = state.attributes.heldStack.getUseAction();
|
||||
if (action == UseAction.SPYGLASS && state.attributes.itemUseTime > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
matrices.translate(0.4F - (0.3F * left), -0.675F, -0.3F);
|
||||
|
||||
UseAction action = state.attributes.heldStack.getUseAction();
|
||||
boolean shouldAimItem =
|
||||
(action == UseAction.SPYGLASS || action == UseAction.BOW) && state.attributes.itemUseTime > 0
|
||||
(action == UseAction.BOW) && state.attributes.itemUseTime > 0
|
||||
|| PonyConfig.getInstance().forwardHoldingItems.get().contains(Registries.ITEM.getId(state.attributes.heldStack.getItem()));
|
||||
|
||||
if (shouldAimItem) {
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraft.client.util.math.MatrixStack;
|
|||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ModelTransformationMode;
|
||||
import net.minecraft.item.consume.UseAction;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
|
@ -74,18 +75,24 @@ public class HeldItemFeature<
|
|||
item.set(DataComponentTypes.ENCHANTMENT_GLINT_OVERRIDE, false);
|
||||
}
|
||||
|
||||
boolean noTransform = state.attributes.heldStack.getUseAction() == UseAction.SPYGLASS && state.attributes.itemUseTime > 0;
|
||||
|
||||
float driftStrength = 0.002F;
|
||||
float xDrift = MathHelper.sin(state.age / 10F) * driftStrength;
|
||||
float zDrift = MathHelper.cos((state.age + 20) / 10F) * driftStrength;
|
||||
|
||||
float scale = 1.1F + (MathHelper.sin(state.age / 20F) + 1) * driftStrength;
|
||||
matrices.scale(scale, scale, scale);
|
||||
matrices.translate(0.045F + xDrift, 0.01F - 0.12F, 0.03F + zDrift);
|
||||
|
||||
matrices.scale(scale, scale, scale);
|
||||
if (!noTransform) {
|
||||
matrices.translate(0.045F + xDrift, 0.01F - 0.12F, 0.03F + zDrift);
|
||||
}
|
||||
renderItem((PlayerEntityRenderState)state, model, item, mode, arm, matrices, vertices, light);
|
||||
if (!noTransform) {
|
||||
matrices.scale(scale, scale, scale);
|
||||
matrices.translate(0.1F, -0.1F, 0.1F);
|
||||
matrices.translate(-0.03F - xDrift, -0.02F, -0.02F - zDrift);
|
||||
}
|
||||
renderItem((PlayerEntityRenderState)state, model, item, mode, arm, matrices, vertices, light);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue