Posted December 23, 20213 yr I created a capability to store player's mana. This mana is used to control the player of casting items. In a method inside an item class I call the mana capability to verify if the player have the amount of mana required to cast the item. But, when I tried to use in game, the item went into recharge(cooldown) but the entity that I punched was not hurt. When I remove the line code of the capability, everything works. The method: Spoiler @Override public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity) { ManaCapability manaCapability = player.getCapability(ModCapabilities.MANA_CAPABILITY).orElse(null); if (!player.getCooldowns().isOnCooldown(this)) { if (manaCapability.getMana() >= this.manaCost) { player.getCooldowns().addCooldown(this, this.getPlayerCooldown(player)); double dano = player.getAttributeValue(ModAttributes.MAGIC_DAMAGE.get()); DamageSource damage = ModDamageSources.playerMagicAttack(player, player, DirectEntityDamageSource.Type.DAGGER); entity.hurt(damage, (float) (dano * multiplier)); } } return true; }
December 23, 20213 yr Author I removed this line: ManaCapability manaCapability = player.getCapability(ModCapabilities.MANA_CAPABILITY).orElse(null); and the if statement : if (manaCapability.getMana() >= this.manaCost) {
December 23, 20213 yr Author I used, but it indicates the correct mana, it's running the code inside the statement, but the method entity.hurt is not working dunno why.
December 23, 20213 yr Author here it is: luccaPossamai/Outro1.18 (github.com) (some words are written in portuguese) Edited December 23, 20213 yr by LuccaPossamai
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.