Carpet

Carpet

2M Downloads

Issue storing integer values of look vector in NBT data motion vector

mathgeniuszach opened this issue ยท 8 comments

commented

image
image

For some reason, when I try to store a player's look vector into a motion vector of another entity, I rarely get this error message that seems to only occur when any coordinate of the vector is an integer number.

commented

Can you try using the floating point version 0.0d instead of the integer 0 when storing to NBT?
(It could be that Scarpet is casting the zeroes here to an integer data type instead of leaving them as Doubles)

commented

I don't have physical control over the 0 exactly, so unfortunately I cannot do that. This is the line of code that's wrong, could it be that the "wspeed" value being an integer is causing this issue?

wprojectile_tag:'Motion' = (e~'look') * wspeed;
commented

Do you get the same error if you replace the above line with the following (which assumes wspeed is 1)?

wprojectile_tag:'Motion' = (e~'look')

If you don't get the error, then it is likely caused by wspeed being an integer.

commented

The issue still seems to occur without wspeed.

commented

As a workaround, can you try filtering out those zeroes and replacing them with a really small floating point number (like 0.000000001)?

commented

I already thought about doing that, but this is a bug nonetheless lol

commented

Seems to actually occur when any of the three values are integer values, not just zero.

commented

its all intended - and its a restriction of the NBT tags to store only one type in a list. In newer parts of MC points are stored as maps like {X:...,Y:...,Z:...} so its not a problem.
To do it properly, pass a string as value:

for(_:0, put(point_nbt:'pos',str('%.6fd',_),_i)); // need to print to float string