use of net.minecraft.world.entity.player.Player in project Tropicraft by Tropicraft.
the class CocktailItem method finishUsingItem.
/**
* Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
* the Item before the action is complete.
*/
@Override
public ItemStack finishUsingItem(@Nonnull ItemStack stack, @Nonnull Level worldIn, @Nonnull LivingEntity entityLiving) {
if (entityLiving instanceof Player) {
final Player player = (Player) entityLiving;
onFoodEaten(stack, worldIn, player);
Drink drink = getDrink(stack);
if (worldIn.isRainingAt(player.blockPosition()) && drink == Drink.PINA_COLADA) {
// TODO 1.17 advancements player.addStat(AchievementRegistry.drinkPinaColada);
}
return player.getAbilities().instabuild ? stack : new ItemStack(TropicraftItems.BAMBOO_MUG.get());
}
return new ItemStack(TropicraftItems.BAMBOO_MUG.get());
}
use of net.minecraft.world.entity.player.Player in project Tropicraft by Tropicraft.
the class BambooItemFrameItem method useOn.
@Override
public InteractionResult useOn(UseOnContext context) {
BlockPos blockpos = context.getClickedPos();
Direction direction = context.getClickedFace();
BlockPos blockpos1 = blockpos.relative(direction);
Player playerentity = context.getPlayer();
ItemStack itemstack = context.getItemInHand();
if (playerentity != null && !this.mayPlace(playerentity, direction, itemstack, blockpos1)) {
return InteractionResult.FAIL;
} else {
Level world = context.getLevel();
HangingEntity hangingentity = new BambooItemFrame(world, blockpos1, direction);
CompoundTag compoundnbt = itemstack.getTag();
if (compoundnbt != null) {
EntityType.updateCustomEntityTag(world, playerentity, hangingentity, compoundnbt);
}
if (hangingentity.survives()) {
if (!world.isClientSide) {
hangingentity.playPlacementSound();
world.addFreshEntity(hangingentity);
}
itemstack.shrink(1);
}
return InteractionResult.SUCCESS;
}
}
Aggregations