Globox1997 / LevelZ

https://modrinth.com/mod/levelz
https://www.curseforge.com/minecraft/mc-mods/levelz
GNU General Public License v3.0
51 stars 50 forks source link

Replace only works occasionally in datapack #92

Closed Kalikimaka closed 2 years ago

Kalikimaka commented 2 years ago

I have been wracking my brain on how to get this mod to work with me. So, for blocks that aren't already locked it's very easy to lock em up for mining, but for ones that have a default mining level then it gets wonky. After many hours of testing every possible thing I could think of, I managed to get this to work...

{ "replace": true, "level": 2, "block": [ "minecraft:gravel", "minecraft:sand", "minecraft:red_sand", "minecraft:stone", "minecraft:andesite", "minecraft:granite", "minecraft:diorite" ] } but other similar stuff doesn't work. for example... { "replace": true, "level": 20, "block": [ "minecraft:deepslate", "minecraft:deepslate_gold_ore", "minecraft:deepslate_diamond_ore", "minecraft:deepslate_emerald_ore", "minecraft:wither_rose" ] } in the second one the only one that works is the wither rose because it doesn't have a default mining level. Deepslate stays at mining level 4. I don't know if there is a reason why my second one isn't working, but the first one is?

I am not sure how to get github to keep the spacing, but my spacing is just like how the wiki is.

Miku0Sama commented 2 years ago

So, based on my limited understanding, I believe the reason this is happening is because by making replace true you aren't replacing the level requirements for the list of blocks but rather you are replacing the blocks that the level unlocks. If that makes sense. So to stop it from happening, you would need to make replace true for level 4 and make sure Deepslate isn't in the list.

Also as for spacing, you technically don't need any as white space is ignored unless it is inside quotes. Here is an example of where white space is read and is not read by the computer: spacesMatter = "the spaces in this string matter"; reads as: spacesMatter="the spaces in this string matter";

spacesDontMatter= string(
someVariable +      anotherVariable+
oneMore

);

reads as: spacesDontMatter=string(someVariable+anotherVariable+oneMore); White space in any form of code is often just for user readability.

Kalikimaka commented 2 years ago

Thanks for your help. At first when I tried what you said it didn't work and then I kept messing around with it and it eventually started working again. I don't know why it didn't work at first, but I'm not gonna question it :)