Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.cjcj55.chrispymod.objects.items;
- import net.minecraft.entity.item.ExperienceOrbEntity;
- import net.minecraft.entity.player.PlayerEntity;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.stats.Stats;
- import net.minecraft.util.ActionResult;
- import net.minecraft.util.Hand;
- import net.minecraft.util.SoundCategory;
- import net.minecraft.util.SoundEvents;
- import net.minecraft.world.World;
- public class EdibleExperienceItem extends Item
- {
- public EdibleExperienceItem(Properties properties)
- {
- super(properties);
- }
- public ActionResult<ItemStack> dropXP(World world, PlayerEntity player, Hand hand)
- {
- ItemStack stack = player.getHeldItem(hand);
- world.playSound((PlayerEntity)null, player.getPosX(), player.getPosY(), player.getPosZ(), SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
- if (!world.isRemote)
- {
- int amount = 8;
- ExperienceOrbEntity xpEntity = new ExperienceOrbEntity(world, player.getPosX(), player.getPosY(), player.getPosZ(), amount);
- world.addEntity(xpEntity);
- player.addStat(Stats.ITEM_USED.get(this));
- if (!player.abilities.isCreativeMode)
- {
- stack.damageItem(1, player, (p_219998_1_) -> {
- p_219998_1_.sendBreakAnimation(hand);
- });
- }
- }
- return ActionResult.resultSuccess(stack);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement