Skip to content

Commit 21a4137

Browse files
committed
Show fake stack in hand and in hud tooltip
1 parent 982d692 commit 21a4137

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

common/src/main/java/com/lambda/mixin/render/InGameHudMixin.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,25 @@
2020
import com.lambda.graphics.RenderMain;
2121
import net.minecraft.client.gui.DrawContext;
2222
import net.minecraft.client.gui.hud.InGameHud;
23+
import net.minecraft.entity.player.PlayerInventory;
24+
import net.minecraft.item.ItemStack;
2325
import org.spongepowered.asm.mixin.Mixin;
2426
import org.spongepowered.asm.mixin.injection.At;
2527
import org.spongepowered.asm.mixin.injection.Inject;
28+
import org.spongepowered.asm.mixin.injection.Redirect;
2629
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2730

31+
import static net.minecraft.entity.player.PlayerInventory.isValidHotbarIndex;
32+
2833
@Mixin(InGameHud.class)
2934
public class InGameHudMixin {
3035
@Inject(method = "render", at = @At("TAIL"))
3136
private void onRender(DrawContext context, float tickDelta, CallbackInfo ci) {
3237
RenderMain.render2D();
3338
}
39+
40+
@Redirect(method = "tick()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;getMainHandStack()Lnet/minecraft/item/ItemStack;"))
41+
private ItemStack onTick(PlayerInventory inventory) {
42+
return isValidHotbarIndex(inventory.selectedSlot) ? inventory.main.get(inventory.selectedSlot) : ItemStack.EMPTY;
43+
}
3444
}

0 commit comments

Comments
 (0)