[Tutorial] How to make a Magic Wand with spells?

Downloads:
720
Upvotes: 10
Share this:
Project members
Coder
Modification type
Supported Minecraft versions
1.15.2

Jump to downloads

 

Made by Loic

 

Welcome to a tutorial mod of how to make a Magic Staff with Mana and Mana potion

 

1) The Master Station (Staff Modifier)

You must have this table to modify your staff, you can find it in the only new creative tab this workspace add

By Loic

 

The Slot with the 1, 2, 3, 4 and 5, are where you should put your powers, then you need to press Add Power for them to go on your staff!

The 3 blue slots down them is when you should put your upgrades, in this workspace example, you only have 3 upgrades

The Orange slot is where you should put your 6th power if you have the BONUS SLOT upgrade on your staff!

 

2) The Staff

This is what you use to store your powers and spells!

by Loic

 

It is where your powers are stored, This staff has LEVELS and also has XP to up!, You unlock new slots for spells when you reach certain levels!

Level 1 = Slot 1 Unlocked

Level 3 = Upgrade Slot 1 Unlocked

Level 4 = Slot 2 Unlocked

Level 6 = Slot 3 and Upgrade Slot 2 Unlocked

Level 8 = Slot 4 Unlocked

Level 9 = Upgrade Slot 3 Unlocked

Level 10 = Slot 5 Unlocked

 

You have 5 powers and 3 Upgrades possible in this Workspace! You can add your own too!

by Loic

 

PS: Use /staffmax command in chat while having the staff in hand to unlock everything on it!

 

3) Custom Codes :

For the stats like the powers, level, xp and upgrades to show in the the description of the staff, you must replace the description of the item by this code:

            @Override
            public void addInformation(ItemStack itemstack, World world, List<ITextComponent> list, ITooltipFlag flag) {
            super.addInformation(itemstack, world, list, flag);
            list.add(new StringTextComponent("Right-Click to cast a selected Spell!"));
            list.add(new StringTextComponent("Shift + Right-Click to change spell!"));
                        if (itemstack.hasTag()) {
            list.add(new StringTextComponent("Level " + (itemstack.getTag().getInt("ItemLevel") + "")));
            list.add(new StringTextComponent("XP: " + (itemstack.getTag().getInt("XPAmount") + " left...")));
            list.add(new StringTextComponent("1 - " + (itemstack.getTag().getString("StaffSlot1Power") + "")));
                        }
                        if (itemstack.hasTag()) {
            list.add(new StringTextComponent("2 - " + (itemstack.getTag().getString("StaffSlot2Power") + "")));
                        }
                        if (itemstack.hasTag()) {
            list.add(new StringTextComponent("3 - " + (itemstack.getTag().getString("StaffSlot3Power") + "")));
                        }
                        if (itemstack.hasTag()) {
            list.add(new StringTextComponent("4 - " + (itemstack.getTag().getString("StaffSlot4Power") + "")));
                        }
                        if (itemstack.hasTag()) {
            list.add(new StringTextComponent("5 - " + (itemstack.getTag().getString("StaffSlot5Power") + "")));
                        }
            list.add(new StringTextComponent("Add different upgrades to your staff!"));
                        if (itemstack.hasTag()) {
            list.add(new StringTextComponent("Upgrade 1 - " + (itemstack.getTag().getString("StaffUpgradeSlot1") + "")));
                        }
                        if (itemstack.hasTag()) {
            list.add(new StringTextComponent("Upgrade 2 - " + (itemstack.getTag().getString("StaffUpgradeSlot2") + "")));
                        }
                        if (itemstack.hasTag()) {
            list.add(new StringTextComponent("Upgrade 3 - " + (itemstack.getTag().getString("StaffUpgradeSlot3") + "")));
                        }
        }

 

For the Mana to be synced server side and client side, you should use this code, placed this after the 2 } } after dependencies code in PLAYERTICK procedure, This code is important to have to prevent lot of bugs:

private int serverMana = 0;
@SubscribeEvent
    public void playerTick(TickEvent.PlayerTickEvent event)
    {
        if (!event.player.world.isRemote)
        {
            serverMana = event.player.getPersistentData().getInt("PlayerMana");
        }
        else {
            if (serverMana != 0) {
                event.player.getPersistentData().putInt("PlayerMana", serverMana);
            }
        }
    }
}

 

4) NBT Tags

This staff uses lot of NBT tags for it, here a list of them so you don't get lost in the procedures!

Itemstack NBT Tags =

- XPAmount = A Number NBT When you use a spell/power, your staff always remove -1 of this NBT in the Call procedure blocks of the powers

- ItemLevel = A Number NBT When you reach < 0 of XPAmount, it sets ItemLevel +1 and it sets the new XPAmount in a new number, like 150, 200...

- StaffSlotXPower = The string NBT that is always set to Locked Slot at level 0, once you reach certain levels, the procedure sets it to Empty Slot, which allows you to add more powers/spells, There is 5 StaffSlotXPower NBT(The X is 1 2 3 4 5)

- StaffUpgradeSlotX = Very Similar to StaffSlotXPower but for the upgrade slots!, there are 3 slots (X is 1 2 3)

- XPBonus - A Logic NBT which increase amount of XP you get when using a spell when set to TRUE, it is set to true when you add the XP Boost Upgrade

- ManaBonus - A Logic NBT similar to XPBonus but when it's true, it reduces the mana you use on spells by 50%(it adds half of the consumed mana in the Call Procedure blocks for spells)

- BonusSlot = A Logic NBT which sets the bonus slot accesibility which shift+right click with the staff in hand!

Entity NBT Tags =

- PlayerMana = This NBT Tag used everything to remove, or add mana to the player

Modification files
MagicStaffTutorial-1.15.2.jar - Download the Mod! Uploaded on: 06/21/2020 - 13:54   File size: 531.88 KB
MagicStaffWorkspace-2020.3.zip - Download the Workspace! Uploaded on: 06/21/2020 - 13:54   File size: 226.28 KB

Hi, I have a question, I don't know where to put the second code, Mana's.

The idea is amazing, but I would do something like RPG leveling

Guys, now in 2020.4 Instead of using NBT tag for player mana, Use a PLAYER_PERSISTENT Global trigger