diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinMilkBucketItem.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinMilkBucketItem.java new file mode 100644 index 00000000..9ce1ad77 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinMilkBucketItem.java @@ -0,0 +1,23 @@ +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.CasterUtils; +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 info) { + CasterUtils.toCaster(entity).ifPresent(c -> c.setSpell(null)); + } +} diff --git a/src/main/resources/unicopia.mixin.json b/src/main/resources/unicopia.mixin.json index 6ac39693..98adfcbc 100644 --- a/src/main/resources/unicopia.mixin.json +++ b/src/main/resources/unicopia.mixin.json @@ -11,6 +11,7 @@ "MixinItemEntity", "MixinItems", "MixinLivingEntity", + "MixinMilkBucketItem", "MixinPlayerEntity", "MixinProjectileEntity", "MixinServerPlayerEntity",