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

24 lines
899 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;
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) {
Caster.of(entity).ifPresent(c -> c.setSpell(null));
}
}