Fixed falling sand glitching on landing, minor logic improvements

This commit is contained in:
Dylan K. Taylor 2017-05-04 17:48:39 +01:00
parent 13fd8b681e
commit 49eb0eb050
2 changed files with 3 additions and 11 deletions

View File

@ -37,6 +37,7 @@ abstract class Fallable extends Solid{
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
$down = $this->getSide(Vector3::SIDE_DOWN); $down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === self::AIR or ($down instanceof Liquid)){ if($down->getId() === self::AIR or ($down instanceof Liquid)){
$this->level->setBlock($this, Block::get(Block::AIR), true, true);
$fall = Entity::createEntity("FallingSand", $this->getLevel(), new CompoundTag("", [ $fall = Entity::createEntity("FallingSand", $this->getLevel(), new CompoundTag("", [
"Pos" => new ListTag("Pos", [ "Pos" => new ListTag("Pos", [
new DoubleTag("", $this->x + 0.5), new DoubleTag("", $this->x + 0.5),

View File

@ -39,6 +39,8 @@ class FallingSand extends Entity{
public $length = 0.98; public $length = 0.98;
public $height = 0.98; public $height = 0.98;
protected $baseOffset = 0.49;
protected $gravity = 0.04; protected $gravity = 0.04;
protected $drag = 0.02; protected $drag = 0.02;
protected $blockId = 0; protected $blockId = 0;
@ -95,17 +97,6 @@ class FallingSand extends Entity{
$hasUpdate = $this->entityBaseTick($tickDiff); $hasUpdate = $this->entityBaseTick($tickDiff);
if($this->isAlive()){ if($this->isAlive()){
$pos = (new Vector3($this->x - 0.5, $this->y, $this->z - 0.5))->round();
if($this->ticksLived === 1){
$block = $this->level->getBlock($pos);
if($block->getId() !== $this->blockId){
$this->kill();
return true;
}
$this->level->setBlock($pos, Block::get(0), true);
}
$this->motionY -= $this->gravity; $this->motionY -= $this->gravity;
$this->move($this->motionX, $this->motionY, $this->motionZ); $this->move($this->motionX, $this->motionY, $this->motionZ);