arrows block collision fix, uncommented commented code

This commit is contained in:
GameHerobrine 2024-03-23 23:33:13 +03:00
parent 60be9fb2da
commit 2ce333af5e
3 changed files with 64 additions and 57 deletions

View file

@ -97,8 +97,7 @@ class Level{
[$startID, $startMeta] = $this->level->getBlock($xStart, $yStart, $zStart);
$block = StaticBlock::getBlock($startID);
console("($xStart, $yStart, $zStart): $startID");
console("start end: $start $end BEFORE");
//$block::updateShape($this, $xStart, $yStart, $zStart); //TODO better way to do it
$aabb = $block::getAABB($this, $xStart, $yStart, $zStart);
if($startID > 0 && $aabb != null){ //TODO also block::canColideCheck
@ -108,7 +107,7 @@ class Level{
for($i = 0; $i <= 200; ++$i){
if($xStart == $xEnd && $yStart == $yEnd && $zStart == $zEnd){ //also add checks for nan?
if(is_nan($start->x) || is_nan($start->y) || is_nan($start->z) || ($xStart == $xEnd && $yStart == $yEnd && $zStart == $zEnd)){ //also add checks for nan?
return null;
}
@ -132,9 +131,9 @@ class Level{
$v29 = $end->y - $start->y;
$v31 = $end->z - $start->z;
if($v39) $v21 = ($v15 - $start->x) / $v27;
if($v40) $v23 = ($v17 - $start->y) / $v29;
if($v41) $v25 = ($v19 - $start->z) / $v31;
if($v39) $v21 = $v27 == 0 ? ($v15 - $start->x)*INF : ($v15 - $start->x) / $v27;
if($v40) $v23 = $v29 == 0 ? ($v17 - $start->y)*INF : ($v17 - $start->y) / $v29;
if($v41) $v25 = $v31 == 0 ? ($v19 - $start->z)*INF : ($v19 - $start->z) / $v31;
if($v21 < $v23 && $v21 < $v25){
$v42 = $xEnd > $xStart ? 4 : 5;
@ -167,15 +166,12 @@ class Level{
[$blockID, $blockMeta] = $this->level->getBlock($xStart, $yStart, $zStart);
$block = StaticBlock::getBlock($blockID);
console("$i($xStart, $yStart, $zStart): $blockID");
console("start end: $start $end BEFORE");
$aabb = $block::getAABB($this, $xStart, $yStart, $zStart);
if($startID > 0 && $aabb != null){ //TODO also block::canColideCheck
if($blockID > 0 && $aabb != null){ //TODO also block::canColideCheck
$v38 = $block::clip($this, $xStart, $yStart, $zStart, $start, $end);
if($v38 != null) return $v38;
}
console("start end: $start $end AFTER");
}
return null;