mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
fixed trpadoors, walls and beds hitboxes + projectile aabb fix for tallgrass
This commit is contained in:
parent
518f6a99a7
commit
057fb8898a
4 changed files with 105 additions and 1 deletions
|
|
@ -14,4 +14,61 @@ class StoneWallBlock extends TransparentBlock{
|
|||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
public static function connectsTo(Level $level, $x, $y, $z){
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
|
||||
if($id == STONE_WALL || $id == FENCE_GATE) return true;
|
||||
if($id == 0) return false;
|
||||
|
||||
if(StaticBlock::getIsSolid($id) && !StaticBlock::getIsTransparent($id)){ //XXX in vanilla it uses Material->isSolidBlocking() and Tile->isCubeShaped()
|
||||
return true; //XXX in vanilla it returns v7->material != Material::vegetable;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [static::getAABB($level, $x, $y, $z)];
|
||||
}
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
static::updateShape($level, $x, $y, $z);
|
||||
StaticBlock::$maxYs[$level->level->getBlockID($x, $y, $z)] = 1.5;
|
||||
return parent::getAABB($level, $x, $y, $z);
|
||||
}
|
||||
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
$zNeg = self::connectsTo($level, $x, $y, $z - 1);
|
||||
$zPos = self::connectsTo($level, $x, $y, $z + 1);
|
||||
$xNeg = self::connectsTo($level, $x - 1, $y, $z);
|
||||
$xPos = self::connectsTo($level, $x + 1, $y, $z);
|
||||
|
||||
$minX = 0.25;
|
||||
$maxY = 1.0;
|
||||
$maxX = 0.75;
|
||||
|
||||
$minZ = $zNeg ? 0 : 0.25;
|
||||
$maxZ = $zPos ? 1.0 : 0.75;
|
||||
|
||||
if($xNeg) $minX = 0;
|
||||
if($xPos) $maxX = 1.0;
|
||||
|
||||
if($zNeg){
|
||||
if($zPos && !$xNeg){
|
||||
if(!$xPos){
|
||||
$maxY = 0.8125;
|
||||
$maxX = 0.6875;
|
||||
$minX = 0.3125;
|
||||
}
|
||||
}
|
||||
}else if(!$zPos && $zNeg){
|
||||
if($xPos){
|
||||
$maxY = 0.8125;
|
||||
$maxZ = 0.6875;
|
||||
$minZ = 0.3125;
|
||||
}
|
||||
}
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
StaticBlock::setBlockBounds($id, $minX, 0, $minZ, $maxX, $maxY, $maxZ);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue