CleverNucleus / data-attributes

Minecraft Fabric mod that overhauls the entity attributes system and exposes it with datapacks.
MIT License
12 stars 15 forks source link

Example makes no sense without further documentation #26

Closed itsdinkd closed 1 year ago

itsdinkd commented 1 year ago

Hi, Please explain how this works as i cannot find any other documentation pages that explain all available properties to use.

image

In the example, where would you write the value for the health change if you were to use rarity? Also, what are all the other available properties for entity types that you can use? Value? min, max?

CleverNucleus commented 1 year ago

Hi there, I do not understand your question. This is merely an example to show how attribute properties work. Attribute properties themselves do not have any impact on game mechanics unless implemented as such (for example, the PlayerEx mod). Nor are they related in any way to entity types. What do you mean 'all available properties'? Data Attributes does not add any attribute properties, it just allows for the addition of them via dependent mods. Thanks.

itsdinkd commented 1 year ago

rarity is a property, so im asking what other properties are there? if I wanted to use the example for a use case and base armor being changed on rarity what is the min and max property called"?

"Minecraft:generic_armor": {
  "rarity": 0.6
  }, 

in this example, I want to add more to it since without a actual value for the armor attribute, nothing would happen. So what are the other available properties that can be added? What is the property called for value? are there constants? uniform? can I use addition or multiplication?

Data Attributes does not add any attribute properties, it just allows for the addition of them via dependent mods.

I understand this however I am not asking about Attributes, I am asking about built in properties from Data Attributes itself, like rarity

itsdinkd commented 1 year ago

or are you saying rarity doesn't actually exist and the example is giving an assumption that the user created a rarity property to be used? If this is the case, can you use Min / Max / Chances or Division / Multiplication / Addition of attribute values at all by default:?

CleverNucleus commented 1 year ago

what are the other available properties that can be added?

Doesn't work like that. There is no list or anything of available properties because there are no 'available properties'. Mods that depend on Data Attributes may add properties to attributes, in which case those properties would be documented by those mods.

built in properties from Data Attributes itself, like rarity

This isn't a thing. Attributes can have properties attached to them. There are no inbuilt properties contained with the Data Attributes mod.

are you saying rarity doesn't actually exist and the example is giving an assumption that the user created a rarity property to be used?

Yes, correct. It is just an example.

can you use Min / Max / Chances or Division / Multiplication / Addition of attribute values at all by default:?

I do not understand this question.

itsdinkd commented 1 year ago

Okay i understand now. For my question on division, addition, multiplication, when setting attributes via java, you need to dictate the arithmetic of the attribute in the java method called "operation".

https://maven.fabricmc.net/docs/yarn-1.19.2+build.1/net/minecraft/entity/attribute/EntityAttributeModifier.html https://maven.fabricmc.net/docs/yarn-1.19.2+build.1/net/minecraft/entity/attribute/EntityAttributeModifier.Operation.html

Is there any way instead of me giving a exact value ie; "minecraft:generic_armor": 5.0 I can multiply the current value of that entity armor by *5.0? If not, can you add in a feature to do this, since its apart of fabric?

CleverNucleus commented 1 year ago

Sorry, I am unclear on what you are actually trying to do here. To be clear: attribute properties do not have any impact on game mechanics. If you are trying to create a datapack that lets you increase armour by x5, then you'll want to look into attribute functions.

itsdinkd commented 1 year ago

Does "Attribute Functions" work for vanilla attributes?

itsdinkd commented 1 year ago

oh you just added it in 1.4.0. nice.

itsdinkd commented 1 year ago
{
    "values": {
            "minecraft:generic.armor": {
                "behaviour": "MULTIPLY",
                "value": 5.0
            }
        }
}

so this will work? this goes in data/minecraft/attributes/ right?

And does the value of 5.0 equal Armor X 5? or 500?

CleverNucleus commented 1 year ago

Close, but not quite:

{
    "values": {
        "examplemod:attribute": {
            "minecraft:generic.armor": {
                "behaviour": "MULTIPLY",
                "value": 5.0
            }
        }
    }
}

This will cause the total value of Armor to be multiplied by 6.0 and also multiplied by the value of examplemod:attribute (the MULTIPLY behaviour here follows the MULTIPLY_TOTAL behaviour specified by vanilla attributes - see here). So, if the value of examplemod:attribute is 1.0, then the total value of Armor will be multiplied by 6.0 = 1.0 + (5.0 * 1.0). Similarly, if the value of examplemod:attribute is 0.5, then the total value of Armor will be multiplied by 3.5 = 1.0 + (5.0 * 0.5). Where examplemod:attribute can be any attribute you choose, either an attribute you have registered with a datapack, or from PlayerEx, or vanilla or any other mod.

