seeloewen / random-item-giver-datapack Goto Github PK
View Code? Open in Web Editor NEWGet a random item every x seconds! The time is fully customizable and you can also select which types of items you want to receive.
Get a random item every x seconds! The time is fully customizable and you can also select which types of items you want to receive.
Because Random Item Giver Datapack 1.4.5 fixed the suspicious stews by changing the NBT, the software will no longer recognise it. Therefore, support for the new tag needs to be added.
The ingame help menu does currently not contain anything useful, just some basic information. It could be improved with some general information and an FAQ on how to use/install the datapack for example and solutions for common issues.
Here's an idea of how the menu could be structured:
Help
╠ General Overview
║ ╚ General overview of what the datapack does
╠ Settings
║ ╚ A list of how to change the most common settings like timer and item categories
╠ Common Issues
║ ╚ Issues like version incompatibility, wrong folder, etc.
╚ Installation on Server
___╚ Where to install the datapack on a server
While it's currently entirely possible to set a custom timer, both using the given options to add/remove seconds as well as just using the scoreboard command manually, it would be cool to have some sort of keypad to set a custom timer. Should theoretically be possible. You'd have 10 buttons, 1 for each number, as well as a button to confirm and backspace. The numbers would go into variables. When confirming, the numbers would be multiplied and added to form the correct output. Once again, this is not really something the datapack really needs or something that's important, more of a personal challenge. Could be added to the datapack soon, maybe not, maybe never.
This version aims to be a big Quality of Life (QoL) update that adds a bunch of useful new settings to the datapack. Additionally, with the planned update to 1.20.2 the Random Number Generator by CloudWolf will be replaced with the new /random command.
Remove the special loot tables and make one loot table for normal items, one for command blocks, one for spawn eggs and one for other creative-only items
The newly added painting variants will be moved to their own loot table, as they appear way too often.
Currently, while everyone receives a random item when playing multiplayer, they always get the same type. If a normal item is rolled, everyone gets a random normal item at the same time. When a goat horn is rolled, a everyone receives a random goat horn.
It should theoretically be possible to make everyone receive a random type of item. By rolling the random number for each person seperately and not for the RandomItemGiver in general, everyone gets a random item from a random loot table.
Edit 25.03.2024: Just found out that components are way bigger of a change, see comment below.
The recent snapshot 24w09a broke the entire datapack by randomly changing how NBT tags are formatted. This was done for "Performance improvements" and to make it more reliable in the future, but I don't really see how these changes are anything but annoying. Anyways, basically all loot tables that have NBT tags for their items need to be redone, so here`s a list of what changed in each loot table:
command_blocks.json: No changes
enchanted_books.json: {StoredEnchantments:[{id:bane_of_arthropods,lvl:1}]} => stored_enchantments={levels:{'minecraft:bane_of_arthropods':1}}
goat_horns.json: {instrument:"minecraft:ponder_goat_horn"} => instrument='minecraft:ponder_goat_horn'
lingering_potions.json: {Potion:"minecraft:strength"} => potion_contents={potion:'minecraft:strength'}
normal_items.json: No changes
other_items.json: No changes
paintings.json: {EntityTag:{variant:"minecraft:alban"}} => entity_data={variant:'minecraft:alban'}
potions.json: {Potion:"minecraft:strength"} => potion_contents={potion:'minecraft:strength'}
spawn_eggs.json: No changes
splash_potions.json: {Potion:"minecraft:strength"} => potion_contents={potion:'minecraft:strength'}
suspicious_stews.json: {Effects:[{EffectId:8,EffectDuration:120}]} => suspicious_stew=[{id:'minecraft:jump_boost',duration:120}]
tipped_arrows.json: {Potion:"minecraft:strength"} => potion_contents={potion:'minecraft:strength'}
As you can probably see, all of these changes are pretty small and only affect formatting, yet they require rewriting a bunch of code. FOrtunately, because these changes are all quite similar, they can be done using a script/tool, which takes the values out of the old tags and puts them into the new ones. I will soon provide a tool which can be used to update existing datapacks to the 24w09a changes. Please note that this tool will most likely only work with datapack made for 1.20.4+ because of the structure.
To-Do for RIG Snapshot 24w09a Updater Software:
When using the Random Item Giver Skyblock Map on a server you need OP to claim the quick start kit. This is fine if you're just playing with some friends but when playing with people you don't know/trust, for example when doing bigger projects or on public servers, giving everyone op is not possible.
There is a /trigger command which somehow let's you run functions without OP. Not sure how it works but I'm gonna look into implementing it.
This version aims to add new features to the datapack by giving commands blocks a use and including better support for the new Random Item Giver Updater app.
Hi again & thanks for your great support on this awesome datapack.
Is there a function to give a specific player random item?
This version will be released for 1.19 to 1.19.2 and 1.16.2 to 1.16.5
And additionally...
What's the bug?
Strength is misspelled in the loot table which causes strength potions, lingering potions, splash potions and arrows to not work.
This small update will raise the datapack version to assure compatibility with 1.20.5. It also replaces all NBT tags with Item Stack Components.
This update will of course feature everything added in 1.4.5. This will basically be a port, nothing more.
When playing with multiple people, the items counted to the items received is multiplied by the number of players. Example: You receive 1 item with 3 players online, items received is increased by 3.
The bossbar does not currently show how many seconds are left until you get an item. Would be a neat feature.
This version will add some improvements to the datapack to improve compatibility, as well as fix some important issues. All these features will also be gradually added to the 1.21 version.
Because the objective names are currently very generic, other datapacks might also use the same ones and thus cause issues. To avoid this, I'll make them unique by adding a prefix
All of these files are in desperate need of grammar and spelling fixes as I've written them a while ago when I wasn't very good at English. Some information in those files is also quite outdated. By updating them, they'll be easier to understand and provide clearer information.
- [ ] Add support for 1.20.5
This update will still target 1.20.4 as I think that this version of MC may be in use for longer because of it being the last version to support NBT
While playing 1.4.4 for 1.20.4 on multiplayer I noticed that none of the items with NBT are working. Even though NBT is being replaced I should still look into it.
Actually: So far only suspicious stews seem affected.
This update will be released for 1.16 and 1.19. It will fix few typos and grammatical mistakes that occur throughout the datapack menus.
Ever since the release of the datapack, the most common issue was version mismatch. MC has this issue, where it won't load any loot tables that contain items that do not exist in the version. Until this gets hopefully fixed someday (Doesn't seem to be that big of an issue, just ignore the items that don't exist and load the rest?) the issue will persist. This issue is unfortunately not obvious to the user, as they still see the UI but don't get any items. I've always wanted to add some kind of version checker to the datapack, but there's pretty much no way to check the MC version from the datapack - or is there?
I've come up with an idea on how to check for the version. It's unfortunately a pretty primitive check and needs to be adapted manually for each version, but that shouldn't be that big of a deal. Here's how it works. There will be 2 new variables: rig_CheckedCompatibility (resets to 0 when reloading) and rig_VersionCheck (also resets to 0 every reload). The compatibility check will be run of the timer would give it's first item and if rig_CheckedCompatibility is 0:
In main.mcfunction:
execute if score RandomItemGiver rig_GiveItemNow matches 1 if score RandomItemGiver rig_GiveItems matches 2 if score RandomItemGiver rig_CheckedCompatibility matches 0 run function randomitemgiver:compatibilitychecker
In reload.mcfunction:
scoreboard objectives add rig_CheckedCompatibility dummy
scoreboard objectives add rig_VersionCheck dummy
...
scoreboard players set RandomItemGiver rig_CheckedCompatibility 0
scoreboard players set RandomItemGiver rig_VersionCheck 0
The check itself is pretty straight forward. First, it places a chest at 0 255 0 and inserts an item that only exists in 1.16 and above. It then uses a command to check whether the chest contains an item. If it does, that means that we are in 1.16 or above, it adds 1 score to rig_VersionCheck. If not, we have found a compatibility issue. After that, it deletes the chest.
We will repeat this to narrow down the version. The process gets repeated, but with a 1.17-only item. Once again, if the item is in the chest, we are 1.17 or above and we add 1 more to the score rig_VersionCheck which would now be 2. If not, compatibility issue.
This will be repeated until were in the most recent version. After all checks are done the pack will check the score of rig_VersionCheck. If it's 0, we know that it failed the 1.16 check and the game must be running in 1.15 or below. If it's one, we know it failed at 1.17, it it's 2 it failed at 1.18 and so on. The user will then receive a version showing the version the game was diagnosed to be running and the version the datapack was made for. There might also possibly be a link to a fitting version of the pack (If available).
The items for the versions would be stored in seperate loot tables, as using direct commands would break the whole mcfunction file. All in all, this would probably look like this:
compatibilitychecker.mcfunction
#Disable Command Block feedback to hide 'Executed commands from function' message and schedule enabling it again
gamerule sendCommandFeedback false
schedule function randomitemgiver:reset_feedback 1t
#Check for 1.16
setblock 0 255 0 chest
loot insert 0 255 0 loot randomitemgiver:compatibilitycheck/1-16
execute if data block 0 255 0 Items[{Count:1b}] run scoreboard players add RandomItemGiver rig_VersionCheck 1
setblock 0 255 0 air
#Check for 1.17
setblock 0 255 0 chest
loot insert 0 255 0 loot randomitemgiver:compatibilitycheck/1-17
execute if data block 0 255 0 Items[{Count:1b}] run scoreboard players add RandomItemGiver rig_VersionCheck 1
setblock 0 255 0 air
#Check for 1.18
setblock 0 255 0 chest
loot insert 0 255 0 loot randomitemgiver:compatibilitycheck/1-18
execute if data block 0 255 0 Items[{Count:1b}] run scoreboard players add RandomItemGiver rig_VersionCheck 1
setblock 0 255 0 air
#Check for 1.19
setblock 0 255 0 chest
loot insert 0 255 0 loot randomitemgiver:compatibilitycheck/1-19
execute if data block 0 255 0 Items[{Count:1b}] run scoreboard players add RandomItemGiver rig_VersionCheck 1
setblock 0 255 0 air
#Check for 1.20
setblock 0 255 0 chest
loot insert 0 255 0 loot randomitemgiver:compatibilitycheck/1-20
execute if data block 0 255 0 Items[{Count:1b}] run scoreboard players add RandomItemGiver rig_VersionCheck 1
setblock 0 255 0 air
#Check final result
execute if score RandomItemGiver rig_VersionCheck matches 0 run tellraw @s "Error: Detected 1.15 or below! ..."
execute if score RandomItemGiver rig_VersionCheck matches 1 run tellraw @s "Error: Detected 1.16! ..."
execute if score RandomItemGiver rig_VersionCheck matches 2 run tellraw @s "Error: Detected 1.17! ..."
execute if score RandomItemGiver rig_VersionCheck matches 3 run tellraw @s "Error: Detected 1.18! ..."
execute if score RandomItemGiver rig_VersionCheck matches 4 run tellraw @s "Error: Detected 1.19! ..."
scoreboard players set RandomItemGiver rig_CheckedCompatibility 1
While I've not tested it yet it should work out pretty fine. With the right adjustments and maybe some additional checks for other things I might also be able to narrow down the version even more (by using certain files that only work in certain versions because of command changes for example), but I'm happy if it works this way. Only downside I found so far is that it only detects issues if you're on a datapack that is too new for you version. Maybe I'll find a check for the other way around as well, we'll see. Not sure when or if I'm gonna implement this, for now it's just a theory.
The chance of getting a smithing template or a pottery sherd is currently way to high, and even worse, they're pretty useless. That's why the chance for them needs to be lowered. Moving them to their own loot table will also allow me to add an option to completely disable them (couldn't imagine why anyone would want that ;) ).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.