public class ChargeableStaffItem extends TieredItem { private final int cooldownSpeed; private final int fireType; private final int xpAmount; public ChargeableStaffItem(IItemTier tierIn, int cooldownSpeedIn, int firetypeIn, int xpAmountIn, Properties properties) { super(tierIn, properties); this.cooldownSpeed = cooldownSpeedIn; this.fireType = firetypeIn; this.xpAmount = xpAmountIn; } @Override public void onPlayerStoppedUsing(ItemStack stack, World worldIn, LivingEntity entityLiving, int timeLeft) { if (entityLiving instanceof PlayerEntity) { PlayerEntity playerIn = (PlayerEntity) entityLiving; Hand handIn = (Hand) playerIn.getActiveHand(); Vector3d aim = playerIn.getLookVec(); double x = playerIn.getPosX(); double y = playerIn.getPosY(); double z = playerIn.getPosZ(); if (fireType == 1) { if (timeLeft <= 7170) { if (playerIn.experienceTotal > 0 || playerIn.abilities.isCreativeMode) { if (!worldIn.isRemote) { IceBallEntity iceball = new IceBallEntity(playerIn, worldIn); IceBallEntity iceball2 = new IceBallEntity(playerIn, worldIn); IceBallEntity iceball3 = new IceBallEntity(playerIn, worldIn); iceball.shoot(aim.x, aim.y, aim.z, 1.5f, 1.0f); iceball2.shoot(aim.x, aim.y, aim.z * 0.5, 1.5f, 1.0f); //<--- I'm trying to get iceball2 and 3 to be on the opposites sides of iceball but they're acting funky iceball3.shoot(aim.x, aim.y, aim.z * -0.5, 1.5f, 1.0f); worldIn.playSound((PlayerEntity) null, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ENTITY_EVOKER_CAST_SPELL, SoundCategory.NEUTRAL, 1.0F, 1.5F); worldIn.addEntity(iceball); worldIn.addEntity(iceball2); worldIn.addEntity(iceball3); } } } else { if (playerIn.experienceTotal > 0 || playerIn.abilities.isCreativeMode) { if (!worldIn.isRemote) { IceBallEntity iceball = new IceBallEntity(playerIn, worldIn); iceball.shoot(aim.x, aim.y, aim.z, 1.5f, 1.0f); worldIn.playSound((PlayerEntity) null, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ENTITY_EVOKER_CAST_SPELL, SoundCategory.NEUTRAL, 1.0F, 1.5F); worldIn.addEntity(iceball); } } } } if (!playerIn.abilities.isCreativeMode) { stack.damageItem(1, playerIn, (p_220045_0_) -> { p_220045_0_.sendBreakAnimation(EquipmentSlotType.MAINHAND); }); playerIn.giveExperiencePoints(this.xpAmount * -1); } playerIn.swingArm(handIn); playerIn.getCooldownTracker().setCooldown(this, cooldownSpeed); playerIn.addStat(Stats.ITEM_USED.get(this)); } } public int getUseDuration(ItemStack stack) { return 7200; } public UseAction getUseAction(ItemStack stack) { return UseAction.BOW; } public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); if (!playerIn.abilities.isCreativeMode && playerIn.experienceTotal == 0) { worldIn.playSound((PlayerEntity) null, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ENTITY_EVOKER_CAST_SPELL, SoundCategory.NEUTRAL, 1.0F, -1.0F); playerIn.swingArm(handIn); playerIn.getCooldownTracker().setCooldown(this, cooldownSpeed); return ActionResult.resultFail(itemstack); } else { playerIn.setActiveHand(handIn); return ActionResult.resultConsume(itemstack); } } @Override public void onUsingTick(ItemStack stack, LivingEntity player, int count) { //player.world.playSound((PlayerEntity) null, player.getPosX(), player.getPosY(), player.getPosZ(), SoundEvents.BLOCK_GLASS_BREAK, SoundCategory.NEUTRAL, 1.0F, 1.5F); } @OnlyIn(Dist.CLIENT) public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { super.addInformation(stack, worldIn, tooltip, flagIn); tooltip.add((new TranslationTextComponent("Chargeable")).func_240699_a_(TextFormatting.WHITE)); tooltip.add((new TranslationTextComponent("Cooldown: " + this.cooldownSpeed)).func_240699_a_(TextFormatting.WHITE)); tooltip.add((new TranslationTextComponent("Xp Cost: " + this.xpAmount)).func_240699_a_(TextFormatting.WHITE)); } }