-
Bug
-
Resolution: Unresolved
-
None
-
1.20.80.23 Preview
-
None
-
Confirmed
-
Windows
-
1235577
Update: A Mojira moderator has told me to merge MCPE-180074 into this report. I have updated the description, attachements, and title to reflect this merge
According to the official docs the "minecraft:damage" component supports an integer type. However, upon further testing, it seems that it uses the following formula:
value = value % 256
rather than using the actual value.
More so, the component seems to be using a signed 16-bit integer which causes unexpected/unwanted behaviour. This causes certain ranges of values to appear as negative which causes the Bedrock Engine to think the value is a negative number, even if the value is a positive number. This occurs due to the 2's complements for 16-bit integer. The negative ranges formula is, inclusive beginning and exclusive ending where x can be any arbitrary number.
[256*(256x+128), 256*(256(x+1)))
As an example, if x is 0, the range for negative values are [32768, 65536) which the below reproduction method below supports
Reproduce:
- Download the attached pack below(As of 27/08/2024, I have attached an updated version to keep the item format and min engine version to 1.21.30)
- Import the pack into Preview 1.21.30.24
- Give yourself the following items:
- mojira:damage_255
- mojira:damage_256
- mojira:damage_257
- mojira:damage_32767
- mojira:damage_32768
- mojira:damage_32769
- mojira:damage_65536
- Open your inventory and hover over the items
Expected Result:
- mojira:damage_255 should have a "+255 attack damage" tooltip
- mojira:damage_256 should have a "+256 attack damage" tooltip
- mojira:damage_257 should have a "+257 attack damage" tooltip
- mojira:damage_32767 should have a "+255 attack damage" tooltip
- mojira:damage_32768 should have no "attack damage" tooltip
- mojira:damage_32769 should have a "+1 attack damage" tooltip
- mojira:damage_65536 should have no "attack damage" tooltip
Actual Result:
- mojira:damage_255 has a "+255 attack damage" tooltip
- mojira:damage_256 has no "attack damage" tooltip
- mojira:damage_257 has a "+1 attack damage" tooltip
- mojira:damage_32767 has a "+255 attack damage" tooltip. The item does parse correctly.
- mojira:damage_32768 throws a content log error. The item does not parse correctly thus rendering the item broken.
- mojira:damage_32769 throws a content log error. The item does not parse correctly thus rendering the item broken.
- mojira:damage_65536 has no "attack damage" tooltip. The item does parse correctly.
- is duplicated by
-
MCPE-180074 "minecraft:damage" component value uses signed 16-bit integer
- Resolved