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

Datapack - Modded Items #53

Closed Yeetmister closed 2 years ago

Yeetmister commented 3 years ago

I have gotten a datapack to work with vanilla items, but cannot get it to work with modded items, I am entering everything from what it seems correctly.

datapacks\itemleveledit\data\levelz\item\bluenetheritesword.json

{ "replace": true, "skill": "strength", "level": 20, "item": "dyeablenetherite:blue_netherite_sword" }

I have tried other weapons & items including those from an entirely different mod to no avail.

Globox1997 commented 3 years ago

The item section here: https://github.com/Globox1997/LevelZ#4-item tells that "item" without a "material" can only have certain values but your goal is to lock a material behind a level which means: ´ "item" : "minecraft:sword", "material" : "blue_netherite" ´ "material" has to get the correct name string, idk if blue netherite is correct, just a guessing

wolfkidsounds commented 3 years ago

Does that mean, that basicly every sword added is registered as "minecraft:sword"? Wondering because I wanted to add "flintytools" ?

Globox1997 commented 3 years ago

Yes exactly. LevelZ doesn't check for single items (except for a few), it reads just the material

Khytwel commented 3 years ago

And would it be possible to add this feature for modded items? Because the problem with material is that it is not precise (for example, a Drill that uses diamond will be at the same level as a diamond pickaxe which is a bit annoying).

Globox1997 commented 2 years ago

With update 1.1.0 datapack creators will be able to lock other mods items/blocks/entities, explained in the readme. It will come out for mc 1.18 :)

Khytwel commented 2 years ago

You just made a man very happy with this addition, thank you!

Skyphiler commented 2 years ago

hello i'm trying to make a data pack to lock the rosegold set of tool and armor of additional addition and following the Readme { "replace": false, "skill": "mining", "level": 12, "block": "minecraft:custom_item", "object": "additionaladditions:rose_gold_pickaxe" } is what I did for one of theme, but it doesn't seem's to work sorry if it seem's like a stupid question but am I doing something wrong? (I moddified vanilla asset to test and it work) edit: I'm using ver. 1.1.1

Globox1997 commented 2 years ago

doesn't look bad but tools/swords have to get looked via the material like:

{
"replace": false,
"skill": "mining",
"level": 12,
"item": "minecraft:tool",
"material": "??rose_gold??"
}

the material string has to be correct, don't know what it is for the mod

Khytwel commented 2 years ago

But I don't understand, why not make it work for the other tools as well (axe, pickaxe, etc...). Whether it's the Rose Gold tools (material in the code of the mod: rosegold) or the TechReborn tools, it simply does not work.

{ "replace": true, "skill": "mining", "level": 24, "item": "minecraft:tool", "material": "industrial" }

image image image

Globox1997 commented 2 years ago

"tool" equals here pickaxes and shovels, swords, hoes and axes are separated as the readme says. the industrial drill has the diamond tool material so it is bound to it, you can see it here at the constructor https://github.com/TechReborn/TechReborn/blob/1.18/src/main/java/techreborn/items/tool/industrial/IndustrialDrillItem.java

Skyphiler commented 2 years ago

I was able to make the armor set to work with { "replace": false, "skill": "defense", "level": 12, "item": "minecraft:armor", "material": "rose_gold" } but for the tool/axe/hoe/sword the using the material line doesn't seem's to work, maybe someting with how the mod AA is built so I was planning on using the custom item restriction method for them but it doesn't work

Khytwel commented 2 years ago

"tool" equals here pickaxes and shovels, swords, hoes and axes are separated as the readme says. the industrial drill has the diamond tool material so it is bound to it, you can see it here at the constructor https://github.com/TechReborn/TechReborn/blob/1.18/src/main/java/techreborn/items/tool/industrial/IndustrialDrillItem.java

This is very annoying, especially since in the example of the Drill. Even if it was not linked to the Diamond material, it would not be very logical to see "Industral Tool" in the UI of the mod knowing that the Drill does pickaxe + shovel at the same time.

image By the way, the rendering is a bit weird for the items that work with your new system (which is still interesting, thanks for adding it)

Globox1997 commented 2 years ago

I was able to make the armor set to work with { "replace": false, "skill": "defense", "level": 12, "item": "minecraft:armor", "material": "rose_gold" } but for the tool/axe/hoe/sword the using the material line doesn't seem's to work, maybe someting with how the mod AA is built so I was planning on using the custom item restriction method for them but it doesn't work

Custom item restriction doesn't work for tools and from which mod is the rose gold material?

"tool" equals here pickaxes and shovels, swords, hoes and axes are separated as the readme says. the industrial drill has the diamond tool material so it is bound to it, you can see it here at the constructor https://github.com/TechReborn/TechReborn/blob/1.18/src/main/java/techreborn/items/tool/industrial/IndustrialDrillItem.java

This is very annoying, especially since in the example of the Drill. Even if it was not linked to the Diamond material, it would not be very logical to see "Industral Tool" in the UI of the mod knowing that the Drill does pickaxe + shovel at the same time.

image By the way, the rendering is a bit weird for the items that work with your new system (which is still interesting, thanks for adding it)

