SHsuperCM / CITResewn

Fabric implementation of mcpatcher's cit
MIT License
143 stars 71 forks source link

[Question/Help] Multiple conditions #399

Open PenT1x opened 1 month ago

PenT1x commented 1 month ago

Is there a way to have multiple conditions? I want to change the armor layer when the armor has both protection 1 and unbreaking 1. Because if you do this: type=armor items=diamond_helmet diamond_chestplate diamond_leggings diamond_boots texture.diamond_layer_1=u1_d_l_1 texture.diamond_layer_2=u1_d_l_2 enchantments=unbreaking protection enchantmentLevels=1

Then it is going to change the layer when the enchantment is unbreaking OR protection with level 1. And not when it is unbreaking 1 AND protection 1.

Is there a way to do like an AND on the enchantments?

HiWord9 commented 1 month ago

There is a way.

I remember a pack which has a lot of different textures for a lot of enchantment combinations for swords, but i could not find it. Instead, I found this pack for enchanted swords which supports combined textures for up to 2 enchantments. Take a look of how to do it in it.

The way it works is that it uses nbt instead of enchantment property, and so as enchantment property is simplified in way that it matches not all provided enchantments but any, u would not like to use it for ur purposes but nbt. The nbt have to be matched completely.

image As u can see in this example, the property file contains 2 lines for nbt.Enchantments. but nothing for enchantments and it works perfectly.

The property nbt.Enchantments.0.id= specifies how enchantment is called, i believe something like nbt.Enchantments.0.level= should specify the level of it, not sure. Note that 0 means index in list since nbt.Enchantments is a list. Try to look for other packs with similar purposes as urs and im sure u will find some useful info. Mb citr wiki can help u too.

Hope it helps

PenT1x commented 1 month ago

Ohh thanks. I also want to check the level. So that would be something like this: nbt.Enchantments.0.id=unbreaking nbt.Enchantments.0.lvl=1 nbt.Enchantments.1.id=protection nbt.Enchantments.1.lvl=1

But what if it isn't in that order. Do I then have to have 2 files with both compinations? And what if the armor has more than 2 enchantments, then I also need to have componations checking for more than 0 and 1 too?

Maybe I could write some code that makes every componation for me easily, but having that many properties files could maybe cause lag. I don't know how much of an effect it has on performance.

HiWord9 commented 1 month ago

To make it work with these 2 enchantments in any order u can make it being regex and it will be something like this:

nbt.Enchantments.0.id=iregex:(minecraft:unbreaking|minecraft:protection)
nbt.Enchantments.0.lvl=1
nbt.Enchantments.1.id=iregex:(minecraft:unbreaking|minecraft:protection)
nbt.Enchantments.1.lvl=1

This regex specifies that enchantment should be minecraft:unbreaking or minecraft:protection, it is assigned 2 times cause if first enchantment is minecraft:protection and the second one wont be the same the only way left to match is that the second will be minecraft:unbreaking, and same otherwise. Likely in ur case both enchantment should be the same level so we have no problems with level specification depending on enchantment, i guess it would require additional .properties file in this case. I took this example from screenshot i send before.

Unfortunately, i do not see a way to make it work in case protection or unbreaking will be at index higher than 1.

HiWord9 commented 1 month ago

I took a look at citr wiki for nbt and found out that u can specify any index in list by *, it will be something like:

nbt.Enchantments.*.id=minecraft:unbreaking
nbt.Enchantments.*.id=minecraft:protection

Now we specify exectly minecraft:unbreaking and minecraft:protection without regex cause it is not necessary here since we point at "any" entry in enchantment list. Unfortunately, this time im not sure is there a way to specify that enchantments should be exactly level 1

PenT1x commented 1 month ago

Likely in ur case both enchantment should be the same level so we have no problems with level specification depending on enchantment, i guess it would require additional .properties file in this case.

I want to have all the protection and unbreaking compinations with levels. So I guess I have to make a lot of .properties files.

Unfortunately, i do not see a way to make it work in case protection or unbreaking will be at index higher than 1.

I was planning on just making every possible case with index from 0 to 30 (That is how many enchantments there is in 1.8.9 i think)

HiWord9 commented 1 month ago

I want to have all the protection and unbreaking compinations with levels. So I guess I have to make a lot of .properties files.

If it is not important what levels enchantments have and it just should be protection of any level and unbreaking of any level than this way will work perfectly.