itsdinkd commented 1 year ago

So then can i replace the example mod attribute with generic armor, in this example?

On Wed, Jan 4, 2023, 3:49 PM CleverNucleus @.***> wrote:

Close, but not quite:

{ "values": { "examplemod:attribute": { "minecraft:generic.armor": { "behaviour": "MULTIPLY", "value": 5.0 } } } }

This will cause the total value of Armor to be multiplied by 5.0 and also multiplied by the value of examplemod:attribute. So, if the value of examplemod:attribute is 1.0, then the total value of Armor will be multiplied by 5.0 = 5.0 1.0. Similarly, if the value of examplemod:attribute is 0.5, then the total value of Armor will be multiplied by 2.5 = 5.0 0.5. Where examplemod:attribute can be any attribute you choose, either an attribute you have registered with a datapack, or from PlayerEx, or vanilla or any other mod.

— Reply to this email directly, view it on GitHub https://github.com/CleverNucleus/Data-Attributes/issues/26#issuecomment-1371554261, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIL5CKF3FEFHCIDF2QM5ALLWQYD7JANCNFSM6AAAAAATN4VUMM . You are receiving this because you modified the open/close state.Message ID: @.***>

CleverNucleus commented 1 year ago

In this particular example, no - if you did, you'd have a recursion issue so the function would be discarded. Instead, I think you probably want to replace examplemod:attribute with a dummy attribute that has a value of 1.0 and doesn't change.

itsdinkd commented 1 year ago

Oh okay so it doesnt really matter what examplemod:attribute is, it will still change the nested attribute value globally?

itsdinkd commented 1 year ago

i take that back. it only matters for the base value of what you multiply or add on the targeted attribute?

CleverNucleus commented 1 year ago

Oh okay so it doesnt really matter what examplemod:attribute is, it will still change the nested attribute value globally?

Yes, correct. The attribute that will change is always the nested one.

itsdinkd commented 1 year ago

Oh okay so it doesnt really matter what examplemod:attribute is, it will still change the nested attribute value globally?

Yes, correct. The attribute that will change is always the nested one.

Got it. so how do I make it change for a Creeper though? and not the entire attribute for any entity?? (As the example I provided above there is no entity ID)

Let's say I wanted to modify creeper movement speed by Base * 1.5

CleverNucleus commented 1 year ago

If you want to change the movement speed of just a Creeper, you can use the entity_types.json:

{
    "values": {
        "minecraft:generic.movement_speed": 0.375
    }
}

I've put 0.375 because the default base movement speed for creepers is 0.25, so 0.25 × 1.5 = 0.375. This changes the default movement speed of all creepers.

itsdinkd commented 1 year ago

Yep i understand entity types but that is also way too fast, 0.375. I set it to 0.001 and it went almost lightning fast.

The main reason for multiplication is for thos exact reason. Values that are so low (0.000001 is player mvmt speed) you can just multiply to have finer control were you dont have to research each default value.

Another use case... modded entities. I want to edit their attack however i do not know there default attack. So what if i set a modded mob to have an attack of 10, which i thought was higher than default, but instead i just made the attack lower than default.

Being able to set the BASE attack * 2.0 guarantees im making their attack stronger

On Tue, Jan 10, 2023, 4:40 AM CleverNucleus @.***> wrote:

If you want to change the movement speed of just a Creeper, you can use the entity_types.json:

{

"values": {

    "minecraft:generic.movement_speed": 0.375

}

}

I've put 0.375 because the default base movement speed for creepers is 0.25, so 0.25 × 1.5 = 0.375. This changes the default movement speed of all creepers.

— Reply to this email directly, view it on GitHub https://github.com/CleverNucleus/Data-Attributes/issues/26#issuecomment-1377200696, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIL5CKGICFM4FDKHTLGFNLTWRVKCZANCNFSM6AAAAAATN4VUMM . You are receiving this because you modified the open/close state.Message ID: @.***>

itsdinkd commented 1 year ago

