2020-10-09 18:00:55 +02:00
|
|
|
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;
|
|
|
|
|
2021-02-13 18:59:12 +01:00
|
|
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
2021-12-22 12:12:51 +01:00
|
|
|
import com.minelittlepony.unicopia.ability.magic.SpellContainer;
|
|
|
|
|
2020-10-09 18:00:55 +02:00
|
|
|
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);
|
2020-10-09 18:00:55 +02:00
|
|
|
}
|
|
|
|
}
|