Jump to content

Mana Capability Not Functioning Properly


Silverbeam

Recommended Posts

In my mod, I have mana implemented. . However, you can gain 50 mana by right clicking on a bed. I have a weapon that, when you right click, consumes 50 mana and spawns EntityLargeFireball. If your mana is less than 50, then a line of text appears in chat. However, for some reason you are able to spawn multiple Fireballs when you shouldn't be able to. For example, if i had 150 mana, I should be able to spawn 3 fireballs, but instead it spawns anywhere from 3 to maybe 8. Once mana reaches 0, the text appears as it should. However, once mana goes back up, the fireball doesn't spawn and the text still occurs. Here is the code that is in the weapon. Can anyone help?

______________________________________________________________________________________________________________________________________________________________________________________

@Override
    public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
      { 
        if(playerIn.hasCapability(ManaProvider.MANA_CAP, null))
        {
            if(playerIn.getCapability(ManaProvider.MANA_CAP, null).consume(50f))
            {
                playerIn.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 5, 1000));
                Minecraft.getMinecraft().world.spawnEntity(new EntityLargeFireball(Minecraft.getMinecraft().world, playerIn.posX, playerIn.posY, playerIn.posZ, 3d, 0d, 3d));
                 
            }
            else
            {
                playerIn.sendMessage(new TextComponentString("FUCK YOU, DIP DIP"));
            }
        }

_____________________________________________________________________________________________________________________________________________________________________________________

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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