@CleverNucleus Did you read what I last wrote? having to learn every single base attribute of a entity is very troublesome. and to use Data Attributes in a modpack (like mine) that have dozens (100+) of custom mobs, not vanilla, but modded mobs, would take a very long time to do vs just running a operation type like ADDITION or MULTIPLY_TOTAL on it.

If you will not add this please let me know so I can stop using data attributes in hope that you will add this feature and instead ill use kubejs in my modpack for entity modification. I will say my pack does bring in 2k downloads every other day so it is helping your credits.

CleverNucleus commented 1 year ago

Hi there, I apologise if I have closed this issue prematurely, but in my defence it has been extremely difficult to understand what you have actually been asking, and therefore what the resolution should look like. Let me explain where I'm standing from:

Explanation

From the onset, you're initial query asking about "available properties" was nonsensical. There are no "available properties", and the documentation is clear that everything shown is an example of how to use the mod's features.

After getting past this point, our discussion moved onto a completely different question from the initial issue - one about attribute functions and how they work. You gave me some examples, and I corrected them and tried my best to understand what it is you wanted. That was fine.

Then you asked me another completely different question:

so how do I make it change for a Creeper though?

You also added some context:

and not the entire attribute for any entity??

Your specific question was:

Let's say I wanted to modify creeper movement speed by Base * 1.5

Well, I answered that too. Base movement speed of a creeper is 0.25. 1.5x that is 0.375. Yet this was not a satisfactory answer for some reason? You go on to state that 0.375 is too fast? And that you set it to 0.001 and it was "lightning fast"? I actually tested this; a value of 0.375 was fine. So I'm not clear on what you mean.

0.000001 is player mvmt speed

This is incorrect. Base movement speed for player is 0.1. I'm not just pulling values out of my ass. I'm looking at them in the source code. And after all this you go on to ask something else completely different:

Another use case... modded entities

What does this mean? There is no difference between how modded entities and vanilla entities are implemented. At the point of reading that message three weeks ago I did not understand what you were asking me, and it was so far from your original question that there was very little context to help me extrapolate what you were actually after.

Yesterday your comment made everything clear (I hope): you want to change entity attribute values per mob, but without actually having to know what the entity attribute value is by default. Therefore, what I believe you actually want is an attribute modifier to apply to specific mobs. Data Attributes provides a similar implementation to the same effect (see below under Solution).

I have been quite patient I think, but if you scroll up and look at what you started with and then what you ended with, it wasn't until your message yesterday that you finally explicitly stated what you were trying to do, specifically.

Specific Solution

You can create a dummy attribute - let's call it itsdinkd:damage_multiplier. Make a datapack file-folder structure as shown:

📂data
 ┗📂itsdinkd
     ┗📂attributes
         ┣📂overrides
         ┃    ┗📄damage_multiplier.json
         ┃
         ┣📄functions.json
         ┗📄entity_types.json

In your damage_multiplier.json file:

{
    "fallbackValue": 1.0,
    "minValue": 0.0,
    "maxValue": 1000.0,
    "incrementValue": 0.0,
    "translationKey": "itsdinkd.attribute.name.damage_multiplier",
    "stackingBehaviour": "FLAT"
}

In your functions.json file:

{
    "values": {
        "itsdinkd:damage_multiplier": {
            "minecraft:generic.attack_damage": {
                "behaviour": "MULTIPLY",
                "value": 1.0
            }
        }
    }
}

In your entity_types.json file:

{
    "values": {
        "minecraft:zombie": {
            "itsdinkd:multiply_damage": 0.5
        },
        "<insert mob entity type id here>": {
            "itsdinkd:multiply_damage": 1.0
        }
        ... continue adding more entries ...
    }
}

Note that the entries I've written in the entity_types.json file are example entries. I've put the minecraft:zombie there so you can see what a complete entry looks like, but obviously you can replace that with another mob of your choice. Additionally, where I've written <insert mob entity type id here> is where you would just put the entity type ID of whatever mob you want. To add more entities you would simply continue adding entries as shown.

For context, with this datapack all (regular) zombies now spawn with 1.5x their default attack damage. Just so I'm clear with the maths there: the multiplier is 1.0 + 0.5 = 1.5x, where the 0.5 is the value you put in the json file. Similarly, where I've put "itsdinkd:multiply_damage": 1.0, for whatever mob that applies to that type will have 2.0x its default attack damage.

Conclusion

I hope that all makes sense. I know sometimes it can be difficult to communicate with some mod authors, so I apologise if I haven't always interpreted your messages as you intended.