mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
solid block collision ported from latest
This commit is contained in:
parent
3ee0bd14c1
commit
c150a46383
1 changed files with 19 additions and 17 deletions
|
|
@ -580,6 +580,25 @@ class Entity extends Position
|
|||
if(Utils::in_range($this->speedY, -0.007, 0.007)){
|
||||
$this->speedY = 0;
|
||||
}
|
||||
|
||||
$horizontalMultiplyFactor = 0.91;
|
||||
if($this->onGround){
|
||||
$horizontalMultiplyFactor = 0.54;
|
||||
$b = $this->level->level->getBlockID(floor($this->x), floor($this->boundingBox->minX) - 1, floor($this->z));
|
||||
if($b > 0){
|
||||
$horizontalMultiplyFactor = StaticBlock::getSlipperiness($b) * 0.91;
|
||||
}
|
||||
}
|
||||
if($this->inWater){
|
||||
$this->speedX *= 0.8;
|
||||
$this->speedY *= 0.8;
|
||||
$this->speedZ *= 0.8;
|
||||
}else{
|
||||
$this->speedX *= $horizontalMultiplyFactor;
|
||||
$this->speedY *= 0.98;
|
||||
$this->speedZ *= $horizontalMultiplyFactor;
|
||||
}
|
||||
|
||||
$savedSpeedY = $this->speedY;
|
||||
if($this->class === ENTITY_MOB || $this->class === ENTITY_ITEM || ($this->class === ENTITY_OBJECT && $this->type === OBJECT_PRIMEDTNT)){
|
||||
$water = false;
|
||||
|
|
@ -614,24 +633,7 @@ class Entity extends Position
|
|||
}
|
||||
|
||||
$support = $savedSpeedY != $this->speedY && $savedSpeedY < 0;
|
||||
$horizontalMultiplyFactor = 0.91;
|
||||
if($support){
|
||||
$horizontalMultiplyFactor = 0.54;
|
||||
$b = $this->level->getBlockWithoutVector(floor($this->x), floor($this->boundingBox->minX) - 1, floor($this->z));
|
||||
if($b instanceof Block){
|
||||
$horizontalMultiplyFactor = $b->slipperiness * 0.91;
|
||||
}
|
||||
}
|
||||
|
||||
if($this->inWater){
|
||||
$this->speedX *= 0.8;
|
||||
$this->speedY *= 0.8;
|
||||
$this->speedZ *= 0.8;
|
||||
}else{
|
||||
$this->speedX *= $horizontalMultiplyFactor;
|
||||
$this->speedY *= 0.98;
|
||||
$this->speedZ *= $horizontalMultiplyFactor;
|
||||
}
|
||||
if($this->speedX != 0){
|
||||
$this->x += $this->speedX;
|
||||
$update = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue