diff --git a/README.md b/README.md index 0184795..f286350 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,42 @@ # Magnet + Survival-friendly datapack for Minecraft that adds an item magnet which attracts items to the wielder in a small radius. -## Download [here](https://github.com/budak7273/magnet/releases), put zip in your save's datapacks folder, then run `/reload` to install. +## Download [here](https://github.com/budak7273/magnet/releases), put zip in your save's datapacks folder, then run `/reload` to install -![Magnet item tooltip](https://i.imgur.com/84YWGfQ.png) +Players will receive a message in the chat upon unlocking the recipe +(obtaining an iron ingot) informing them of its existence. -Craft chainmail leggings using a custom recipe to obtain a magnet. +Craft a magnet (enhanced Chainmail Leggings) in your local Crafting Table or Crafter. -![Magnet crafting recipe](https://i.imgur.com/Rf1a2TE.png) +![Magnet crafting recipe](https://i.imgur.com/dc2A8DY.png) ## Features -* Lag friendly! -* Configurable! - * Run `/function magnet:toggle_options_pane` to see options. + * Brings items to you! * Break blocks over a void without fear of dropping items off the edge. +* Configurable! + * Run `/function magnet:toggle_options_pane` to see options. Read the section below for more details. +* Lag friendly! * Survival friendly * Custom crafting recipe provides a method of obtaining magnets in a survival playthrough * Nearby item entities play a quiet sound to help you locate them (configurable) -* Works for multiple players at once +* Multiplayer compatible * Wear a magnet as pants! * Both functional _and_ stylish. -* Mobs can also use magnets (configurable) - * Make a magnet powered mobfarm! Use mobs (or armor stands) wearing magnets to gather items to a hopper and save on hoppers - * Mobs with magnets can attract and equip your gear if you die. (disabled by default) Don't die near a mob with a magnet. +* Armor stands can use magnets (configurable, on by default) + * Make a magnet powered mobfarm! Use armor stands wearing magnets to gather items to a central hopper. +* Mobs can also use magnets (configurable, off by default) + * Mobs with magnets can attract and possibly equip dropped gear. Don't die near a mob with a magnet. * Particles are displayed when an item is brought to a magnet user (configurable) -* Works on Spigot/Paper/Etc. +* Works on Fabric/Paper/etc. servers ## Commands + * `/function magnet:toggle_options_pane` * Toggles the options pane to show/hide the current config settings. * `/function magnet:give_magnet` - * Gives yourself a magnet if you don't want to craft one. + * Gives you a magnet's crafting ingredients for testing. * `/function magnet:magnetize_item` * Manually teleport an item entity within range to you as if you were holding a magnet. * `/function magnet:default_configs` @@ -46,38 +51,36 @@ Craft chainmail leggings using a custom recipe to obtain a magnet. * Display the total crafted magnets stats scoreboard in the sidebar ## Config Options + +Use `/scoreboard players set optionNameHere m_options valueHere` to set values + * `m_mob_interval` (Default 20) - The number of ticks between magnets working for mobs. 20 ticks in one second. * `m_player_interval` (Default 5) - The number of ticks between magnets working for players. 20 ticks in one second. -* `armorStand` (Default 1) - If magnets work when equipped on armor stands. +* `armorStand` (Default 1) - If magnets work when equipped on armor stands (leggings slot). * `playerHands` (Default 1) - If magnets work when in the player's main or offhand * `playerEquip` (Default 1) - If magnets work when in the player's legs slot. * `particlesOnHolder` (Default 1) - If particles should be spawned on the magnet user when an item is attracted. * `particlesOnItem` (Default 1) - If particles should be spawned at the old location of the item when an item is attracted. * `playItemSound` (Default 1) - If items should play a sound when within 10 blocks of a magnet user. * `enabledActionbarText` (Default 1) - If having a magnet equipped should display text in your action bar. -* `allMobs_Laggy` (Default 0) - If magnets work for every mob than can equip armor. This can be quite laggy to enable. +* `allMobs_Laggy` (Default 0) - If magnets work for every mob than can equip armor. It will function when the item is in the leggings slot (ex. Zombies) or primary hand slot (ex. Fox) This can be quite laggy to enable. ## Further Details + * I tried to document exactly how everything works via comments in the function files. Feel free to contact me with any questions. * Regular chainmail leggings are unaffected and can be used normally. - * Avoid crafting a magnet while you have chainmail leggings in your inventory. A shortcoming of my method of detecting the crafting means that they will lose their data. * Teleports items to you in a 5 block radius. * Only one item entity at a time is teleported on purpose, so you can't 'carry' multiple stacks of item entities with you as you move like you can with many modded magnets. -* Makes all items in a 10 block radius play a quiet sound (from the "player" sound category) to help you find them. +* Makes all items in a 10 block radius play a quiet sound (in the "player" sound category) to help you find them. * Plays a quieter, pitch shifted version of the Experience Bottle Thrown sound, if you have captions enabled. * More item entities causes the sounds to stack and get louder. -* Any mob that can wear a magnet in its legs slot will have the magnet effect applied on equip. Tested with zombies, skeletons, zombie pigmen, and villagers. Would probably work for foxes as well. +* When `allMobs_Laggy` is enabled, any mob wearing a magnet in its legs slot or primary hand slot will have the magnet effect applied. Tested with zombies, skeletons, zombie pigmen, foxes, and villagers. ## Credit -* I based my crafting system off of the one that SethBling uses in his [Water Mill datapack](https://www.youtube.com/watch?v=hG-KOFf5GbM). - * If you are looking to create a custom crafting recipe that produces an item with NBT data, I strongly suggest that you look at the comments I wrote in my functions. SethBling didn't leave any explanatory comments in his function files, and his process was difficult to follow at first. -* I used an [online generator](https://advancements.thedestruc7i0n.ca/) to produce the advancement used to grant the recipes. + * I used an [online tellraw generator](https://minecraft.tools/en/tellraw.php) to produce tellraw commands - those are a pain. * Multiple stackoverflow, reddit, and minecraft forums posts explaining command behavior and nitpicky syntax were read in the process of squashing bugs. -## Known Bugs -* Because Minecraft advancements are buggy, trading with a villager for Chainmail Leggings counts as crafting them using the custom recipe. - * If you need regular chainmail leggings, either drop them out of the villager window, or craft 2 magnets together and directly drop the product out of the crafting window, then wait for 5 seconds (you should see a message in chat when it's safe to pick them up) - ## Planned features (Eventuallyâ„¢) + * Offer a resource pack to clients that retextures the magnet item. diff --git a/data/magnet/function/crafting_dropped_item_error.mcfunction b/data/magnet/function/crafting_dropped_item_error.mcfunction deleted file mode 100644 index 4d81b6c..0000000 --- a/data/magnet/function/crafting_dropped_item_error.mcfunction +++ /dev/null @@ -1,8 +0,0 @@ - -# Reset the stopper and crafting loop -scoreboard players set craftSafetyStopper m_internals 0 -scoreboard players set @s m_craft_leggings 0 - -# Warning message and sound -tellraw @s ["",{"text":"\u2715","color":"red"},{"text":" Item-returning automatically gave up as a lag prevention measure. Don't drop custom crafting item products on the ground.","italic":true,"color":"gray"}] -execute as @s at @s run playsound minecraft:block.note_block.snare voice @s ~ ~ ~ 1 0.25 \ No newline at end of file diff --git a/data/magnet/function/debug_list_holders.mcfunction b/data/magnet/function/debug_list_holders.mcfunction index a7ce639..6f574fc 100644 --- a/data/magnet/function/debug_list_holders.mcfunction +++ b/data/magnet/function/debug_list_holders.mcfunction @@ -3,7 +3,7 @@ #execute as @e[type=!minecraft:player,nbt={ArmorItems:[{}, {tag: {isMagnet:1b}}, {}, {}]}, sort=random] at @s run say I am holding a magnet. # Make entities glow -effect give @e[type=!minecraft:player,nbt={ArmorItems:[{}, {tag: {isMagnet:1b}}, {}, {}]}] minecraft:glowing 30 0 true +effect give @e[type=!minecraft:player,nbt={ArmorItems: [{}, {components:{"minecraft:custom_data": {isMagnet: 1b}} }, {}, {}]}] minecraft:glowing 30 0 true # Command that lists them all + helper text -tellraw @s ["",{"text":"Loaded entities holding magnets:\n","bold":true,"color":"yellow"},{"text":" ["},{"selector":"@e[type=!minecraft:player,nbt={ArmorItems:[{}, {tag: {isMagnet:1b}}, {}, {}]}]"},{"text":"]\n\nThey have all been given glowing for 30 seconds.\nTo teleport to one of them hover over them in the list to get their UUID, then type: "},{"text":"/tp ","color":"yellow","clickEvent":{"action":"suggest_command","value":"/tp UUID"},"hoverEvent":{"action":"show_text","contents":"Suggest command"}},{"text":"\nYou should probably copy-paste them in from your log file.\n\nAlternatively, you can select them for commands via:\n"},{"text":"@e[type=!minecraft:player,nbt={ArmorItems:[{}, {tag: {isMagnet:1b}}, {}, {}]}]","color":"yellow","clickEvent":{"action":"copy_to_clipboard","value":"@e[type=!minecraft:player,nbt={ArmorItems:[{}, {tag: {isMagnet:1b}}, {}, {}]}]"},"hoverEvent":{"action":"show_text","contents":"Click to Copy"}}] \ No newline at end of file +tellraw @s ["",{"text":"Loaded mobs holding magnets:\n","bold":true,"color":"yellow"},{"text":"Legs: ["},{"selector":"@e[type=!minecraft:player,nbt={ArmorItems: [{}, {components:{'minecraft:custom_data': {isMagnet: 1b}} }, {}, {}]}]"},{"text":"]\nHandheld: ["},{"selector":"@e[type=!minecraft:player,nbt={HandItems: [{components:{'minecraft:custom_data': {isMagnet: 1b}}}]}]"},{"text":"]\n\nThey have all been given glowing for 30 seconds.\nUse this to teleport to one: "},{"text":"[Click to suggest legs command]","color":"yellow","clickEvent":{"action":"suggest_command","value":"/tp @e[type=!minecraft:player,nbt={ArmorItems: [{}, {components:{'minecraft:custom_data': {isMagnet: 1b}} }, {}, {}]}, limit=1]"},"hoverEvent":{"action":"show_text","contents":"Suggest command"}},{"text":" "},{"text":"[Click to suggest handheld command]","color":"yellow","clickEvent":{"action":"suggest_command","value":"/tp @e[type=!minecraft:player,nbt={HandItems: [{components:{'minecraft:custom_data': {isMagnet: 1b}}}]}, limit=1]"},"hoverEvent":{"action":"show_text","contents":"Suggest command"}},{"text":"\nYou can select them for commands via:\n"},{"text":"@e[type=!minecraft:player,nbt={ArmorItems: [{}, {components:{'minecraft:custom_data': {isMagnet: 1b}} }, {}, {}]}]","color":"yellow","clickEvent":{"action":"copy_to_clipboard","value":"@e[type=!minecraft:player,nbt={ArmorItems: [{}, {components:{'minecraft:custom_data': {isMagnet: 1b}} }, {}, {}]}]"},"hoverEvent":{"action":"show_text","contents":"Click to Copy"}}] diff --git a/data/magnet/function/give_magnet.mcfunction b/data/magnet/function/give_magnet.mcfunction index abc1c4a..2870e75 100644 --- a/data/magnet/function/give_magnet.mcfunction +++ b/data/magnet/function/give_magnet.mcfunction @@ -1,5 +1,7 @@ -# Gives the caller one properly formatted magnet item. The cause of the actual magnetism is the {isMagnet:1b} tag. -give @s minecraft:chainmail_leggings{isMagnet:1b, display:{Lore:["{\"text\":\" \"}", "{\"text\":\"When in main hand:\",\"color\":\"gray\",\"italic\":false}", "{\"text\":\"When in offhand:\",\"color\":\"gray\",\"italic\":false}", "{\"text\":\"When on legs:\",\"color\":\"gray\",\"italic\":false}", "{\"text\":\" 5 Block Item Magnetism\",\"color\":\"dark_green\",\"italic\":false}","{\"text\":\" 10 Block Item Sense\",\"color\":\"dark_green\",\"italic\":false}", "{\"text\":\"Works when equipped by mobs.\",\"color\":\"gray\"}"], Name:"{\"text\":\"Magnet\",\"italic\":false,\"color\":\"yellow\"}"}, HideFlags: 63, Unbreakable:1,Enchantments:[{id:"minecraft:invalid_enchantment_for_glimmer",lvl:1}]} 1 +execute as @s at @s run playsound minecraft:block.anvil.use voice @s ~ ~ ~ 0.25 1.5 -# Play a sound -execute as @s at @s run playsound minecraft:block.anvil.use voice @s ~ ~ ~ 0.25 1.5 \ No newline at end of file +give @s minecraft:iron_ingot 5 +give @s minecraft:red_dye 1 +give @s minecraft:blue_dye 1 + +tell @s Ingredients required to craft a magnet given. diff --git a/data/magnet/function/init.mcfunction b/data/magnet/function/init.mcfunction index dfd2a4e..8024757 100644 --- a/data/magnet/function/init.mcfunction +++ b/data/magnet/function/init.mcfunction @@ -1,14 +1,6 @@ # Print load message tellraw @a ["",{"text":"\u2714","color":"dark_green"},{"text":" Magnet datapack loaded.\nGet some iron and go craft a "},{"text":"Magnet","color":"yellow"},{"text":".\nMore info "},{"text":"here","underlined":true,"clickEvent":{"action":"open_url","value":"http://bit.ly/MagnetDatapack"}},{"text":".\nTo configure the datapack, click "}, {"text":"[here]","color":"yellow","clickEvent":{"action":"run_command","value":"/function magnet:toggle_options_pane"},"hoverEvent":{"action":"show_text","contents":"Toggle options pane"}},{"text":"\nor type: "},{"text":"/function magnet:toggle_options_pane","color":"yellow","clickEvent":{"action":"suggest_command","value":"/function magnet:toggle_options_pane"},"hoverEvent":{"action":"show_text","contents":"Click to suggest"}},{"text":"\n "}] -# Set up scoreboard values for tracking crafting of chainmail leggings -scoreboard objectives add m_craft_leggings minecraft.crafted:minecraft.chainmail_leggings -scoreboard objectives add m_count_magnets dummy -scoreboard objectives add m_count_reg_legs dummy - -# Fun crafted magnets counter -scoreboard objectives add m_total_crafted_magnets dummy "Magnets Crafted" - # Set up scoreboard values for timed magnetization and internal settings scoreboard objectives add m_internals dummy "Magnet Internal" @@ -45,4 +37,3 @@ scoreboard players operation optionsOpen m_internals *= optionsOpen m_internals # If setup never ran, run setup script execute if score ranSetup m_internals matches 0 run function magnet:default_configs - diff --git a/data/magnet/function/magnetize_item.mcfunction b/data/magnet/function/magnetize_item.mcfunction index 7852a8e..071a71e 100644 --- a/data/magnet/function/magnetize_item.mcfunction +++ b/data/magnet/function/magnetize_item.mcfunction @@ -13,6 +13,9 @@ execute if score enabledActionbarText m_options matches 1 run title @s actionbar # Particles on item execute if score particlesOnItem m_options matches 1 run execute as @e[limit=1,sort=nearest,distance=0..5,type=minecraft:item] at @s if entity @e[distance=0..5, type=item] run particle minecraft:reverse_portal ~ ~.25 ~ 0 0 0 0.1 3 normal +# TODO figure out how to dynamically select this particle's destination +# /particle minecraft:vibration{destination:{type:"block", pos:[0,0,0]}, arrival_in_ticks:100} + # Teleport nearest item entity to the function's caller tp @e[limit=1,sort=nearest,distance=0..5,type=minecraft:item] @s # Move 1 block towards the holder's feet (broken) diff --git a/data/magnet/function/on_mob_interval.mcfunction b/data/magnet/function/on_mob_interval.mcfunction index e651889..f9d1cb9 100644 --- a/data/magnet/function/on_mob_interval.mcfunction +++ b/data/magnet/function/on_mob_interval.mcfunction @@ -4,7 +4,10 @@ scoreboard players set m_timer_mob m_internals 0 #Random sort so that mobs 'fight' for items and if multiple have magnets they are more likely to suck up gear that others don't need # Detect magnet in armor stands' leggings armor slot. Exclude if all mobs is on -execute unless score allMobs_Laggy m_options matches 1 if score armorStand m_options matches 1 run execute as @e[type=minecraft:armor_stand, nbt={ArmorItems:[{}, {tag: {isMagnet:1b}}, {}, {}]}, sort=random] at @s run function magnet:magnetize_item +execute unless score allMobs_Laggy m_options matches 1 if score armorStand m_options matches 1 run execute as @e[type=minecraft:armor_stand, sort=random, nbt={ArmorItems: [{}, {components:{"minecraft:custom_data": {isMagnet: 1b}} }, {}, {}]}] at @s run function magnet:magnetize_item # Detect magnet in any mobs' leggings armor slot. -execute if score allMobs_Laggy m_options matches 1 run execute as @e[type=!minecraft:player,nbt={ArmorItems:[{}, {tag: {isMagnet:1b}}, {}, {}]}, sort=random] at @s run function magnet:magnetize_item \ No newline at end of file +execute if score allMobs_Laggy m_options matches 1 run execute as @e[type=!minecraft:player,nbt={ArmorItems: [{}, {components:{"minecraft:custom_data": {isMagnet: 1b}} }, {}, {}]}, sort=random] at @s run function magnet:magnetize_item + +# Detect magnet in any mobs' hand slot (ex. Foxes). +execute if score allMobs_Laggy m_options matches 1 run execute as @e[type=!minecraft:player,nbt={HandItems: [{components:{"minecraft:custom_data": {isMagnet: 1b}}}]}, sort=random] at @s run function magnet:magnetize_item diff --git a/data/magnet/function/on_player_interval.mcfunction b/data/magnet/function/on_player_interval.mcfunction index 5d634e4..31da651 100644 --- a/data/magnet/function/on_player_interval.mcfunction +++ b/data/magnet/function/on_player_interval.mcfunction @@ -2,9 +2,8 @@ scoreboard players set m_timer_player m_internals 0 # Detect magnet held in player main hand -execute if score playerHands m_options matches 1 run execute as @a[nbt={SelectedItem:{tag: {isMagnet:1b}}}] at @s run function magnet:magnetize_item +execute if score playerHands m_options matches 1 run execute as @a[gamemode=!spectator, nbt={SelectedItem:{components: {"minecraft:custom_data": {isMagnet: 1b}}}}] at @s run function magnet:magnetize_item # Detect magnet equipped in player offhand -execute if score playerHands m_options matches 1 run execute as @a[nbt={Inventory:[{Slot: -106b, tag: {isMagnet:1b}}]}] at @s run function magnet:magnetize_item - +execute if score playerHands m_options matches 1 run execute as @a[gamemode=!spectator, nbt={Inventory:[{Slot: -106b, components: {"minecraft:custom_data": {isMagnet: 1b}}}]}] at @s run function magnet:magnetize_item # Detect magnet equipped in player leggings slot -execute if score playerEquip m_options matches 1 run execute as @a[nbt={Inventory:[{Slot: 101b, tag: {isMagnet:1b}}]}] at @s run function magnet:magnetize_item +execute if score playerEquip m_options matches 1 run execute as @a[gamemode=!spectator, nbt={Inventory:[{Slot: 101b, components: {"minecraft:custom_data": {isMagnet: 1b}}}]}] at @s run function magnet:magnetize_item diff --git a/data/magnet/function/tick.mcfunction b/data/magnet/function/tick.mcfunction index e6d0704..a682b17 100644 --- a/data/magnet/function/tick.mcfunction +++ b/data/magnet/function/tick.mcfunction @@ -1,6 +1,3 @@ -# Detect players that have crafted at least one pair of leggings and deal with that -execute as @a[scores={m_craft_leggings=1..}] if score @s m_craft_leggings matches 1.. run function magnet:while001_crafted_legs - # Increment global timers by 1 scoreboard players add m_timer_player m_internals 1 scoreboard players add m_timer_mob m_internals 1 @@ -9,4 +6,4 @@ scoreboard players add m_timer_mob m_internals 1 execute if score m_timer_player m_internals >= m_player_interval m_options run function magnet:on_player_interval # If mob timer exceeds m_mob_interval, set it back to zero -execute if score m_timer_mob m_internals >= m_player_interval m_options run function magnet:on_mob_interval \ No newline at end of file +execute if score m_timer_mob m_internals >= m_player_interval m_options run function magnet:on_mob_interval diff --git a/data/magnet/function/uninstall.mcfunction b/data/magnet/function/uninstall.mcfunction index 86203d9..0875fee 100644 --- a/data/magnet/function/uninstall.mcfunction +++ b/data/magnet/function/uninstall.mcfunction @@ -1,13 +1,7 @@ - advancement revoke @a only magnet:root scoreboard objectives remove m_internals scoreboard objectives remove m_options -scoreboard objectives remove m_total_crafted_magnets - -scoreboard objectives remove m_count_magnets -scoreboard objectives remove m_count_reg_legs -scoreboard objectives remove m_craft_leggings team remove magnet_internal -team remove magnet_option \ No newline at end of file +team remove magnet_option diff --git a/data/magnet/function/while001_crafted_legs.mcfunction b/data/magnet/function/while001_crafted_legs.mcfunction deleted file mode 100644 index 2517366..0000000 --- a/data/magnet/function/while001_crafted_legs.mcfunction +++ /dev/null @@ -1,29 +0,0 @@ -# Based off of watermill:while043_ln150 -#say Running while001_crafted_legs - -# Increase the safety stopper -scoreboard players add craftSafetyStopper m_internals 1 - -# Empty the player's inventory of magnets and regular chainmail leggings, storing the count of each in counter variables so they can be returned -execute store result score @s m_count_magnets run clear @s chainmail_leggings{isMagnet:1b} -execute store result score @s m_count_reg_legs run clear @s chainmail_leggings -# {Damage: 0} tried to track undamaged chain leggings but it didn't work, probably because it's the blank thing - -# Give back the correct number of magnet leggings -execute if score @s m_count_magnets matches 1.. run function magnet:while002_return_magnets - -# Give magnet leggings for the leggings that were crafted to be turned into magnets, taking away from the number of regular leggings to return as well (since those were the ones we just crafted) -execute if score @s m_count_reg_legs matches 1.. if score @s m_craft_leggings matches 1.. run function magnet:while003_give_magnets_when_new_crafted - -# Give back the remaining regular leggings (the ones we didn't craft, they were already in our inv) -execute if score @s m_count_reg_legs matches 1.. run function magnet:while004_return_regular_leggings - -# Safety for if this runs too many times without succeeding in completing its task -execute if score craftSafetyStopper m_internals matches 100.. run function magnet:crafting_dropped_item_error - -# Debugging always stop after one pass -#scoreboard players set @s m_craft_leggings 0 - -# Run the function again if there is still a crafted leggings score for the player -# Need this off to prevent superlag when the player dropped the item on the ground instead of taking it into their inventory -#execute if score @s m_craft_leggings matches 1.. run function magnet:while001_crafted_legs diff --git a/data/magnet/function/while002_return_magnets.mcfunction b/data/magnet/function/while002_return_magnets.mcfunction deleted file mode 100644 index dde35f3..0000000 --- a/data/magnet/function/while002_return_magnets.mcfunction +++ /dev/null @@ -1,11 +0,0 @@ -# Based off of watermill:while040_ln156 -#say Running while002_return_magnets - -# Give the caller one magnet -function magnet:give_magnet -# Subtract 1 from the 'magnets to return' count -scoreboard players remove @s m_count_magnets 1 - - -# Run this function again if there are still magnets to return -execute if score @s m_count_magnets matches 1.. run function magnet:while002_return_magnets \ No newline at end of file diff --git a/data/magnet/function/while003_give_magnets_when_new_crafted.mcfunction b/data/magnet/function/while003_give_magnets_when_new_crafted.mcfunction deleted file mode 100644 index e52211a..0000000 --- a/data/magnet/function/while003_give_magnets_when_new_crafted.mcfunction +++ /dev/null @@ -1,17 +0,0 @@ -# Based off of watermill:while041_ln160 -#say Running while003_give_magnets_when_new_crafted - -# Give the caller one magnet -function magnet:give_magnet -# Subtract 1 from the 'regular leggings to return' count and 1 from the 'crafted leggings' count -scoreboard players remove @s m_count_reg_legs 1 -scoreboard players remove @s m_craft_leggings 1 - -# bump the total magnets crafted counter -scoreboard players add @s m_total_crafted_magnets 1 - -# Run this function again if there are still magnets to return (?) -execute if score @s m_count_reg_legs matches 1.. if score @s m_craft_leggings matches 1.. run function magnet:while003_give_magnets_when_new_crafted - -# Otherwise set the safety stopper back to 0 -scoreboard players set craftSafetyStopper m_internals 0 \ No newline at end of file diff --git a/data/magnet/function/while004_return_regular_leggings.mcfunction b/data/magnet/function/while004_return_regular_leggings.mcfunction deleted file mode 100644 index 2102dd6..0000000 --- a/data/magnet/function/while004_return_regular_leggings.mcfunction +++ /dev/null @@ -1,13 +0,0 @@ -# Based off of watermill:while042_ln165 -#say Running while004_return_regular_leggings - -# Give the caller regular leggings -give @s chainmail_leggings 1 -# Subtract 1 from the 'leggings to return' count -scoreboard players remove @s m_count_reg_legs 1 - -# Inform players that had regular chainmail leggings in their inventory that the process of returning them isn't perfect -tellraw @s ["",{"text":"\u26a0","color":"yellow"},{"text":" You had chainmail leggings in your inventory when crafting a Magnet. They may have lost some of their item data. This is due to datapack limitations. Please avoid crafting Magnets while you have regular chainmail leggings in your inventory in the future.","italic":true,"color":"gray"}] - -# Run this function again if there are still leggings to return -execute if score @s m_count_reg_legs matches 1.. run function magnet:while004_return_regular_leggings \ No newline at end of file diff --git a/data/magnet/recipe/magnet_blue_red.json b/data/magnet/recipe/magnet_blue_red.json index 4dd036f..9a3b72c 100644 --- a/data/magnet/recipe/magnet_blue_red.json +++ b/data/magnet/recipe/magnet_blue_red.json @@ -1,26 +1,45 @@ { - "type": "minecraft:crafting_shaped", - "group": "magnet", - "category": "equipment", - "key": { - "I": { - "item": "minecraft:iron_ingot" - }, - "B": { - "item": "minecraft:blue_dye" - }, - "R": { - "item": "minecraft:red_dye" - } - }, - "pattern": [ - "III", - "I I", - "B R" - ], - "result": { - "id": "minecraft:chainmail_leggings", - "count": 1, - "components": {} - } + "type": "minecraft:crafting_shaped", + "group": "magnet", + "category": "equipment", + "key": { + "I": { + "item": "minecraft:iron_ingot" + }, + "B": { + "item": "minecraft:blue_dye" + }, + "R": { + "item": "minecraft:red_dye" + } + }, + "pattern": [ + "III", + "I I", + "B R" + ], + "result": { + "__comment": "Remember to keep in sync with the other recipe file!", + "id": "minecraft:chainmail_leggings", + "count": 1, + "components": { + "minecraft:enchantment_glint_override": true, + "minecraft:custom_name": "[{'text':'Magnet','italic':false,'color':'yellow'}]", + "hide_additional_tooltip": {}, + "minecraft:lore": [ + "[{'text':''}]", + "[{'text':'When in Main Hand:', 'italic':false, 'color':'gray'}]", + "[{'text':'When in Off Hand:', 'italic':false, 'color':'gray'}]", + "[{'text':'When on Legs:', 'italic':false, 'color':'gray'}]", + "[{'text':' 5 Block Item Magnetism', 'italic':false, 'color':'dark_green'}]", + "[{'text':' 10 Block Item Sense', 'italic':false, 'color':'dark_green'}]", + "[{'text':'Works when equipped by mobs', 'italic':true, 'color':'gray'}]", + "[{'text':'when configuration enables it.', 'italic':true, 'color':'gray'}]" + ], + "minecraft:custom_data": { + "isMagnet": true + }, + "minecraft:unbreakable": {} + } + } } \ No newline at end of file diff --git a/data/magnet/recipe/magnet_red_blue.json b/data/magnet/recipe/magnet_red_blue.json index 5e65864..e437bd4 100644 --- a/data/magnet/recipe/magnet_red_blue.json +++ b/data/magnet/recipe/magnet_red_blue.json @@ -1,26 +1,45 @@ { - "type": "minecraft:crafting_shaped", - "group": "magnet", - "category": "equipment", - "key": { - "I": { - "item": "minecraft:iron_ingot" - }, - "R": { - "item": "minecraft:red_dye" - }, - "B": { - "item": "minecraft:blue_dye" - } - }, - "pattern": [ - "III", - "I I", - "R B" - ], - "result": { - "id": "minecraft:chainmail_leggings", - "count": 1, - "components": {} - } + "type": "minecraft:crafting_shaped", + "group": "magnet", + "category": "equipment", + "key": { + "I": { + "item": "minecraft:iron_ingot" + }, + "R": { + "item": "minecraft:red_dye" + }, + "B": { + "item": "minecraft:blue_dye" + } + }, + "pattern": [ + "III", + "I I", + "R B" + ], + "result": { + "__comment": "Remember to keep in sync with the other recipe file!", + "id": "minecraft:chainmail_leggings", + "count": 1, + "components": { + "minecraft:enchantment_glint_override": true, + "minecraft:custom_name": "[{'text':'Magnet','italic':false,'color':'yellow'}]", + "hide_additional_tooltip": {}, + "minecraft:lore": [ + "[{'text':''}]", + "[{'text':'When in Main Hand:', 'italic':false, 'color':'gray'}]", + "[{'text':'When in Off Hand:', 'italic':false, 'color':'gray'}]", + "[{'text':'When on Legs:', 'italic':false, 'color':'gray'}]", + "[{'text':' 5 Block Item Magnetism', 'italic':false, 'color':'dark_green'}]", + "[{'text':' 10 Block Item Sense', 'italic':false, 'color':'dark_green'}]", + "[{'text':'Works when equipped by mobs', 'italic':true, 'color':'gray'}]", + "[{'text':'when configuration enables it.', 'italic':true, 'color':'gray'}]" + ], + "minecraft:custom_data": { + "isMagnet": true + }, + "minecraft:unbreakable": {} + } + } } \ No newline at end of file diff --git a/pack.mcmeta b/pack.mcmeta index 99a6d25..81a24f0 100644 --- a/pack.mcmeta +++ b/pack.mcmeta @@ -1,6 +1,6 @@ - { - "pack": { - "pack_format": 3, - "description": "More info here: http://bit.ly/MagnetDatapack" - } - } \ No newline at end of file +{ + "pack": { + "pack_format": 48, + "description": "Magnet v4.0.0 for Minecraft 1.21. More info here: http://bit.ly/MagnetDatapack" + } +}