-
-
Notifications
You must be signed in to change notification settings - Fork 421
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
mdenials
authored
Nov 12, 2023
1 parent
c2d8a9c
commit 1cf6ecb
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/main/java/net/wurstclient/mixin/HeldItemRendererMixin.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,51 @@ | ||
/* | ||
* Copyright (c) 2014-2023 Wurst-Imperium and contributors. | ||
* | ||
* This source code is subject to the terms of the GNU General Public | ||
* License, version 3. If a copy of the GPL was not distributed with this | ||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt | ||
*/ | ||
package net.wurstclient.mixin; | ||
|
||
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.CallbackInfo; | ||
|
||
import net.minecraft.client.network.AbstractClientPlayerEntity; | ||
import net.minecraft.client.render.VertexConsumerProvider; | ||
import net.minecraft.client.render.item.HeldItemRenderer; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.util.Hand; | ||
import net.wurstclient.WurstClient; | ||
|
||
@Mixin(HeldItemRenderer.class) | ||
public abstract class HeldItemRendererMixin | ||
{ | ||
@Inject(at = {@At(value = "INVOKE", | ||
target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applyEquipOffset(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/Arm;F)V", | ||
ordinal = 4)}, | ||
method = "renderFirstPersonItem") | ||
private void lowerShieldBlocking(AbstractClientPlayerEntity player, float tickDelta, float pitch, | ||
Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, | ||
VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) | ||
{ | ||
// lower shield when blocking | ||
WurstClient.INSTANCE.getHax().noShieldOverlayHack.adjustShieldPosition(matrices, true); | ||
} | ||
|
||
@Inject(at = {@At(value = "INVOKE", | ||
target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applySwingOffset(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/Arm;F)V", | ||
ordinal = 1)}, | ||
method = "renderFirstPersonItem") | ||
private void lowerShieldNonBlocking(AbstractClientPlayerEntity player, float tickDelta, float pitch, | ||
Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, | ||
VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) | ||
{ | ||
// lower shield when not blocking | ||
if(hand == Hand.OFF_HAND && item.getItem() == Items.SHIELD) | ||
WurstClient.INSTANCE.getHax().noShieldOverlayHack.adjustShieldPosition(matrices, false); | ||
} | ||
} |