You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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 text was updated successfully, but these errors were encountered:
Will look into this soon, just because I'm curious whether it would work. Also noticed something when going through it, I should probably force load the chunk while it's doing the check (or is 0,0 always force loaded?)
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:
In reload.mcfunction:
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
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 text was updated successfully, but these errors were encountered: