File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
common/src/main/java/com/lambda/mixin/render Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 2020import com .lambda .graphics .RenderMain ;
2121import net .minecraft .client .gui .DrawContext ;
2222import net .minecraft .client .gui .hud .InGameHud ;
23+ import net .minecraft .entity .player .PlayerInventory ;
24+ import net .minecraft .item .ItemStack ;
2325import org .spongepowered .asm .mixin .Mixin ;
2426import org .spongepowered .asm .mixin .injection .At ;
2527import org .spongepowered .asm .mixin .injection .Inject ;
28+ import org .spongepowered .asm .mixin .injection .Redirect ;
2629import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
2730
31+ import static net .minecraft .entity .player .PlayerInventory .isValidHotbarIndex ;
32+
2833@ Mixin (InGameHud .class )
2934public 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}
You can’t perform that action at this time.
0 commit comments