Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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;
    }

 

 

  • Author

I removed this line:

ManaCapability manaCapability = player.getCapability(ModCapabilities.MANA_CAPABILITY).orElse(null);

and the if statement :

if (manaCapability.getMana() >= this.manaCost) {

 

  • 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.

  • Author

here it is: luccaPossamai/Outro1.18 (github.com)

(some words are written in portuguese)

 

Edited 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.