2020-04-25 22:03:36 +02:00
|
|
|
package com.minelittlepony.unicopia.mixin;
|
|
|
|
|
|
|
|
import org.spongepowered.asm.mixin.Mixin;
|
2022-09-30 12:43:07 +02:00
|
|
|
|
2020-09-22 15:11:20 +02:00
|
|
|
import com.minelittlepony.unicopia.item.toxin.ToxicHolder;
|
2020-04-25 22:03:36 +02:00
|
|
|
|
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
|
|
import net.minecraft.item.BlockItem;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.Hand;
|
|
|
|
import net.minecraft.util.TypedActionResult;
|
|
|
|
import net.minecraft.util.UseAction;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
@Mixin(BlockItem.class)
|
|
|
|
abstract class MixinBlockItem extends Item implements ToxicHolder {
|
2022-03-26 20:34:15 +01:00
|
|
|
MixinBlockItem() {super(null); }
|
2020-04-25 22:03:36 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public UseAction getUseAction(ItemStack stack) {
|
2022-09-30 12:43:07 +02:00
|
|
|
return getToxic(stack).useAction().orElseGet(() -> super.getUseAction(stack));
|
2020-04-25 22:03:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
2022-09-30 12:43:07 +02:00
|
|
|
return getToxic(player.getStackInHand(hand)).ailment().get(player)
|
2021-06-21 22:05:40 +02:00
|
|
|
.map(t -> t.use(world, player, hand))
|
|
|
|
.orElseGet(() -> super.use(world, player, hand));
|
2020-04-25 22:03:36 +02:00
|
|
|
}
|
|
|
|
}
|