some hitboxes tweaks

This commit is contained in:
GameHerobrine 2024-05-01 16:26:18 +03:00
parent 73a36a1ea2
commit 589922daaf
10 changed files with 28 additions and 7 deletions

View file

@ -1232,7 +1232,7 @@ class Player{
$headSent = false;
$svdYSpeed = $e->speedY;
if($e->modifySpeedY){
$e->speedY = $e->modifedSpeedY;
$e->speedY = $e->modifedSpeedY;
}
if($e->speedX != 0 || $e->speedY != 0 || $e->speedZ != 0 || $e->speedY != $e->lastSpeedY || $e->speedX != $e->lastSpeedX || $e->speedZ != $e->lastSpeedZ){
if(!($e->speedY < 0 && $e->onGround) || $e->speedX != 0 || $e->speedZ != 0 || $e->speedY != $e->lastSpeedY || $e->speedX != $e->lastSpeedX || $e->speedZ != $e->lastSpeedZ){
@ -1248,8 +1248,8 @@ class Player{
}
}
if($e->modifySpeedY){
$e->speedY = $svdYSpeed;
$e->modifySpeedY = false;
$e->speedY = $svdYSpeed;
$e->modifySpeedY = false;
}
if($e->x != $e->lastX || $e->y != $e->lastY || $e->z != $e->lastZ || $e->yaw != $e->lastYaw || $e->pitch != $e->lastPitch){

View file

@ -639,8 +639,8 @@ class Entity extends Position
$dz = $cz;
$this->boundingBox->setBB($aabb1);
}else{
$this->modifySpeedY = true;
$this->modifedSpeedY = 0.5;
$this->modifySpeedY = true;
$this->modifedSpeedY = 0.5;
}
}

View file

@ -17,4 +17,8 @@ class TransparentBlock extends GenericBlock{
$this->isSolid = true;
$this->boundingBox->setBounds($this->x, $this->y, $this->z, $this->x + 1, $this->y + 1, $this->z + 1);
}
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
return [];
}
}

View file

@ -11,7 +11,7 @@ class TrapdoorBlock extends TransparentBlock{
}
$this->hardness = 15;
}
//TODO collision box
public function canAttachTo(Block $target){
$id = $target->getID();
return $id === SLAB || $id === GLOWSTONE || $id === SLAB || $id === WOOD_SLAB || (!$target->isTransparent || $target instanceof StairBlock);

View file

@ -20,7 +20,7 @@ class BedBlock extends TransparentBlock{
$this->isFullBlock = false;
$this->hardness = 1;
}
//TODO collision box
public static function findStandUpPosition(Level $level, $x, $y, $z){
$blockMeta = $level->level->getBlockDamage($x, $y, $z);
$direction = $blockMeta & 0x3;

View file

@ -9,6 +9,11 @@ class CakeBlock extends TransparentBlock{
$this->hardness = 2.5;
}
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
$data = $level->level->getBlockDamage($x, $y, $z);
return [new AxisAlignedBB($x + (2*$data + 1) * 0.0625, $y, $z + 0.0625, $x + 0.9375, $y + 0.5, $z + 0.9375)];
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0);
if($down->getID() !== AIR){

View file

@ -1,6 +1,7 @@
<?php
class StoneWallBlock extends TransparentBlock{
//TODO collision box
public function __construct($meta = 0){
parent::__construct(STONE_WALL, $meta & 0x01, $meta === 1 ? "Mossy Cobblestone Wall" : "Cobblestone Wall");
$this->isFullBlock = false;

View file

@ -10,6 +10,9 @@ class CactusBlock extends TransparentBlock{
public static function onEntityCollidedWithBlock(Level $level, $x, $y, $z, Entity $entity){
$entity->harm(1, "cactus");
}
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
return [new AxisAlignedBB($x + 0.0625, $y, $z + 0.0625, $x - 0.0625, $y - 0.0625, $z - 0.0625)];
}
public static function onRandomTick(Level $level, $x, $y, $z){
//$b = $level->level->getBlock($x, $y - 1, $z);

View file

@ -9,4 +9,8 @@ class GlassBlock extends TransparentBlock{
public function getDrops(Item $item, Player $player){
return array();
}
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
return [new AxisAlignedBB($x, $y, $z, $x + 1, $y + 1, $z + 1)];
}
}

View file

@ -10,4 +10,8 @@ class MelonBlock extends TransparentBlock{
array(MELON_SLICE, 0, mt_rand(3, 7)),
);
}
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
return [new AxisAlignedBB($x, $y, $z, $x + 1, $y + 1, $z + 1)];
}
}