PARTICIPANT IN A UNRANKED JAM
This Data Pack is an entry in the completed Minecraft Magic Event.

Minecraft Data Packs / Magic

Magic PvP Framework

  • check_circle Functions
  • 7,943 views, 3 today
  • 735 downloads, 0 today
  • 72
  • 45
  • 44
Bertiecrafter's Avatar Bertiecrafter
Retired Moderator
Level 70 : Legendary Engineer
776

This data pack provides everything you need to create your own magic spells!


The data pack functions as a base for spell data packs that other creators can make. It provides a chest with auto-generated pages of spells, wands, the necessary ray-casting mechanics, extensive spell metadata customization and easy to use hooks for spells.

It was also used in a PMC Magic event of which you can read the conclusion here.

The data pack can be interacted with in a variety of ways. Choose your use case below.

I'm a WIZARD that wants to blast spells at my opponent!
Soon there will be maps and spell data packs available for you to download. Follow these steps If you want to try it out with an example spell.
  1. Start by downloading one of the arena's or creating your own world.
  2. Press the download button on this submission and copy the Magic PvP folder inside the .zip file to the datapacks folder of the world. The other one is an example spell data pack to be used as template for data pack developers.
  3. Download and install one or more spell data packs and at least 1 magic resource pack.
  4. Of course, don't forget about an awesome outfit (collection 1 and collection 2).
  5. Load up the world and run /reload. You should see a message pop up that indicates the data packs have been loaded.
  6. Use "/loot give @s loot bertiecrafter:mpp/wand" to obtain a wand.
  7. Use "/function bertiecrafter:mpp/items/spawn_chest" to spawn a chest with all the loaded spells in the direction you're looking.
  8. Use "/loot give @s loot bertiecrafter:mpp/hat" to obtain a wizards hat.
You can now cast spells by holding the wand in your offhand (shield slot) and holding a spell in your main hand (hotbar). In a wizard fight, switch between spells by simply selecting a different spell item in your hotbar. The spell will become disabled for a certain amount of time after casting it. This time will only pass as long as the item is in the inventory.

Use "/trigger bcmpp_mute" to mute and unmute the spell phrases that appear in chat.
I'm a CODER that wants to create a spell data pack with ease!

The Magic PvP data pack takes away a lot of the base functionality you need for a wizardry data pack. All you have to do is add the spells. There are going to be quite a bit of steps, but each of them should be really small.

Remember: You are only allowed to publish the data pack created from the Example Spell data pack. Do not re-publish the Magic PvP Framework data pack, regardless of it being merged or provided separately (copyright). Add a link to this page on your submission page instead.

Setup
  1. Start by creating a new world.
  2. Press the download button on this submission and copy the 2 folders inside the .zip file to the datapacks folder of the world.
  3. Load up the world and run /reload. You should see a message pop up that indicates the data packs have been loaded.
  4. Read the spoiler above and familiarize yourself with the mechanics of the data pack. Play around a bit.
Your first spell
In these instructions we're only modifying the Example Spell Pack. You should be familiar with JSON and the raw JSON text component (as in /tellraw). You can find a tutorial here.

Creating your own namespace
  1. Start by giving the folder of the example spell data pack a different name and modify the description in the pack.mcmeta file inside that folder.
  2. Open up data/minecraft/tags/functions and in each of the files you see, replace "steve" with your own username. Note that only a-z 0-9 . _ - are allowed (so no capitals or spaces). Modify the "steve" replacement to fit that constraint.
  3. Now rename the data/steve folder to what you entered before.
  4. Open all functions in data/<username>/functions/mpp/ starting with "spells_" (except spells_register) and replace "steve", like you did in step 2 and 3.
  5. Run /reload and check if the example spell is still working.
Creating your own spell item
  1. Open data/<username>/functions/mpp/spells_register.mcfunction. This is where you describe your spell by giving it a color, name, description and more. At the top of the file you'll see descriptions of all the fields that you can fill in and the possible values for the color fields.
  2. Modify the last group of lines in that file to your own likings. All fields should be modified to describe your spell, not the example spell.
  3. Make sure to generate a new id and paste that in the Id field. If you don't generate a new id, other data packs will target your spell and prevent it from functioning correctly.
  4. Open all functions in data/<username>/functions/mpp/ starting with "spells_" (except spells_register) and replace the id on each line with the id you generated.
  5. Run /reload, press the reload button in a spells chest and make sure your custom spell item shows up. Try using it and confirm that the example behaviour is still working.
Adding your own spell behaviour
  1. In the same function files, replace "floop" with anything that could identify your spell (again, only a-z 0-9 . _ - are allowed). And rename the "floop" folder accordingly.
  2. You can now modify the function files in that folder with your own custom commands. Open the "Available States" spoiler for more info on implementing these functions.
Adding more spells
  1. Start by opening the spells_register function and copying the template at the top of the file down (without # in front). Use this new group of lines to describe your new spell.
  2. Run /reload and press the reload button in a spells chest to confirm it shows up.
  3. In the other functions starting with "spells_" you can copy the already existing lines, but with different IDs and new function paths.
  4. You can now fill the specified function files with your own custom commands. Open the "Available States" spoiler for more info on implementing these functions.
Available States
The function files starting with "spells_" represent certain states. For example, the spells_travel function is called when the spell is travelling. Each function file contains commands that run a certain function if the spell id matches. A typical command looks like this:
execute if entity @s[tag=<id>] run function <function> The following states are available:

StateWhenVariables
spawnOnce when the player casts a spell.Spell marker: @s
Player that cast the spell: @p
Location of players head: ~ ~ ~
travelMultiple times per tick, while the spell is shooting forwards. Tip: Use ^ ^ ^forwards coordinates to position along the spell path.
Spell marker: @s
Location of spell marker: ~ ~ ~
missOnce if the spell did not find a block or entity in time.Spell marker: @s
Location of spell marker: ~ ~ ~
hit_blockOnce if the spell hits a block.Spell marker: @s
Location of block that has been hit: ~ ~ ~
hit_entityOnce if the spell hits an entity.Spell marker: @s
Location of spell marker: ~ ~ ~
Entity that has been hit: @e[​type=!#bertiecrafter:mpp/spell_ignored,limit=1,sort=nearest]

Of course, there's the spells_register function that you use for specifying spell meta data and you can still use the vanilla minecraft tick and load functions.
I'm a CODER that wants to create a datapack to interact with and extend this pack!
  • You can run the commands listed in the first spoiler from functions to generate wands, hats and spell chests.
  • You can find the meta data of all spells in the bertiecrafter:mpp data storage under the "SpellsMeta" key.
  • In the same data storage you can also find all spell items under the "SpellsItems" key.
  • Register a function in the "#bertiecrafter:mpp/meta_data_to_item" function tag to allow processing additional meta (from the spells_register function) into the spell items. Use data storage bertiecrafter:mpp Tmp2 as source, data storage bertiecrafter:mpp SpellsItems[-1] as output. Note that the item "tag" tag is at SpellsItems[-1].tag
  • Register a function in the "#bertiecrafter:mpp/item_to_spell_marker" function tag to process/copy item data when an spell item is used. The execute entity/position is that of the newly spawned spell marker, which is inside the player's head. Use data entity @p SelectedItem as input, data entity @s as output. Executed before the "#minecraft:spells_spawn" function tag that is used in spell data packs.
  • Register a function in the "#bertiecrafter:mpp/travel" to override the spell movement behaviour.
    • Make sure to set scoreboard #travel bcmpp_default to 0 to prevent default behaviour.
    • The function is responsible for moving the spells marker (@s).
    • Call #minecraft:spells_travel to run user code every tick.
    • You must also call #minecraft:spells_hit_block, #minecraft:spells_hit_entity, #minecraft:spells_miss and kill @s depending on the behavior of the travel function.
    • You can use the "bertiecrafter:mpp/wand/detect_hit" function and the scoreboard #result bcmpp_hit output to detect blocks and entities. (0 = miss, 1 = hit block, 2 = hit entity)
I'm an ARCHITECT that wants to create an arena!
Note: These instructions are simplified for generic use. Read the event description if you want to create an arena for the related event.

The wizards of PMC will need an arena to cast their spells in. Spells might destroy the arena a bit, so make sure to make walls, floors and possibly ceilings very thick. Maybe even add barrier blocks around the entire arena to prevent players from walking/falling out.

You can add some extra's involving buttons, commands and command blocks. If you get lost while following the instructions below, have a look at the Magic Arena Reference map.


[ LVL 1 ] Basic playability for friends.
The following steps will prepare your arena to welcome players in a lobby and let them equip in peace in an armory. From there, they will be able to press a button to teleport to the arena.

Quick introduction to command blocks: Command blocks are triggered by redstone and can run any command you put in it. Use /give @s command_block to obtain one. Besides the text box for the command, you'll see a couple buttons when you click the block, don't worry about them for now.

You're going to use commands with coordinates. Copying them from F3 is fine, but you can get the coordinates faster by typing /setblock in chat, using tab autocomplete and copying the coordinates that appear.
  1. Once you've created your arena, install the Magic PvP and example spell data packs and run /reload.
  2. Create a separate area in which you set the world spawn (/setworldspawn), we'll call this the lobby.
  3. Run /defaultgamemode adventure. This makes new players automatically join in that gamemode and will allow them to respawn at the exact world spawn block. Otherwise players will spawn at the highest block at the world spawn.
  4. Create at least 2 rooms where players will be able to equip themselves, we'll call these armories.
  5. Slap buttons on walls with command blocks behind them that teleport the nearest player (/tp @p <x> <y> <z>). There should be buttons in the lobby teleporting to each armory and buttons in each armory teleporting to the arena.
  6. In each armory, store a wand item, hat item and a spells chest. Obtain these things using the commands below. Other PMC creators will help texture the items, but untextured they are just a fungus on a stick and a carved pumpkin.
    # Place a chest at your feet in the direction you're looking
    /function bertiecrafter:mpp/items/spawn_chest
    # Get wand and hat
    /loot give @s loot bertiecrafter:mpp/wand
    /loot give @s loot bertiecrafter:mpp/hat

  7. Disable command block output with /gamerule commandBlockOutput false
  8. You might want to consider setting other gamerules. For example, freeze time (/gamerule doDaylightCycle false) or freeze the weather (/gamerule doWeatherCycle false). Use tab to autocomplete the others.
  9. Well done! Your map is now ready to be published. If you want to stop here, make sure to remove the data packs before publishing.
[ LVL 2 ] Making your map reusable.
After completing this level, players will be able to get new wands and hats. Players will also be able to teleport back to the lobby whenever they want.

More command block info: Command blocks can be chained, so that you only have to power the first command block. To chain command blocks, place them behind each other. Use the buttons in the interface to switch modes, the first one should be Impulse - Unconditional - Needs Redstone, the others should be Chain - Unconditional - Always Active. The arrows on a command block indicate where the next command block should be in order to be triggered.
  1. Wire up each button in the lobby to a command that kills all items./kill @e[​type=item]
  2. Add two more command blocks to each of those buttons that give the player new wands and hats. The simplest is using the commands above, but with @p (nearest player) instead of @s. However, you can also modify the command to spawn the items on the floor or insert them into armor stands, item frames or chests. Either way, you should remove the wand and hat that were already there from the previous instructions.
  3. There should be a way for the last standing player to return to the lobby. One way of doing that is teleporting all players without a wand back. To do this, place a command block at the center of the arena, set it to Repeat - Unconditional - Always Active with the command:
    /tp @a[distance=..<radius>,nbt=!{Inventory:[{tag:{bcmpp_wand:1b}}]}] <x> <y> <z>Replace <radius> by the amount of blocks from the center of the arena to the furthest edge (without modifying the two dots in front) and use <x> <y> <z> to teleport players to the lobby.
  4. Congrats on making your map reusable! If you want to stop here, make sure to remove the data packs before publishing.
[ LVL 3 ] Synchronizing players for multiplayer.
You might want to synchronize players to create some concept of rounds. In the following instructions, we'll be making the buttons in the lobby (that teleport the player to the armory) disappear after a player presses them and come back after all players have left the arena. Also, we'll prevent the players from entering the arena until all players in the armories have pressed a button.

You're going to create commands that place and remove blocks. You can do this easily by placing the block that the command should create, looking at it and pressing F3+I. You now have a /setblock command on your clipboard that will place the exact block you were looking at in that position.
  1. Make each button in the lobby delete itself by adding yet another command block with the command below. /setblock <x> <y> <z> air
  2. Place a command block at the center of the arena and set it to Repeat - Unconditional - Always Active, enter the command: /execute unless entity @a[distance=..<radius>] and attach a comparator facing away from the command block. It will power on when there is no player in the radius. Use the redstone output to power command blocks that place the buttons back in the lobby.
  3. Now create a redstone line running into a block with a redstone torch on the side of that block. Connect the torch to a simple command block. Enter the same teleport command that teleports the player from the armory to the arena, but with @a (all players) instead of @p.
  4. Make each of the buttons in the lobby also place a redstone block besides the redstone line (using /setblock). The torch and the redstone output to the command block should turn off.
  5. Make each of the buttons in the armories remove the associated redstone block from the line instead of teleporting the nearest player to the arena. When the last redstone block is removed, the torch should come on and the command block should teleport everyone to the arena.
  6. You can make the buttons in the lobby and armories remove and place another redstone block behind a redstone lamp in the armory. This way the player gets a visual confirmation that you registered their button press.
  7. Congrats on synchronizing players and rounds! Make sure to remove the data packs before publishing.

I'm a DESIGNER that wants to add textures to the Items and GUIs involved!
Note: These instructions are simplified for generic use. Read the event description if you want to create a resource pack for the related event.

The data pack that players will use to become wizards and fight in the arenas uses vanilla built-in items. These items feel misplaced and could do with some nice retexturing. You can simply replace the texture of an item, but that would apply the texture to all of those items. Although it can be more difficult, it would be better if you only applied your custom texture/model if the item has a Custom Model Data of 300 000. There will be a quick tutorial of custom model data below.

It's a good idea to create a test world and install the data pack to test if your textures are working.

AssetUse within the Magic PvP data packExample ideas
Fungus on a stickThe wand that the player holds.
The item name can be changed with translation key "Magic Wand".
A nicely textured wizards wand.
Dye of various colorsItems that represent spells.Magic dust, scrolls or icons representing categories of spells.
Gray dye (not light gray)Signifies that the spell is used and cannot be used again until a timeout has passed, which would change the dye back to one of the other colors.  A lock/clock icon, an empty pouch of dust or broken scroll.
Carved pumpkin (item)Hats that players receive. The carved pumpkin will have to be remodeled. Within the coordinate space of a model, 0 0 0 to 16 16 16 is the same size as the players head and the space between y = 16 and y = 32 can be used to model a hat on top of the player's head.

Also, you probably want to make the pumpkin view overlay completely transparent or create something less obstructing so that players can see.
Any kind of hat. The overlay could be completely transparent or maybe a simple vignette.
GUIs  Various GUIs are part of the experience as well, like the start screen, menu background, menu buttons, inventory interface and the chest interface.The menu's could be themed to be more wizard/magic related.
Purple stained glass paneThe previous page button in a spell chest.A "back" or "up" arrow.
Blue stained glass paneReload button in a spell chest.A circular or "back to start" arrow.
Magenta stained glass paneThe next page button in a spell chest.A "forward" or "down" arrow.


Custom Model Data Quickstart
Only applying your textures based on "Custom Model Data" allows you to only apply textures to items that have a specific meaning within the Magic PvP Framework. Use the following steps to add textures with custom model data, assuming you have basic knowledge of creating resource packs:

  1. Start by creating an empty resource pack: A named folder, the pack.mcmeta file and optionally the pack.png file.
  2. Now open up .minecraft / versions / 1.18.1 / 1.18.1.jar with any zip file reader like 7-Zip or WinRar.
  3. In the resource pack, create 2 folders: assets/minecraft/models/item and assets/<namespace>/models/item, where namespace is usually your username, but only use the characters a-z 0-9 . _ - (no capital letters)
  4. In the version .jar, open up assets/minecraft/models/item. Copy the .json file of the item you want to retexture to both folders you just created.
  5. In the resource pack, open up assets/minecraft/models/item/<item>.json in your editor and add the following:
    {
    <existing content> ,
    "overrides": [
    {
    "predicate": {
    "custom_model_data": 300000
    },
    "model": "<namespace>:item/<item>"
    }
    ]
    }

    Make sure to add the comma at the end of the last item that was already there (before "overrides") and fill in the namespace and item names you have used before. Using the above model path (identifier) results in the following file path: assets/<namespace>/models/item/<item>.json
  6. In the resource pack, open up assets/<namespace>/models/item/<item>.json
  7. Replace the identifiers under "textures" in the file you just opened. The identifiers should look like this <namespace>:item/<item> which results in the file path: assets/<namespace>/textures/item/<item>.png. You should choose your own namespace and item name. For example, I can use the identifier "bertiecrafter:item/wand".
  8. Now create the texture file(s) for the identifiers you used earlier. In the case of "bertiecrafter:item/wand", I would create the "assets/bertiecrafter/textures/item/wand.png" file.

That's it! The texture should now only be applied based on custom model data.

To recap:

  • assets/minecraft/models/item/<item>.json should match the file name that is in the version .jar in order to override it (just like you would with normal textures)
  • The file contains a special overrides function that selects a different model if the item has custom model data.
  • The override model should be in your own namespace folder and be a copy of the original model from the version .jar.
  • The override model has custom texture identifiers that map to image paths that are not originally known by Minecraft.
  • Finally, you create the image file(s) that are targeted by the identifiers in the override model.




Does this work on version x.x.x?
I don't know, unfortunately I can't check all of my submissions on each version out there. Have a look at the bottom of the submission for the known compatible versions. You're free to try the data pack in versions that are not specified with the risk of it not working. If it does work, let me know in the comments so I can adjust the listed known compatible versions.

I encountered a bug! What do I do now?

I test all my creations, but bugs happen no matter how long you test something. Whenever someone experiences a bug, I do my best to fix the issue. You can help me by providing any useful information. You can never give me enough information, but please send it in a DM instead of placing it in the comments. You can still place a one-liner in the comments stating the issue to make the community aware, but that alone isn't enough to help me fix the issue.
  • Checklist: Are you using the right version? Did you do /reload after dropping the datapack in? After /reload, does the datapack show up green in /datapack list?
  • What is the issue? Does the datapack not seem to be working at all or is there a specific feature you are having issues with?
  • What happened? Please give me all the steps needed to reproduce the issue. The faster I can experience it, the faster I can solve it.
  • What did you expect to happen instead? This helps me understand your point of view and determine if the issue described is actually the issue I need to fix. The bug you are experiencing could just be a side effect of something else that doesn't behave as expected.

Magic PvP Framework Minecraft Data Pack
Magic PvP Framework Minecraft Data Pack
CreditThank you Silabear for giving the data pack a usability test!
CompatibilityMinecraft 1.17
toMinecraft 1.19
Tags

5 Update Logs

Added 1.19 support! : by Bertiecrafter 01/06/2023 5:32:31 pmJan 6th, 2023

Thanks FunkyToc for the initial investigations!
LOAD MORE LOGS

Create an account or sign in to comment.

1
01/04/2023 2:46 pmhistory
Level 74 : Legendary Lumberjack
FunkyToc
FunkyToc's Avatar
Hi Bertiecrafter, I just look at your amazing code to learn how to replicate it, and in 1.19 it seems to be a single bug: a missing removed tag in 1.19.
Couldn't load tag bertiecrafter:mpp/spell_ignored as it is missing following references: #minecraft:carpets
It has been renamed in #minecraft:wool_carpets .
I tested it, it's working now.

So, do you plan to update it in 1.19 ? Could be really nice =)
2
01/06/2023 5:33 pm
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
Done!
2
03/04/2022 8:25 am
Level 45 : Master Necromancer
Rignchen
Rignchen's Avatar
Hey, I just test with a friend to play in multiplayer with the datapacks but when he added his datapack, mine become unusable and the item of mine stop appearing in chests, then when we up mine it was his one that didn't work.
3
03/04/2022 8:39 amhistory
Level 45 : Master Necromancer
Rignchen
Rignchen's Avatar
I just find the problem and now it works. If sb have this problem, just rename the file "steeve" then go into data\minecraft\tags\functions and change the steve to the new name and it will be ok. (be sure to also change in your functions the steeve to the new name)
2
02/21/2022 7:42 pmhistory
Level 45 : Master Necromancer
Rignchen
Rignchen's Avatar
Hey, I started testing my futur submission but the spawn function don't work when I use spells...
2
02/22/2022 1:11 am
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
Enable the log output in the launcher settings (not game settings), it will show red text if it cannot load your data pack for whatever reason. Make sure the id in spells_register matches the id used in spells_spawn.
2
02/22/2022 5:02 amhistory
Level 45 : Master Necromancer
Rignchen
Rignchen's Avatar
that's not the problem cause the other files like the hit block are working corectly and cause if I try to do run the function in the chat it word, that's why I don't understand
2
02/23/2022 1:48 am
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
I just tested the example spell pack and it works there. Try to compare your data pack with a fresh download of the spell pack. See if in data/minecraft/tags/functions/spells_spawn.json you find a correct reference to the spells_spawn function. Although, the logs should tell you if it cannot find your function. The only other thing I can think of is a mismatch in IDs or a syntax error in your spawn function (which would also show up in the logs).
3
02/26/2022 5:30 amhistory
Level 45 : Master Necromancer
Rignchen
Rignchen's Avatar
I just took the last update of the "magic pvp" datapack and it all work, thank's
2
02/07/2022 1:50 pm
Level 48 : Master Fish
Flashbulb
Flashbulb's Avatar
Glad for the new update, I noticed that entities were hard to hit.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome