|
49 | 49 |
|
50 | 50 | @Mixin(ItemStackRenderState.LayerRenderState.class) |
51 | 51 | public abstract class MixinItemStackRenderLayerState { |
52 | | - @Shadow |
53 | | - ItemTransform transform; |
| 52 | + @Shadow |
| 53 | + ItemTransform transform; |
54 | 54 |
|
55 | | - @Shadow |
56 | | - @Final |
57 | | - ItemStackRenderState field_55345; // ItemStackRenderState.this |
| 55 | + @Shadow(aliases = "field_55345") // ItemStackRenderState.this |
| 56 | + @Final |
| 57 | + ItemStackRenderState itemStackRenderState; |
58 | 58 |
|
59 | | - @ModifyArg(method = "submit", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitItem(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/item/ItemDisplayContext;III[ILjava/util/List;Lnet/minecraft/client/renderer/RenderType;Lnet/minecraft/client/renderer/item/ItemStackRenderState$FoilType;)V"), index = 8) |
60 | | - private ItemStackRenderState.FoilType animatium$disableGlintOn2DItems(ItemStackRenderState.FoilType glint) { |
61 | | - final boolean glintDropped = !AnimatiumConfig.instance().items.glintOnItemDrops2D; |
62 | | - final boolean glintFramed = !AnimatiumConfig.instance().items.glintOnItemFramed2D; |
63 | | - if (Animatium.isEnabled() && |
64 | | - (glintDropped && field_55345.displayContext == ItemDisplayContext.GROUND) || |
65 | | - (glintFramed && field_55345.displayContext == ItemDisplayContext.FIXED)) { |
66 | | - return ItemStackRenderState.FoilType.NONE; |
67 | | - } else { |
68 | | - return glint; |
69 | | - } |
70 | | - } |
| 59 | + @ModifyArg(method = "submit", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitItem(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/item/ItemDisplayContext;III[ILjava/util/List;Lnet/minecraft/client/renderer/RenderType;Lnet/minecraft/client/renderer/item/ItemStackRenderState$FoilType;)V"), index = 8) |
| 60 | + private ItemStackRenderState.FoilType animatium$disableGlintOn2DItems(ItemStackRenderState.FoilType glint) { |
| 61 | + final boolean glintDropped = !AnimatiumConfig.instance().items.glintOnItemDrops2D; |
| 62 | + final boolean glintFramed = !AnimatiumConfig.instance().items.glintOnItemFramed2D; |
| 63 | + if (Animatium.isEnabled() && |
| 64 | + (glintDropped && itemStackRenderState.displayContext == ItemDisplayContext.GROUND) || |
| 65 | + (glintFramed && itemStackRenderState.displayContext == ItemDisplayContext.FIXED)) { |
| 66 | + return ItemStackRenderState.FoilType.NONE; |
| 67 | + } else { |
| 68 | + return glint; |
| 69 | + } |
| 70 | + } |
71 | 71 |
|
72 | | - // TODO/MOVE |
73 | | - @Inject(method = "submit", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/model/ItemTransform;apply(ZLcom/mojang/blaze3d/vertex/PoseStack$Pose;)V")) |
74 | | - private void animatium$itemPositions(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int light, int overlay, int k, CallbackInfo ci) { |
75 | | - if (Animatium.isEnabled()) { |
76 | | - final ItemStack stack = ((ItemUtilityRenderState) field_55345).animatium$getItemStack(); |
77 | | - if (!stack.isEmpty()) { |
78 | | - final ItemDisplayContext itemDisplayContext = this.field_55345.displayContext; |
79 | | - boolean isGui = itemDisplayContext == ItemDisplayContext.GUI; |
80 | | - boolean isFirstPerson = itemDisplayContext == ItemDisplayContext.FIRST_PERSON_LEFT_HAND || itemDisplayContext == ItemDisplayContext.FIRST_PERSON_RIGHT_HAND; |
81 | | - boolean isThirdPerson = itemDisplayContext == ItemDisplayContext.THIRD_PERSON_LEFT_HAND || itemDisplayContext == ItemDisplayContext.THIRD_PERSON_RIGHT_HAND; |
| 72 | + // TODO/MOVE |
| 73 | + @Inject(method = "submit", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/model/ItemTransform;apply(ZLcom/mojang/blaze3d/vertex/PoseStack$Pose;)V")) |
| 74 | + private void animatium$itemPositions(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int light, int overlay, int k, CallbackInfo ci) { |
| 75 | + if (Animatium.isEnabled()) { |
| 76 | + final ItemStack stack = ((ItemUtilityRenderState) itemStackRenderState).animatium$getItemStack(); |
| 77 | + if (!stack.isEmpty()) { |
| 78 | + final ItemDisplayContext itemDisplayContext = this.itemStackRenderState.displayContext; |
| 79 | + final boolean isGui = itemDisplayContext == ItemDisplayContext.GUI; |
| 80 | + final boolean isFirstPerson = itemDisplayContext == ItemDisplayContext.FIRST_PERSON_LEFT_HAND || itemDisplayContext == ItemDisplayContext.FIRST_PERSON_RIGHT_HAND; |
| 81 | + final boolean isThirdPerson = itemDisplayContext == ItemDisplayContext.THIRD_PERSON_LEFT_HAND || itemDisplayContext == ItemDisplayContext.THIRD_PERSON_RIGHT_HAND; |
| 82 | + float x = this.transform.translation().x(); |
| 83 | + float y = this.transform.translation().y(); |
| 84 | + float z = this.transform.translation().z(); |
| 85 | + if (AnimatiumConfig.instance().items.fishingRodVersion != FishingRodVersion.VANILLA && ItemUtils.isFishingRodItem(stack) && isFirstPerson) { |
| 86 | + final int ordinal = AnimatiumConfig.instance().items.fishingRodVersion.ordinal(); |
| 87 | + if (ordinal <= FishingRodVersion.V1_8.ordinal()) { |
| 88 | + poseStack.translate(0.070625, 0.1, 0.020625); |
| 89 | + } |
82 | 90 |
|
83 | | - float x = this.transform.translation().x(); |
84 | | - float y = this.transform.translation().y(); |
85 | | - float z = this.transform.translation().z(); |
86 | | - float rotX = this.transform.rotation().x(); |
87 | | - float rotY = this.transform.rotation().y(); |
88 | | - float rotZ = this.transform.rotation().z(); |
89 | | - float scaleX = this.transform.scale().x(); |
90 | | - float scaleY = this.transform.scale().y(); |
91 | | - float scaleZ = this.transform.scale().z(); |
92 | | - if (AnimatiumConfig.instance().items.fishingRodVersion != FishingRodVersion.VANILLA && ItemUtils.isFishingRodItem(stack) && isFirstPerson) { |
93 | | - final int ordinal = AnimatiumConfig.instance().items.fishingRodVersion.ordinal(); |
94 | | - if (ordinal <= FishingRodVersion.V1_8.ordinal()) { |
95 | | - poseStack.translate(0.070625, 0.1, 0.020625); |
96 | | - } |
| 91 | + poseStack.translate(x, y, z); |
| 92 | + if (ordinal == FishingRodVersion.V1_7.ordinal()) { |
| 93 | + poseStack.mulPose(Axis.YP.rotationDegrees(180)); |
| 94 | + } |
97 | 95 |
|
98 | | - poseStack.translate(x, y, z); |
99 | | - if (ordinal == FishingRodVersion.V1_7.ordinal()) { |
100 | | - poseStack.mulPose(Axis.YP.rotationDegrees(180)); |
101 | | - } |
| 96 | + poseStack.translate(-x, -y, -z); |
| 97 | + } |
102 | 98 |
|
103 | | - poseStack.translate(-x, -y, -z); |
104 | | - } |
| 99 | + if (AnimatiumConfig.instance().items.thinBlockPositions && ItemUtils.isThinBlockItem(stack)) { |
| 100 | + if (isFirstPerson) { |
| 101 | + poseStack.translate(0, -4.2 * 0.0625, 0); |
| 102 | + } else if (isThirdPerson) { |
| 103 | + poseStack.translate(0, 0, -2 * 0.0625); |
| 104 | + } |
| 105 | + } |
105 | 106 |
|
106 | | - if (AnimatiumConfig.instance().items.thinBlockPositions && ItemUtils.isThinBlockItem(stack)) { |
107 | | - if (isFirstPerson) { |
108 | | - poseStack.translate(0, -4.2 * 0.0625, 0); |
109 | | - } else if (isThirdPerson) { |
110 | | - poseStack.translate(0, 0, -2 * 0.0625); |
111 | | - } |
112 | | - } |
| 107 | + // TODO/NEED TO FIX |
| 108 | + if (AnimatiumConfig.instance().items.skullPosition && ItemUtils.isSkullBlock(stack) && isGui && !AnimatiumConfig.instance().items.mobHeadIcons) { |
| 109 | + poseStack.translate(x, y, z); |
| 110 | + poseStack.mulPose(Axis.XP.rotationDegrees(Utils.toRadians(this.transform.rotation().x()))); |
| 111 | + poseStack.mulPose(Axis.YP.rotationDegrees(Utils.toRadians(this.transform.rotation().y()))); |
| 112 | + poseStack.mulPose(Axis.ZP.rotationDegrees(Utils.toRadians(this.transform.rotation().x()))); |
| 113 | + poseStack.scale(0.9F, 0.9F, 0.9F); |
| 114 | + poseStack.scale(this.transform.scale().x(), this.transform.scale().y(), this.transform.scale().z()); |
| 115 | + animatium$doInverseTransformations(poseStack); |
| 116 | + } |
| 117 | + } |
| 118 | + } |
| 119 | + } |
113 | 120 |
|
114 | | - // TODO/NEED TO FIX |
115 | | - if (AnimatiumConfig.instance().items.skullPosition && ItemUtils.isSkullBlock(stack) && isGui && !AnimatiumConfig.instance().items.mobHeadIcons) { |
116 | | - poseStack.translate(x, y, z); |
117 | | - poseStack.mulPose(Axis.XP.rotationDegrees(Utils.toRadians(rotZ))); |
118 | | - poseStack.mulPose(Axis.YP.rotationDegrees(Utils.toRadians(rotY))); |
119 | | - poseStack.mulPose(Axis.ZP.rotationDegrees(Utils.toRadians(rotX))); |
120 | | - poseStack.scale(0.9F, 0.9F, 0.9F); |
121 | | - poseStack.scale(scaleX, scaleY, scaleZ); |
122 | | - animatium$doInverseTransformations(poseStack); |
123 | | - } |
124 | | - } |
125 | | - } |
126 | | - } |
127 | | - |
128 | | - @Unique |
129 | | - private void animatium$doInverseTransformations(PoseStack poseStack) { |
130 | | - poseStack.scale(1 / this.transform.scale().x(), 1 / this.transform.scale().y(), 1 / this.transform.scale().z()); |
131 | | - poseStack.mulPose(Axis.ZP.rotationDegrees(-Utils.toRadians(this.transform.rotation().x()))); |
132 | | - poseStack.mulPose(Axis.YP.rotationDegrees(-Utils.toRadians(this.transform.rotation().y()))); |
133 | | - poseStack.mulPose(Axis.XP.rotationDegrees(-Utils.toRadians(this.transform.rotation().z()))); |
134 | | - poseStack.translate(-this.transform.translation().x(), -this.transform.translation().y(), -this.transform.translation().z()); |
135 | | - } |
| 121 | + @Unique |
| 122 | + private void animatium$doInverseTransformations(final PoseStack poseStack) { |
| 123 | + poseStack.scale(1 / this.transform.scale().x(), 1 / this.transform.scale().y(), 1 / this.transform.scale().z()); |
| 124 | + poseStack.mulPose(Axis.ZP.rotationDegrees(-Utils.toRadians(this.transform.rotation().x()))); |
| 125 | + poseStack.mulPose(Axis.YP.rotationDegrees(-Utils.toRadians(this.transform.rotation().y()))); |
| 126 | + poseStack.mulPose(Axis.XP.rotationDegrees(-Utils.toRadians(this.transform.rotation().z()))); |
| 127 | + poseStack.translate(-this.transform.translation().x(), -this.transform.translation().y(), -this.transform.translation().z()); |
| 128 | + } |
136 | 129 | } |
0 commit comments