diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 4602d727..80fe53df 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -522,11 +522,6 @@ class Entity extends Position $this->speedX += $strafe*$v6 - $forward*$v5; $this->speedZ += $forward*$v6 + $strafe*$v5; - - //float var5 = MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F); - //float var6 = MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F); - //this.motionX += (double)(strafe * var6 - forward * var5); - //this.motionZ += (double)(forward * var6 + strafe * var5); } } diff --git a/src/entity/monster/Zombie.php b/src/entity/monster/Zombie.php index e864ada3..a07458f1 100644 --- a/src/entity/monster/Zombie.php +++ b/src/entity/monster/Zombie.php @@ -38,7 +38,7 @@ class Zombie extends Monster{ } public function getAttackDamage(){ - return 4; //TODO vanillafy(zombies might be able to hold items) + return 4; } public function update($now){ diff --git a/src/entity/object/FallingSand.php b/src/entity/object/FallingSand.php index 6a9a8607..2a43338f 100644 --- a/src/entity/object/FallingSand.php +++ b/src/entity/object/FallingSand.php @@ -34,7 +34,7 @@ class FallingSand extends Entity{ $x = floor($this->x); $y = floor($this->y); - $z = floot($this->z); + $z = floor($this->z); if($this->fallTime == 1){ /* i dont think this is needed here? @@ -52,14 +52,15 @@ class FallingSand extends Entity{ $this->speedX *= 0.7; $this->speedZ *= 0.7; $this->speedY *= -0.5; - - //1.5.2 has piston check, skipping $this->close(); - //if (!this.isBreakingAnvil && this.worldObj.canPlaceEntityOnSide(this.blockID, var1, var2, var3, true, 1, (Entity)null, (ItemStack)null) && !BlockSand.canFallBelow(this.worldObj, var1, var2 - 1, var3) && this.worldObj.setBlock(var1, var2, var3, this.blockID, this.metadata, 3)) - // - //} - //a check if block has tilentity, might be added after tile entities rewrite - + //TODO vanilla-like checking? + $this->level->fastSetBlockUpdate($x, $y, $z, $this->data["Tile"], 0); //TODO add metadata + }else if(($blockAt = $this->level->level->getBlockID($x, $y, $z)) != 0){ + //TODO vanilla-like checking? + if(StaticBlock::getIsTransparent($blockAt) && !StaticBlock::getIsLiquid($blockAt)){ + $this->close(); + ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->data["Tile"], 0, 1)); //TODO add metadata + } } } } diff --git a/src/material/Block.php b/src/material/Block.php index e4b4965e..17c89272 100755 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -155,6 +155,20 @@ abstract class Block extends Position{ public $z = 0; public $slipperiness; + public static $minX = 0, $minY = 0, $minZ = 0, $maxX = 1, $maxY = 1, $maxZ = 1; + public static function setBlockBounds($minX, $minY, $minZ, $maxX, $maxY, $maxZ){ //TODO call for some specific blocks + static::$minX = $minX; + static::$minY = $minY; + static::$minZ = $minZ; + static::$maxX = $maxX; + static::$maxY = $maxY; + static::$maxZ = $maxZ; + } + public static function getAABB(Level $level, $x, $y, $z){ + return new AxisAlignedBB(static::$minX + $x, static::$minY + $y, static::$minZ + $z, static::$maxX + $x, static::$maxY + $y, static::$maxZ + $z); + } + + public static function addVelocityToEntity(Level $level, $x, $y, $z, Entity $entity, Vector3 $velocityVector){} public static function onRandomTick(Level $level, $x, $y, $z){} public static function fallOn(Level $level, $x, $y, $z, Entity $entity, $fallDistance){} diff --git a/src/material/StaticBlock.php b/src/material/StaticBlock.php index d74ea36c..fd42c6b5 100644 --- a/src/material/StaticBlock.php +++ b/src/material/StaticBlock.php @@ -37,6 +37,33 @@ class StaticBlock self::$boundingBoxes[$b->getID()] = $b->boundingBox; self::$hardness[$b->getID()] = $b->getHardness(); } + + Block::$class[BED_BLOCK]::setBlockBounds(0, 0, 0, 1, 0.5625, 1); + //Cake: has bounds based on world state + //Chest: has bounds based on world state + Block::$class[WHEAT_BLOCK]::setBlockBounds(0, 0, 0, 1, 0.25, 1); + Block::$class[CARROT_BLOCK]::setBlockBounds(0, 0, 0, 1, 0.25, 1); + Block::$class[POTATO_BLOCK]::setBlockBounds(0, 0, 0, 1, 0.25, 1); + Block::$class[BEETROOT_BLOCK]::setBlockBounds(0, 0, 0, 1, 0.25, 1); //i assume it extends class Crops + Block::$class[WHEAT_BLOCK]::setBlockBounds(0, 0, 0, 1, 0.25, 1); + Block::$class[DEAD_BUSH]::setBlockBounds(0.1, 0, 0.1, 0.9, 0.8, 0.9); + Block::$class[DOOR_BLOCK]::setBlockBounds(0, 0, 0, 1, 1, 1); //has bounds based on rotation + Block::$class[FARMLAND]::setBlockBounds(0, 0, 0, 1, 0.9375, 1); + //Fence: bounds on state + //Fence Gate: bounds on state + Block::$class[TALL_GRASS]::setBlockBounds(0.1, 0, 0.1, 0.9, 0.8, 0.9); + Block::$class[MELON_STEM]::setBlockBounds(0.5 - 0.125, 0, 0.5 - 0.125, 0.5 + 0.125, 0.25, 0.5 + 0.125); + Block::$class[PUMPKIN_STEM]::setBlockBounds(0.5 - 0.125, 0, 0.5 - 0.125, 0.5 + 0.125, 0.25, 0.5 + 0.125); + Block::$class[SAPLING]::setBlockBounds(0.1, 0, 0.1, 0.9, 0.8, 0.9); + Block::$class[BROWN_MUSHROOM]::setBlockBounds(0.3, 0, 0.3, 0.8, 0.4, 0.8); + Block::$class[SLAB]::setBlockBounds(0, 0, 0, 1, 0.5, 1); + //Ladder: based on rotation + //Glass Pane: based on state + RailBaseBlock::setBlockBounds(0, 0, 0, 1, 0.125, 1); + Block::$class[SUGARCANE_BLOCK]::setBlockBounds(0.5 - 0.375, 0, 0.5 - 0.375, 0.5 + 0.375, 1, 0.5 + 0.375); + Block::$class[SNOW_LAYER]::setBlockBounds(0, 0, 0, 1, 0.125, 1); + //Stairs: based on different factors + //Stone wall: based on state } public static function getBlock($id){ @@ -47,6 +74,7 @@ class StaticBlock return self::$hardness[$id] ?? StaticBlock::DEFAULT_HARDNESS; } + //TODO: use static block min/max public static function getBoundingBoxForBlockCoords($id, $x, $y, $z){ /**@var AxisAlignedBB $bb*/ $bb = self::$boundingBoxes[$id] ?? false; diff --git a/src/world/Level.php b/src/world/Level.php index cf4e1a10..87a2dbe1 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -76,7 +76,8 @@ class Level{ return true; } - //TODO public function canPlaceEntityOnSide() + //TODO mayPlace + public function handleMaterialAcceleration(AxisAlignedBB $aabb, $materialType, Entity $entity){ $minX = floor($aabb->minX);