I don't get the first point, does a drill work as a shovel and pickaxe? The screenshot looks like the name string doesn't get read correctly How is the rendering weird? What exactly happens?

Khytwel commented 2 years ago

When I said "rendering" it was meant: it's read strangely (everything is correct in the file). For the first point, yes

Skyphiler commented 2 years ago

the rose gold is from additional addition https://github.com/Dqu1J/additionaladditions

Skyphiler commented 2 years ago

And I second what Khytwel said about the ''rendering'' when you add a custom block in the UI it give modid:blockid [ex:harvest scythes:wooden machete] it should just show blockid for this exemple wodden machete

Globox1997 commented 2 years ago

So the rose gold item restriction won't work cause levelz can't read the correct material name :/ Vanilla mc has an enum instead of separating all materials into classes. here https://github.com/Dqu1J/additionaladditions/blob/main/src/main/java/dqu/additionaladditions/material/RoseGoldToolMaterial.java

Globox1997 commented 2 years ago

Fixed gui with https://github.com/Globox1997/LevelZ/commit/3d96c1421be71b4d84205f38e235f6cfce23adb1

Globox1997 commented 2 years ago

It is interesting that the scythe mod doesn't add its scythes to the fabric hoe tag cause those are instances of hoes. If it would be in the hoe tag, custom restriction wouldn't work and they would be bound to the hoe restriction (depends on material)

Globox1997 commented 2 years ago

So there are three ways to fix the rosegold tool material issue:

wolfkidsounds commented 2 years ago

So there are three ways to fix the rosegold tool material issue:

What about restricting the item in general without needing the material tag? - For me personally it overcomplicates things or is this a general restriction that you bypass using the materials?

Like if one would restrict the item it would be cool if we could just follow the same rules everywhere:

"replace" "skill" "level" "block/item" (inserting just the mod:id here?)

I guess I just oversimplify it right now :s


For example I would like to restrict "quivers" behind archery. Or swords from "betternether" which do not have the swords tag.

wolfkidsounds commented 2 years ago

I've tried the datapack situation but actually could not get it to work - essentially what makes this a little difficult is that mods like paxi and openloader can not override that standard fabric tags making it definitly a little harder for modpacks (also they are not yet available for 1.18)

Khytwel commented 2 years ago

It is interesting that the scythe mod doesn't add its scythes to the fabric hoe tag cause those are instances of hoes. If it would be in the hoe tag, custom restriction wouldn't work and they would be bound to the hoe restriction (depends on material)

Indeed, I had not noticed. I removed the tags from the drill to test and it works. The only current problem I have is that the drill is not marked in the GUI, but this can be solved by creating a fake tool file with the drill name as material.

Edit: image Small problem, the custom item for the mining category, the necessary level information is put in the farming category (in the screenshot example, the drill and jackhammer should not be present). Same for the custom sword.

Edit++: When we do not have the necessary level for a custom item, we can still use it and no malusse is applied.

Globox1997 commented 2 years ago

The answer why levelz takes the material for such items is, I made it as performant as possible. Of course some mods need tweaks for that cause they don't stick to the vanilla code style but that is the compromise. Those new custom restrictions are not as performant especially for tools (cause they get checked multiple times in a second when used) cause at the end all non custom restrictions have their own list to get checked if the player has the required level, all custom restrictions are filled in one list and when they get used, the server and or client has to go trough the whole list and look if it exist and if the player meets the required levels.

Khytwel commented 2 years ago

And your answer is quite justified, especially when it works directly with some mods. On my side, I will contact the mods developers to support the material properly. On the other hand, some tools are not necessarily adapted with the material system.

Globox1997 commented 2 years ago

Yes some tools are not adapted but that is the performance compromise. So I could add the custom check for tools but I'm not sure if this is a good idea.

Khytwel commented 2 years ago

https://github.com/Technici4n/TechReborn/blob/custom-tool-materials/src/main/java/techreborn/init/TRToolMaterials.java Here is their change to support LevelZ. On the other hand, even if the tool is blocked it still does damage (so the malus is not applied). According to their developer they can't do much because they use their own system.

image The material is "techreborn:advanced_drill", would there be a way for the tool to be read correctly?

wolfkidsounds commented 2 years ago

@Globox1997 - thanks for taking the time explaining the issues. You are really responsive and Its great you still answer these questions. - I was thinking about somewhat to abstract solutions to the problem..

jexline commented 2 years ago

I've had requests to make my mods compatible with this, so I have set up my tool materials as done in the TechReborn mod above. What would I have to do next to lock the tools and armors? EDIT: Just read the part about adding them in, but does it go in my save folder; then data? or datapacks, then another folder called data?

Globox1997 commented 2 years ago

I recommend to check out Data pack and also an existing datapack. in the "datapacks" folder you have to put your zip file and inside the zip file, the top folder is the "data" folder

Globox1997 commented 2 years ago

@jexline so tha path is when you open your zip file: data/levelz/item/examplefile.json

Since v1.2 (not sure but the latest is definitely right) you can even use "item": "minecraft:custom_item" for restricting items but I always recommend to use the material for restriction, sometimes this won't work for example if a mod doesn't use an enum for materials.