Minenash / CustomHUD

A highly customizable variable-based text HUD for Minecraft
MIT License
83 stars 24 forks source link

target_block_power, target_block_strong_power, and target_block_powers returning unexpected values #142

Closed poqbox closed 5 days ago

poqbox commented 5 days ago

Mod version: 4.0.0-beta.8+1.21 Mod loader: Fabric

This is possibly a feature request.

I saw that a variable for redstone power was added in this post did some searching for it. I came across target_block_power, target_block_strong_power, and target_block_powers, but none of them do as I expected. I expected that at least one of them would behave like "power" property in the F3 menu, but they all provide different values. Take the three images below for example. All of them use {target_block_power} on line 1, {target_block_strong_power} on line 2, and {target_block_powers} on line 3.

15 Here, I would expect a power of 15. target_block_power behaves as expected, but the rest do not.

14 Here, I would expect a power of 14. None of the three behave as expected. However, target_block_power and target_block_strong_power return a value that is one higher than expected. target_block_powers did not return a different value.

13 Here, I would expect a power of 13. Again, target_block_power and target_block_strong_power return a value that is one higher than expected, and target_block_powers did not return a different value.

The wiki doesn't seem to be updated with these new variables. I'm having trouble making sense of this and I'm looking for some clarification. Also, if this intended and I'm just not understanding it, I would like to see a variable that behaves like the "power" property in the F3 menu. (This is my feature request)

Minenash commented 5 days ago

Hey! These variables are about the power coming into the block your looking at. If you want to get the power the block produces, you can use the target_block_properties list and show the one called power.

In the future, I should make a non-list version of the properties, and probably should create a dedicated one for power

poqbox commented 5 days ago

Do you have a link to some docs on it? I'm not sure of how to manipulate that variable. Using target_block_properties seems to return the number of properties of the targeted block, but that's all I figured out.

I appreciate the quick reply.

poqbox commented 5 days ago

Nevermind, I figured it out. This actually works alright, and I don't think it's necessary to make a non-list version since it'll probably take a while and that you'd have to update it every time a new property is added.

I'll make another comment in case anyone else comes across this problem.

poqbox commented 5 days ago

For anyone trying to do the same thing, you can use target_block_property:<property>:<method>, where <property> would be the desired property and <method> would be the type of return value. This format should be the same for all variables like this one, where an attribute would be referenced using a :, and an attribute of the attribute would also be referenced with a :.

For example, if a piece of redstone dust is outputting a power of 2, {target_block_property:power:value} would display 2. If you wanted to display the direction that a redstone repeater is facing, you would use {target_block_property:facing:value}. Here, the :power attribute was replaced with :facing. These can typically be found in the F3 menu.

The last value can also be changed to display a different value. For example, replacing :value with :name would display the name of the property.

Minenash commented 5 days ago

For anyone trying to do the same thing, you can use target_block_property::

Oh, so I did add this. I didn't see it in my own change log xD