mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-12-01 08:47:59 +01:00
ad7a7d84c0
- Foods fill for different amounts for different races - Certain foods can no longer be eaten by certain races - Added food categories for candy, rocks, desserts - Moved everything to datapacks
33 lines
1.4 KiB
Java
33 lines
1.4 KiB
Java
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.diet.DietView;
|
|
import net.minecraft.entity.LivingEntity;
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.ActionResult;
|
|
import net.minecraft.util.Hand;
|
|
import net.minecraft.util.TypedActionResult;
|
|
import net.minecraft.world.World;
|
|
|
|
@Mixin(ItemStack.class)
|
|
abstract class MixinItemStack {
|
|
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
|
|
private void onUse(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> info) {
|
|
ItemStack self = (ItemStack)(Object)this;
|
|
TypedActionResult<ItemStack> result = ((DietView.Holder)self.getItem()).getDiets(self).startUsing(self, world, user, hand);
|
|
if (result.getResult() != ActionResult.PASS) {
|
|
info.setReturnValue(result);
|
|
}
|
|
}
|
|
|
|
@Inject(method = "finishUsing", at = @At("HEAD"))
|
|
private void onFinishUsing(World world, LivingEntity user, CallbackInfoReturnable<ItemStack> info) {
|
|
ItemStack self = (ItemStack)(Object)this;
|
|
((DietView.Holder)self.getItem()).getDiets(self).finishUsing(self, world, user);
|
|
}
|
|
}
|