Unicopia/src/main/java/com/minelittlepony/unicopia/mixin/MixinMilkBucketItem.java

26 lines
991 B
Java
Raw Normal View History

package com.minelittlepony.unicopia.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.CallbackInfoReturnable;
import com.minelittlepony.unicopia.ability.magic.Caster;
2021-12-22 12:12:51 +01:00
import com.minelittlepony.unicopia.ability.magic.SpellContainer;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.MilkBucketItem;
import net.minecraft.world.World;
@Mixin(MilkBucketItem.class)
abstract class MixinMilkBucketItem extends Item {
MixinMilkBucketItem() { super(null); }
@Inject(method = "finishUsing", at = @At("HEAD"), cancellable = true)
private void finishUsing(ItemStack stack, World world, LivingEntity entity, CallbackInfoReturnable<ItemStack> info) {
2021-12-22 12:12:51 +01:00
Caster.of(entity).map(Caster::getSpellSlot).ifPresent(SpellContainer::clear);
}
}