Update Math dependency, obliterate some nasty code from Block

This commit is contained in:
Dylan K. Taylor
2018-11-23 19:41:52 +00:00
parent 4c848bb4c1
commit 101de7adda
9 changed files with 31 additions and 203 deletions

View File

@ -74,36 +74,12 @@ class CocoaBlock extends Transparent{
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
static $logDistance = 1 / 16;
$bb = new AxisAlignedBB(0, (7 - $this->age * 2) / 16, 0, 1, 0.75, 1);
$widthInset = (6 - $this->age) / 16;
$faceDistance = (5 + $this->age * 2) / 16;
$minY = (7 - $this->age * 2) / 16;
if(Facing::isPositive($this->facing)){
$minFacing = $logDistance;
$maxFacing = $faceDistance;
}else{
$minFacing = 1 - $faceDistance;
$maxFacing = 1 - $logDistance;
}
if(Facing::axis($this->facing) === Facing::AXIS_Z){
$minX = $widthInset;
$maxX = 1 - $widthInset;
$minZ = $minFacing;
$maxZ = $maxFacing;
}else{
$minX = $minFacing;
$maxX = $maxFacing;
$minZ = $widthInset;
$maxZ = 1 - $widthInset;
}
return new AxisAlignedBB($minX, $minY, $minZ, $maxX, 0.75, $maxZ);
return $bb
->squash(Facing::axis(Facing::rotate($this->facing, Facing::AXIS_Y, true)), (6 - $this->age) / 16) //sides
->trim(Facing::opposite($this->facing), 1 / 16) //gap between log and pod
->trim($this->facing, (11 - $this->age * 2) / 16); //outward face
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{