Additional plants

This commit is contained in:
paulevsGitch 2021-03-17 14:26:39 +03:00
parent 37b24bfcaf
commit c3ce436fe0
59 changed files with 1468 additions and 5 deletions

View file

@ -1,8 +1,13 @@
package ru.betterend.item;
import net.minecraft.advancement.criterion.Criteria;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsage;
import net.minecraft.item.Items;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.stat.Stats;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.UseAction;
@ -27,4 +32,23 @@ public class DrinkItem extends PatternedItem {
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
return ItemUsage.consumeHeldItem(world, user, hand);
}
@Override
public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) {
if (user instanceof ServerPlayerEntity) {
ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) user;
Criteria.CONSUME_ITEM.trigger(serverPlayerEntity, stack);
serverPlayerEntity.incrementStat(Stats.USED.getOrCreateStat(this));
}
if (user instanceof PlayerEntity && !((PlayerEntity) user).abilities.creativeMode) {
stack.decrement(1);
}
if (!world.isClient) {
user.clearStatusEffects();
}
return stack.isEmpty() ? new ItemStack(Items.GLASS_BOTTLE) : stack;
}
}