diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 04575501..57fd44d4 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -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){ diff --git a/src/entity/object/ItemEntity.php b/src/entity/object/ItemEntity.php index 43d42808..825f031c 100644 --- a/src/entity/object/ItemEntity.php +++ b/src/entity/object/ItemEntity.php @@ -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(){ diff --git a/src/material/block/nonfull/FenceBlock.php b/src/material/block/nonfull/FenceBlock.php index 2af3da8c..fddb9c80 100644 --- a/src/material/block/nonfull/FenceBlock.php +++ b/src/material/block/nonfull/FenceBlock.php @@ -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; } diff --git a/src/world/Level.php b/src/world/Level.php index b07569f1..2f1cc931 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -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;