Level::handleMaterialAcceleration uses materials now

This commit is contained in:
GameHerobrine 2025-07-03 16:55:47 +03:00
parent 5e613268ab
commit 6c7bcf014b
4 changed files with 13 additions and 5 deletions

View file

@ -404,7 +404,7 @@ class Entity extends Position
}
public function handleWaterMovement(){
if($this->level->handleMaterialAcceleration($this->boundingBox->expand(0, -0.4, 0)->contract(0.001, 0.001, 0.001), 0, $this)){
if($this->level->handleMaterialAcceleration($this->boundingBox->expand(0, -0.4, 0)->contract(0.001, 0.001, 0.001), Material::$water, $this)){
$this->fallDistance = 0;
$this->inWater = true;
if($this->fire > 0){

View file

@ -174,7 +174,7 @@ class ItemEntity extends Entity{
}
public function handleWaterMovement(){
return $this->level->handleMaterialAcceleration($this->boundingBox, 0, $this);
return $this->level->handleMaterialAcceleration($this->boundingBox, Material::$water, $this);
}
public function updateEntityMovement(){

View file

@ -12,9 +12,16 @@ class FenceBlock extends TransparentBlock{
public static function canConnectTo(Level $level, $x, $y, $z){
$id = $level->level->getBlockID($x, $y, $z);
/*if($id == FENCE || $id == FENCE_GATE) return true;
if($id == 0) return false;
$mat = StaticBlock::getMaterial($id);
if($mat->isSolidBlocking() && tile->isCubeShaped()){ //TODO tile->isCubeShaped
return $mat != Material::$vegetable;
}
return false;*/
if($id != FENCE && $id != FENCE_GATE){
return StaticBlock::getIsSolid($id) && $id != PUMPKIN; //TODO check var6 != null && var6.blockMaterial.isOpaque() && var6.renderAsNormalBlock() ? var6.blockMaterial != Material.pumpkin : false;
return StaticBlock::getIsSolid($id) && $id != PUMPKIN;
}
return true;
}

View file

@ -216,7 +216,7 @@ class Level{
return false;
}
public function handleMaterialAcceleration(AxisAlignedBB $aabb, $materialType, Entity $entity){
public function handleMaterialAcceleration(AxisAlignedBB $aabb, Material $material, Entity $entity){
$minX = floor($aabb->minX);
$maxX = ceil($aabb->maxX);
$minY = floor($aabb->minY);
@ -232,7 +232,8 @@ class Level{
for($y = $minY; $y < $maxY; ++$y){
for($z = $minZ; $z < $maxZ; ++$z){
[$block, $meta] = $this->level->getBlock($x, $y, $z);
if(($materialType == 0 && ($block == WATER || $block == STILL_WATER)) || ($materialType == 1 && ($block == LAVA || $block == STILL_LAVA))){ //TODO better material system
$mat = StaticBlock::getMaterial($block);
if($material == $mat){
$v16 = ($y + 1) - LiquidBlock::getPercentAir($meta);
if($maxY >= $v16){
$appliedVelocity = true;