From e56c921432927c6587bf4d0fbfaec49e7c210dbe Mon Sep 17 00:00:00 2001 From: H2Sxxa Date: Thu, 19 Oct 2023 17:44:19 +0800 Subject: [PATCH] Update ItemShouLamp.java --- .../common/item/ItemShouLamp.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/arekkuusu/grimoireofalice/common/item/ItemShouLamp.java b/src/main/java/arekkuusu/grimoireofalice/common/item/ItemShouLamp.java index 2b8a6982..0151d12a 100644 --- a/src/main/java/arekkuusu/grimoireofalice/common/item/ItemShouLamp.java +++ b/src/main/java/arekkuusu/grimoireofalice/common/item/ItemShouLamp.java @@ -70,18 +70,24 @@ public ActionResult onItemRightClick(World world, EntityPlayer player player.setActiveHand(hand); return new ActionResult<>(EnumActionResult.SUCCESS, stack); } - + @Override - public void onUsingTick(ItemStack stack, EntityLivingBase player, int count) { - if(JEWELS.get(stack) < 500 && player instanceof EntityPlayer) { + public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entityLiving, int timeLeft) { + if(entityLiving instanceof EntityPlayer) { + EntityPlayer player = ((EntityPlayer) entityLiving); + int timeUsed = getMaxItemUseDuration(stack) - timeLeft; + if(timeUsed > 500) { + timeUsed = 500; + } + addJewels(stack, (short) timeUsed); player.addPotionEffect(new PotionEffect(MobEffects.LUCK, 10, 5)); - if(count % 4 == 0) { - player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 0.1F, 1F); + player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 0.1F, 1F); + if(JEWELS.get(stack) > 500){ + JEWELS.set((short) 500); } - addJewels(stack, (short) 1); } } - + @Override public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entityLiving, int timeLeft) { if(entityLiving instanceof EntityPlayer) {