aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemRenderer.java
blob: d691b79fc9864e94b2a2ff915ebf20b3ec183706 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package io.github.moulberry.notenoughupdates.mixins;

import io.github.moulberry.notenoughupdates.miscgui.InventoryStorageSelector;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(ItemRenderer.class)
public abstract class MixinItemRenderer {
	@Redirect(method = "updateEquippedItem", at = @At(
		value = "INVOKE",
		target = "Lnet/minecraft/entity/player/InventoryPlayer;getCurrentItem()Lnet/minecraft/item/ItemStack;"
	))
	public ItemStack modifyStackToRender(InventoryPlayer player) {
		if (InventoryStorageSelector.getInstance().isSlotSelected()) {
			return InventoryStorageSelector.getInstance().getHeldItemOverride();
		}
		return player.getCurrentItem();
	}
}