aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dulkirmod/mixins/MixinItem.java
blob: 62ae99d8ec3b7350e92d3f25dc9d2de478172ea6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package dulkirmod.mixins;

import dulkirmod.DulkirMod;
import dulkirmod.config.DulkirConfig;
import dulkirmod.features.ImpactDisplay;
import dulkirmod.features.ReaperDisplay;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
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.CallbackInfoReturnable;

@Mixin(value = {Item.class})
public class MixinItem {

    @Inject(method = "shouldCauseReequipAnimation", at = @At("HEAD"), cancellable = true, remap = false)
    public void overrideReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged, CallbackInfoReturnable<Boolean> ci) {
        if (DulkirMod.Companion.getConfig().getCancelReequip())
            ci.setReturnValue(false);
    }

    @Inject(method = "showDurabilityBar(Lnet/minecraft/item/ItemStack;)Z", at = @At("HEAD"),
            cancellable = true, remap = false)
    public void shouldShowDur(ItemStack stack, CallbackInfoReturnable<Boolean> cir) {
        if (DulkirConfig.INSTANCE.getDisplayReaperCD())
            ReaperDisplay.INSTANCE.shouldDisplay(stack, cir);
        if (DulkirConfig.INSTANCE.getDisplayImpactCD())
            ImpactDisplay.INSTANCE.shouldDisplay(stack, cir);
    }
    @Inject(method = "getDurabilityForDisplay(Lnet/minecraft/item/ItemStack;)D", at = @At("HEAD"),
            cancellable = true, remap = false)
    public void getItemHealthDisplayVal(ItemStack stack, CallbackInfoReturnable<Double> cir) {
        if (DulkirConfig.INSTANCE.getDisplayReaperCD())
            ReaperDisplay.INSTANCE.calcDurability(stack, cir);
        if (DulkirConfig.INSTANCE.getDisplayImpactCD())
            ImpactDisplay.INSTANCE.calcDurability(stack, cir);
    }
}