Skip to content

Magic Consumable Items

Deadlydiamond98 edited this page Aug 2, 2024 · 1 revision

There are currently 4 consumable items in here that can be used as a base for new items: MagicUpgrade, MagicDowngrade, MagicConsumable, and MagicFood.


Magic Upgrade

Magic Upgrade is an item that increases maximum mana, and the constructor takes in the following variables:

  • useUntilManaIs: The Max Mana Level needed to no longer allow use of the item
  • addedMana: The amount of Mana the Max Mana is increased by
  • consumed: If the item is removed from the player after use
  • replenishMana: If the item also grants the the same amount of mana as the max increase
  • cooldown: How long of a cool down the item has after use (with 0 or below giving no cooldown)

If you want to add custom functionality after doing a max mana increase, you can use the addMana method

Example that sends a very dumb message to the player upon consumption:

@Override
public void addMana(PlayerEntity user, Hand hand) {
    super.addMana(user, hand);
    user.sendMessage(Text.literal("You have the power of god and anime on your side"));
}

Magic Downgrade

Magic Downgrades are very similar to Magic Upgrade items, except they remove rather than add. The Constructor has:

  • useUntilManaIs: The Minimum Mana level needed to no longer allow use of the item
  • addedMana: The amount of Mana the Max Mana is decreased by
  • consumed: If the item is removed from the player after use
  • cooldown: How long of a cool down the item has after use (with 0 or below giving no cooldown)

If you want to add custom functionality after decreasing max mana, you can use the removeMana method

Example that sends a very dumb message to the player upon consumption:

@Override
public void removeMana(PlayerEntity user, Hand hand) {
    super.removeMana(user, hand);
    user.sendMessage(Text.literal("You no longer have the power of god and anime on your side"));
}

Magic Consumable

A Magic Consumable is an item that grants the player some extra mana (not max, just regular) upon use. It takes the following in the constructor:

  • amountToGive: The amount of Mana gained
  • consumed: If the item is removed from the player after use
  • cooldown: How long of a cool down the item has after use (with 0 or below giving no cooldown)

You can use the method afterUse() to do additional things after consumption:

private void afterUse(PlayerEntity user) {
   user.sendMessage(Text.literal("You consumed the thing"));
}

Magic Food

A Magic Food is exactly the same as a Magic Consumable, except it's eaten rather than right clicked! Constructor Variables are:

  • amountToGive: The amount of Mana gained
  • consumed: If the item is removed from the player after use
  • cooldown: How long of a cool down the item has after use (with 0 or below giving no cooldown)

You can use the method finishUsing() to add additional effects once eaten:

@Override
public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) {
    user.sendMessage(Text.literal("You ate the thing"));
    return super.finishUsing(stack, world, user);
}

Clone this wiki locally