Skip to content

Commit

Permalink
Fix strange distance bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico314159 committed Aug 19, 2023
1 parent 749ed9c commit 5403fa0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions data/retina/functions/storage/block.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ data modify storage retina:output TargetedBlock set value [0,0,0]
data modify storage retina:output PlacingPosition set value [0,0,0]
data modify storage retina:output ContactCoordinates set value [0.0d,0.0d,0.0d]
data modify storage retina:output ContactSurface set from storage retina:data ContactSurface
execute if score $X0 retina.__variable__ matches ..-1 run scoreboard players add $X0 retina.__variable__ 480
execute if score $Y0 retina.__variable__ matches ..-1 run scoreboard players add $Y0 retina.__variable__ 480
execute store result storage retina:output TargetedBlock[0] int 1 run scoreboard players get $int_X retina.__variable__
execute store result storage retina:output PlacingPosition[0] int 1 run scoreboard players get $prev_X retina.__variable__
scoreboard players operation $targeted_X retina.__variable__ += $origin_X retina.__variable__
Expand Down
2 changes: 2 additions & 0 deletions data/retina/functions/storage/entity.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ data modify storage retina:output TargetedEntity.Pos set from storage retina:dat
data remove storage retina:data Entity
data modify storage retina:output ContactSurface set from storage retina:data ContactSurface
data modify storage retina:output ContactCoordinates set value [0.0d,0.0d,0.0d]
execute if score $X0 retina.__variable__ matches ..-1 run scoreboard players add $X0 retina.__variable__ 480
execute if score $Y0 retina.__variable__ matches ..-1 run scoreboard players add $Y0 retina.__variable__ 480
scoreboard players operation $targeted_X retina.__variable__ += $origin_X retina.__variable__
execute store result storage retina:output ContactCoordinates[0] double 0.0020833333333333333 run scoreboard players get $targeted_X retina.__variable__
execute if score $nearest_axis retina.__variable__ matches 0 run function retina:__private__/if_else/20
Expand Down
9 changes: 9 additions & 0 deletions retina.jmc
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,10 @@ class storage {
// Contact surface
data modify storage retina:output ContactSurface set from storage retina:data ContactSurface;

// I have no clue why X and Y need this but Z doesn't.
if ($X0 < 0) $X0 += 480;
if ($Y0 < 0) $Y0 += 480;

Hardcode.repeatLists(
["[axis]", "index"],
() => {
Expand Down Expand Up @@ -1948,6 +1952,11 @@ class storage {

// Contact coordinates
data modify storage retina:output ContactCoordinates set value [0.0d, 0.0d, 0.0d];

// I have no clue why X and Y need this but Z doesn't.
if ($X0 < 0) $X0 += 480;
if ($Y0 < 0) $Y0 += 480;

Hardcode.repeatLists(
["[axis]", "_index"],
() => {
Expand Down

0 comments on commit 5403fa0

Please sign in to comment.