mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 03:59:43 +00:00
code style fix
This commit is contained in:
parent
fc5c5625cb
commit
5e8e9330e2
361 changed files with 4766 additions and 4650 deletions
|
|
@ -86,14 +86,13 @@ class DoorBlock extends TransparentBlock{
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return [$aabb->offset($x, $y, $z)];
|
||||
}
|
||||
|
||||
|
||||
public static function getCompositeData(Level $level, $x, $y, $z){
|
||||
$myMeta = $level->level->getBlockDamage($x, $y, $z);
|
||||
|
||||
|
||||
if(($myMeta & 8) != 0){
|
||||
$metaLower = $level->level->getBlockDamage($x, $y - 1, $z);
|
||||
$metaUpper = $myMeta;
|
||||
|
|
@ -101,19 +100,18 @@ class DoorBlock extends TransparentBlock{
|
|||
$metaLower = $myMeta;
|
||||
$metaUpper = $level->level->getBlockDamage($x, $y + 1, $z);
|
||||
}
|
||||
|
||||
|
||||
return $metaLower & 7 | (($myMeta & 8) != 0 ? 8 : 0) | (($metaUpper & 1 != 0) ? 16 : 0);
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
if($level->level->getBlockID($x, $y - 1, $z) == AIR){ //Replace with common break method
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
|
||||
if($id == 64) ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(324, 0, 1));
|
||||
elseif($id == 71) ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(330, 0, 1));
|
||||
|
||||
|
||||
if($id == 64) ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(324, 0, 1));
|
||||
elseif($id == 71) ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(330, 0, 1));
|
||||
|
||||
$top = $level->level->getBlockID($x, $y + 1, $z);
|
||||
if($top == IRON_DOOR_BLOCK || $top == DOOR_BLOCK){
|
||||
$level->fastSetBlockUpdate($x, $y + 1, $z, 0, 0);
|
||||
|
|
@ -121,12 +119,7 @@ class DoorBlock extends TransparentBlock{
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
* @param Block $block
|
||||
* @param Block $target
|
||||
* @param integer $face
|
||||
* @param integer $fx
|
||||
* @param integer $fy
|
||||
|
|
@ -142,12 +135,12 @@ class DoorBlock extends TransparentBlock{
|
|||
return false;
|
||||
}
|
||||
$direction = $player->entity->getDirection();
|
||||
$face = array(
|
||||
$face = [
|
||||
0 => 3,
|
||||
1 => 4,
|
||||
2 => 2,
|
||||
3 => 5,
|
||||
);
|
||||
];
|
||||
$next = $this->getSide($face[(($direction + 2) % 4)]);
|
||||
$next2 = $this->getSide($face[$direction]);
|
||||
$metaUp = 0x08;
|
||||
|
|
@ -155,17 +148,15 @@ class DoorBlock extends TransparentBlock{
|
|||
$metaUp |= 0x01;
|
||||
}
|
||||
$this->level->setBlock($blockUp, BlockAPI::get($this->id, $metaUp), true, false, true); //Top
|
||||
|
||||
|
||||
$this->meta = $direction & 0x03;
|
||||
$this->level->setBlock($block, $this, true, false, true); //Bottom
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
|
|
@ -186,8 +177,6 @@ class DoorBlock extends TransparentBlock{
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -12,10 +12,6 @@ class FallableBlock extends SolidBlock{
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
* @param Block $block
|
||||
* @param Block $target
|
||||
* @param int $face
|
||||
* @param int $fx
|
||||
* @param int $fy
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
|
||||
class GenericBlock extends Block{
|
||||
/**
|
||||
* @param int $id
|
||||
|
|
@ -12,10 +11,6 @@ class GenericBlock extends Block{
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
* @param Block $block
|
||||
* @param Block $target
|
||||
* @param integer $face
|
||||
* @param integer $fx
|
||||
* @param integer $fy
|
||||
|
|
@ -28,8 +23,6 @@ class GenericBlock extends Block{
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
|
|
@ -38,8 +31,6 @@ class GenericBlock extends Block{
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
@ -55,26 +46,25 @@ class GenericBlock extends Block{
|
|||
parent::onPlace($level, $x, $y, $z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function onUpdate(Level $level, $x, $y, $z, $type){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
$down = $level->level->getBlockID($x, $y - 1, $z);
|
||||
if($down == AIR || StaticBlock::getIsLiquid($down)){
|
||||
$data = array(
|
||||
$data = [
|
||||
"x" => $x + 0.5,
|
||||
"y" => $y - 0.5,
|
||||
"z" => $z + 0.5,
|
||||
"Tile" => $id,
|
||||
);
|
||||
];
|
||||
$server = ServerAPI::request();
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
$e = $server->api->entity->add($level, ENTITY_FALLING, FALLING_SAND, $data);
|
||||
$server->api->entity->spawnToAll($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param integer $type
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
|
|
@ -86,8 +76,6 @@ class GenericBlock extends Block{
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -21,14 +21,14 @@ class LiquidBlock extends TransparentBlock{
|
|||
return match(static::$blockID){
|
||||
WATER, STILL_WATER => $id == WATER || $id == STILL_WATER ? $meta : -1,
|
||||
LAVA, STILL_LAVA => $id == LAVA || $id == STILL_LAVA ? $meta : -1,
|
||||
default=> -1
|
||||
default => -1
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public static function onPlace(Level $level, $x, $y, $z){
|
||||
static::updateLiquid($level, $x, $y, $z);
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
static::updateLiquid($level, $x, $y, $z);
|
||||
}
|
||||
|
|
@ -40,10 +40,10 @@ class LiquidBlock extends TransparentBlock{
|
|||
$f = ($meta + 1) / 9;
|
||||
return $f;
|
||||
}
|
||||
|
||||
|
||||
public static function getRenderedDepth(Level $level, $x, $y, $z){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
|
||||
|
||||
$cond = match($id){
|
||||
WATER, STILL_WATER => static::$blockID == WATER || static::$blockID == STILL_WATER,
|
||||
LAVA, STILL_LAVA => static::$blockID == LAVA || static::$blockID == STILL_LAVA,
|
||||
|
|
@ -52,23 +52,23 @@ class LiquidBlock extends TransparentBlock{
|
|||
if(!$cond) return -1;
|
||||
return $meta >= 8 ? 0 : $meta;
|
||||
}
|
||||
|
||||
|
||||
public static function shouldRenderFace(Level $level, $x, $y, $z, $face){
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
|
||||
|
||||
if($id == ICE) return false;
|
||||
if((($id == WATER || $id == STILL_WATER) && (static::$blockID == WATER || static::$blockID == STILL_WATER))) return false;
|
||||
if((($id == LAVA || $id == STILL_LAVA) && (static::$blockID == LAVA || static::$blockID == STILL_LAVA))) return false;
|
||||
|
||||
|
||||
if($face == 1) return true;
|
||||
return StaticBlock::getIsSolid($id);
|
||||
//return parent::shouldRenderFace($level, $x, $y, $z, $face);
|
||||
}
|
||||
|
||||
|
||||
public static function getFlow(Level $level, $x, $y, $z){
|
||||
$flowVector = new Vector3(0, 0, 0);
|
||||
$v6 = static::getRenderedDepth($level, $x, $y, $z);
|
||||
|
||||
|
||||
for($v7 = 0; $v7 < 4; ++$v7){
|
||||
$v8 = $x;
|
||||
$v10 = $z;
|
||||
|
|
@ -86,12 +86,12 @@ class LiquidBlock extends TransparentBlock{
|
|||
++$v10;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$v11 = static::getRenderedDepth($level, $v8, $y, $v10);
|
||||
if($v11 < 0){
|
||||
if(!StaticBlock::getIsSolid($level->level->getBlockID($v8, $y, $v10))){ //TODO material.blocksMovement
|
||||
$v11 = static::getRenderedDepth($level, $v8, $y - 1, $v10);
|
||||
|
||||
|
||||
if($v11 >= 0){
|
||||
$v12 = $v11 - ($v6 - 8);
|
||||
$flowVector->x += ($v8 - $x) * $v12;
|
||||
|
|
@ -99,29 +99,29 @@ class LiquidBlock extends TransparentBlock{
|
|||
$flowVector->z += ($v10 - $z) * $v12;
|
||||
}
|
||||
}
|
||||
}else if($v11 >= 0){
|
||||
}elseif($v11 >= 0){
|
||||
$v12 = $v11 - $v6;
|
||||
$flowVector->x += ($v8 - $x) * $v12;
|
||||
$flowVector->y += ($y - $y) * $v12;
|
||||
$flowVector->z += ($v10 - $z) * $v12;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$meta = $level->level->getBlockDamage($x, $y, $z);
|
||||
|
||||
|
||||
if($meta >= 8){
|
||||
$v13 = //TODO more vanilla way to do it
|
||||
static::shouldRenderFace($level, $x, $y, $z - 1, 2) ||
|
||||
static::shouldRenderFace($level, $x, $y, $z + 1, 3) ||
|
||||
static::shouldRenderFace($level, $x - 1, $y, $z, 4) ||
|
||||
static::shouldRenderFace($level, $x + 1, $y, $z, 5) ||
|
||||
|
||||
|
||||
static::shouldRenderFace($level, $x, $y + 1, $z - 1, 2) ||
|
||||
static::shouldRenderFace($level, $x, $y + 1, $z + 1, 3) ||
|
||||
static::shouldRenderFace($level, $x - 1, $y + 1, $z, 4) ||
|
||||
static::shouldRenderFace($level, $x + 1, $y + 1, $z, 5)
|
||||
;
|
||||
|
||||
|
||||
if($v13){
|
||||
$ln = $flowVector->length();
|
||||
if($ln){
|
||||
|
|
@ -141,37 +141,37 @@ class LiquidBlock extends TransparentBlock{
|
|||
}else{
|
||||
$flowVector->x = $flowVector->y = $flowVector->z = 0;
|
||||
}
|
||||
|
||||
|
||||
return $flowVector;
|
||||
}
|
||||
|
||||
|
||||
public static function addVelocityToEntity(Level $level, $x, $y, $z, Entity $entity, Vector3 $velocityVector){
|
||||
$flow = static::getFlow($level, $x, $y, $z);
|
||||
$velocityVector->x += $flow->x * 0.5;
|
||||
$velocityVector->y += $flow->y * 0.5;
|
||||
$velocityVector->z += $flow->z * 0.5;
|
||||
}
|
||||
|
||||
|
||||
public static function getTickDelay(){
|
||||
throw new RuntimeException("If you see this, something bad happened");
|
||||
}
|
||||
|
||||
|
||||
public static function updateLiquid(Level $level, $x, $y, $z){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
if($id != LAVA && $id != STILL_LAVA) return;
|
||||
|
||||
|
||||
$zNeg = $level->level->getBlockID($x, $y, $z - 1);
|
||||
$zPos = $level->level->getBlockID($x, $y, $z + 1);
|
||||
$xNeg = $level->level->getBlockID($x - 1, $y, $z);
|
||||
$xPos = $level->level->getBlockID($x + 1, $y, $z);
|
||||
$yPos = $level->level->getBlockID($x, $y + 1, $z);
|
||||
|
||||
|
||||
if(
|
||||
$zNeg == WATER || $zNeg == STILL_WATER
|
||||
|| $zPos == WATER || $zPos == STILL_WATER
|
||||
|| $xNeg == WATER || $xNeg == STILL_WATER
|
||||
|| $xPos == WATER || $xPos == STILL_WATER
|
||||
|| $yPos == WATER || $yPos == STILL_WATER
|
||||
|| $zPos == WATER || $zPos == STILL_WATER
|
||||
|| $xNeg == WATER || $xNeg == STILL_WATER
|
||||
|| $xPos == WATER || $xPos == STILL_WATER
|
||||
|| $yPos == WATER || $yPos == STILL_WATER
|
||||
) {
|
||||
if($meta){
|
||||
//if($meta > 4) -> fizz & ret
|
||||
|
|
@ -179,17 +179,16 @@ class LiquidBlock extends TransparentBlock{
|
|||
}else{
|
||||
$replacement = OBSIDIAN;
|
||||
}
|
||||
|
||||
|
||||
$level->fastSetBlockUpdate($x, $y, $z, $replacement, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
public function getLiquidHeight(){
|
||||
return (($this->meta >= 8 ? 0 : $this->meta)+1) / 9;
|
||||
return (($this->meta >= 8 ? 0 : $this->meta) + 1) / 9;
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ class SolidBlock extends GenericBlock{
|
|||
$this->isSolid = true;
|
||||
$this->isFullBlock = true;
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [new AxisAlignedBB($x, $y, $z, $x + 1, $y + 1, $z + 1)];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,26 +15,26 @@ class StairBlock extends TransparentBlock{
|
|||
}
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
|
||||
public static function isBlocksStairsID($id){
|
||||
return $id > 0 && StaticBlock::getBlock($id) instanceof StairBlock;
|
||||
}
|
||||
|
||||
|
||||
public static function isStairsAtXYZAndAreTheirMetadataSame(Level $level, $x, $y, $z, $meta){
|
||||
$block = $level->level->getBlock($x, $y, $z);
|
||||
return self::isBlocksStairsID($block[0]) && $block[1] == $meta;
|
||||
}
|
||||
|
||||
|
||||
public static function setBaseShape(Level $level, $x, $y, $z){
|
||||
$meta = $level->level->getBlockDamage($x, $y, $z);
|
||||
|
||||
|
||||
if(($meta & 4) != 0){
|
||||
return new AxisAlignedBB(0, 0.5, 0, 1, 1, 1);
|
||||
}else{
|
||||
return new AxisAlignedBB(0, 0, 0, 1, 0.5, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const DEAD_SAPCES = [
|
||||
[2, 6],
|
||||
[3, 7],
|
||||
|
|
@ -45,72 +45,72 @@ class StairBlock extends TransparentBlock{
|
|||
[0, 1],
|
||||
[4, 5]
|
||||
];
|
||||
|
||||
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
if(self::$complexState){
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
$cid = self::$complexStateID;
|
||||
StaticBlock::setBlockBounds($id,
|
||||
StaticBlock::setBlockBounds($id,
|
||||
0.5 * ($cid % 2),
|
||||
0.5 * ((int)($cid / 2) % 2),
|
||||
0.5 * ((int)($cid / 4) % 2),
|
||||
0.5 * ((int) ($cid / 2) % 2),
|
||||
0.5 * ((int) ($cid / 4) % 2),
|
||||
0.5 + 0.5 * ($cid % 2),
|
||||
0.5 + 0.5 * ((int)($cid / 2) % 2),
|
||||
0.5 + 0.5 * ((int)($cid / 4) % 2)
|
||||
0.5 + 0.5 * ((int) ($cid / 2) % 2),
|
||||
0.5 + 0.5 * ((int) ($cid / 4) % 2)
|
||||
);
|
||||
}else{
|
||||
StaticBlock::setBlockBounds($level->level->getBlockID($x, $y, $z), 0, 0, 0, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static $complexState = false;
|
||||
static $complexStateID = 0;
|
||||
public static function clip(Level $level, $x, $y, $z, Vector3 $start, Vector3 $end){
|
||||
$v7 = [];
|
||||
|
||||
|
||||
$v8 = $level->level->getBlockDamage($x, $y, $z);
|
||||
$v9 = $v8 & 3;
|
||||
$v10 = ($v8 & 4) == 4;
|
||||
$v11 = self::DEAD_SAPCES[$v9 + ($v10 ? 4 : 0)];
|
||||
self::$complexState = true;
|
||||
|
||||
|
||||
for($v12 = 0; $v12 < 8; ++$v12){
|
||||
self::$complexStateID = $v12;
|
||||
|
||||
|
||||
for($v15 = 0; $v15 < /*count($v11}*/ 2; ++$v15){
|
||||
$v16 = $v11[$v15];
|
||||
if($v16 == $v12){
|
||||
//wat
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$v7[$v12] = parent::clip($level, $x, $y, $z, $start, $end);
|
||||
}
|
||||
|
||||
|
||||
for($v14 = 0; $v14 < /*count($v11}*/ 2; ++$v14){
|
||||
$v15 = $v11[$v14];
|
||||
$v7[$v15] = null;
|
||||
}
|
||||
|
||||
|
||||
$v24 = 0;
|
||||
$v22 = null;
|
||||
|
||||
|
||||
for($v17 = 0; $v17 < count($v7); ++$v17){
|
||||
$v18 = $v7[$v17];
|
||||
|
||||
|
||||
if($v18 != null){
|
||||
$v19 = $v18->hitVector->distanceSquared($end);
|
||||
|
||||
|
||||
if($v19 > $v24){
|
||||
$v22 = $v18;
|
||||
$v24 = $v19;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $v22;
|
||||
}
|
||||
|
||||
|
||||
public static function setStepShape(Level $level, $x, $y, $z){
|
||||
$blockMeta = $level->level->getBlockDamage($x, $y, $z);
|
||||
$metaAnd3 = $blockMeta & 3;
|
||||
|
|
@ -120,13 +120,13 @@ class StairBlock extends TransparentBlock{
|
|||
$minY = 0.0;
|
||||
$maxY = 0.5;
|
||||
}
|
||||
|
||||
|
||||
$minX = 0;
|
||||
$maxX = 1;
|
||||
$minZ = 0;
|
||||
$maxZ = 0.5;
|
||||
$v13 = true;
|
||||
|
||||
|
||||
switch($metaAnd3){
|
||||
case 0:
|
||||
$minX = 0.5;
|
||||
|
|
@ -134,10 +134,10 @@ class StairBlock extends TransparentBlock{
|
|||
$blockNearby = $level->level->getBlock($x + 1, $y, $z);
|
||||
$blockIDNearby = $blockNearby[0];
|
||||
$blockMetaNearby = $blockNearby[1];
|
||||
|
||||
|
||||
if(self::isBlocksStairsID($blockIDNearby) && (($blockMeta & 4) == ($blockMetaNearby & 4))){
|
||||
$blockMetaNearbyAnd3 = $blockMetaNearby & 3;
|
||||
|
||||
|
||||
if($blockMetaNearbyAnd3 == 3 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x, $y, $z + 1, $blockMeta)){
|
||||
$maxZ = 0.5;
|
||||
$v13 = false;
|
||||
|
|
@ -153,10 +153,10 @@ class StairBlock extends TransparentBlock{
|
|||
$blockNearby = $level->level->getBlock($x - 1, $y, $z);
|
||||
$blockIDNearby = $blockNearby[0];
|
||||
$blockMetaNearby = $blockNearby[1];
|
||||
|
||||
|
||||
if(self::isBlocksStairsID($blockIDNearby) && (($blockMeta & 4) == ($blockMetaNearby & 4))){
|
||||
$blockMetaNearbyAnd3 = $blockMetaNearby & 3;
|
||||
|
||||
|
||||
if($blockMetaNearbyAnd3 == 3 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x, $y, $z + 1, $blockMeta)){
|
||||
$maxZ = 0.5;
|
||||
$v13 = false;
|
||||
|
|
@ -172,10 +172,10 @@ class StairBlock extends TransparentBlock{
|
|||
$blockNearby = $level->level->getBlock($x, $y, $z + 1);
|
||||
$blockIDNearby = $blockNearby[0];
|
||||
$blockMetaNearby = $blockNearby[1];
|
||||
|
||||
|
||||
if(self::isBlocksStairsID($blockIDNearby) && (($blockMeta & 4) == ($blockMetaNearby & 4))){
|
||||
$blockMetaNearbyAnd3 = $blockMetaNearby & 3;
|
||||
|
||||
|
||||
if($blockMetaNearbyAnd3 == 1 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x + 1, $y, $z, $blockMeta)){
|
||||
$maxX = 0.5;
|
||||
$v13 = false;
|
||||
|
|
@ -191,7 +191,7 @@ class StairBlock extends TransparentBlock{
|
|||
$blockMetaNearby = $blockNearby[1];
|
||||
if(self::isBlocksStairsID($blockIDNearby) && (($blockMeta & 4) == ($blockMetaNearby & 4))){
|
||||
$blockMetaNearbyAnd3 = $blockMetaNearby & 3;
|
||||
|
||||
|
||||
if($blockMetaNearbyAnd3 == 1 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x + 1, $y, $z, $blockMeta)){
|
||||
$maxX = 0.5;
|
||||
$v13 = false;
|
||||
|
|
@ -203,34 +203,34 @@ class StairBlock extends TransparentBlock{
|
|||
break;
|
||||
}
|
||||
return [new AxisAlignedBB($minX, $minY, $minZ, $maxX, $maxY, $maxZ), $v13];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function setInnerPieceShape(Level $level, $x, $y, $z){
|
||||
$meta = $level->level->getBlockDamage($x, $y, $z);
|
||||
$metaAnd3 = $meta & 3;
|
||||
$minY = 0.5;
|
||||
$maxY = 1.0;
|
||||
|
||||
|
||||
if(($meta & 4) != 0){
|
||||
$minY = 0.0;
|
||||
$maxY = 0.5;
|
||||
}
|
||||
|
||||
|
||||
$minX = 0.0;
|
||||
$maxX = 0.5;
|
||||
$minZ = 0.5;
|
||||
$maxZ = 1.0;
|
||||
$v13 = false;
|
||||
|
||||
|
||||
switch($metaAnd3){
|
||||
case 0:
|
||||
$idNearby = $level->level->getBlockID($x - 1, $y, $z);
|
||||
$metaNearby = $level->level->getBlockDamage($x - 1, $y, $z);
|
||||
|
||||
|
||||
if(self::isBlocksStairsID($idNearby) && ($meta & 4) == ($metaNearby & 4)){
|
||||
$metaNearbyAnd3 = $metaNearby & 3;
|
||||
|
||||
|
||||
if($metaNearbyAnd3 == 3 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x, $y, $z - 1, $meta)){
|
||||
$minZ = 0;
|
||||
$maxZ = 0.5;
|
||||
|
|
@ -245,7 +245,7 @@ class StairBlock extends TransparentBlock{
|
|||
case 1:
|
||||
$idNearby = $level->level->getBlockID($x + 1, $y, $z);
|
||||
$metaNearby = $level->level->getBlockDamage($x + 1, $y, $z);
|
||||
|
||||
|
||||
if(self::isBlocksStairsID($idNearby) && ($meta & 4) == ($metaNearby & 4)){
|
||||
$minX = 0.5;
|
||||
$maxX = 1.0;
|
||||
|
|
@ -261,17 +261,17 @@ class StairBlock extends TransparentBlock{
|
|||
$v13 = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case 2:
|
||||
$idNearby = $level->level->getBlockID($x, $y, $z - 1);
|
||||
$metaNearby = $level->level->getBlockDamage($x, $y, $z - 1);
|
||||
|
||||
|
||||
if(self::isBlocksStairsID($idNearby) && ($meta & 4) == ($metaNearby & 4)){
|
||||
$minZ = 0;
|
||||
$maxZ = 0.5;
|
||||
$metaNearbyAnd3 = $metaNearby & 3;
|
||||
|
||||
|
||||
if($metaNearbyAnd3 == 1 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x - 1, $y, $z, $meta)){
|
||||
$v13 = true;
|
||||
}elseif($metaNearbyAnd3 == 0 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x + 1, $y, $z, $meta)){
|
||||
|
|
@ -280,16 +280,16 @@ class StairBlock extends TransparentBlock{
|
|||
$v13 = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case 3:
|
||||
|
||||
|
||||
$idNearby = $level->level->getBlockID($x, $y, $z + 1);
|
||||
$metaNearby = $level->level->getBlockDamage($x, $y, $z + 1);
|
||||
|
||||
|
||||
if(self::isBlocksStairsID($idNearby) && ($meta & 4) == ($metaNearby & 4)){
|
||||
$metaNearbyAnd3 = $metaNearby & 3;
|
||||
|
||||
|
||||
if($metaNearbyAnd3 == 1 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x - 1, $y, $z, $meta)){
|
||||
$v13 = true;
|
||||
}elseif($metaNearbyAnd3 == 0 && !self::isStairsAtXYZAndAreTheirMetadataSame($level, $x + 1, $y, $z, $meta)){
|
||||
|
|
@ -300,10 +300,10 @@ class StairBlock extends TransparentBlock{
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return [new AxisAlignedBB($minX, $minY, $minZ, $maxX, $maxY, $maxZ), $v13];
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
$bbs = [self::setBaseShape($level, $x, $y, $z)->offset($x, $y, $z)];
|
||||
$ret = self::setStepShape($level, $x, $y, $z);
|
||||
|
|
@ -314,15 +314,11 @@ class StairBlock extends TransparentBlock{
|
|||
$bbs[] = $ret2[0]->offset($x, $y, $z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $bbs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
* @param Block $block
|
||||
* @param Block $target
|
||||
* @param int $face
|
||||
* @param int $fx
|
||||
* @param int $fy
|
||||
|
|
@ -331,12 +327,12 @@ class StairBlock extends TransparentBlock{
|
|||
* @return bool|mixed
|
||||
*/
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$faces = array(
|
||||
$faces = [
|
||||
0 => 0,
|
||||
1 => 2,
|
||||
2 => 1,
|
||||
3 => 3,
|
||||
);
|
||||
];
|
||||
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
|
||||
if(($fy > 0.5 and $face !== 1) or $face === 0){
|
||||
$this->meta |= 0x04; //Upside-down stairs
|
||||
|
|
@ -346,18 +342,16 @@ class StairBlock extends TransparentBlock{
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ class TransparentBlock extends GenericBlock{
|
|||
$this->isFlowable = false;
|
||||
$this->isTransparent = true;
|
||||
$this->isReplaceable = false;
|
||||
$this->isPlaceable = true;
|
||||
$this->isPlaceable = true;
|
||||
$this->isSolid = true;
|
||||
$this->boundingBox->setBounds($this->x, $this->y, $this->z, $this->x + 1, $this->y + 1, $this->z + 1);
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class LadderBlock extends TransparentBlock{
|
|||
public static $blockID;
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
|
||||
|
||||
switch($meta){
|
||||
case 2:
|
||||
StaticBlock::setBlockBounds($id, 0.0, 0.0, 0.875, 1.0, 1.0, 1.0);
|
||||
|
|
@ -18,9 +18,9 @@ class LadderBlock extends TransparentBlock{
|
|||
case 5:
|
||||
StaticBlock::setBlockBounds($id, 0, 0.0, 0.0, 0.125, 1.0, 1.0);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return parent::getAABB($level, $x, $y, $z);
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
|
|
@ -43,7 +43,7 @@ class LadderBlock extends TransparentBlock{
|
|||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
$side = $level->level->getBlockDamage($x, $y, $z);
|
||||
|
||||
|
||||
$attached = match($side){
|
||||
3 => $level->level->getBlockID($x, $y, $z - 1),
|
||||
2 => $level->level->getBlockID($x, $y, $z + 1),
|
||||
|
|
@ -51,7 +51,7 @@ class LadderBlock extends TransparentBlock{
|
|||
4 => $level->level->getBlockID($x + 1, $y, $z),
|
||||
default => 0 //TODO
|
||||
};
|
||||
|
||||
|
||||
if($attached == AIR){ //Replace with common break method
|
||||
ServerAPI::request()->api->entity->drop(new Position($x, $y, $z, $level), BlockAPI::getItem(LADDER, 0, 1));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
|
|
@ -59,8 +59,8 @@ class LadderBlock extends TransparentBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
}
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class SignPostBlock extends TransparentBlock{
|
|||
$this->isFullBlock = false;
|
||||
$this->hardness = 5;
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if(($target->isSolid || $target->getID() === SIGN_POST || $target->getID() === WALL_SIGN) && $face !== 0){
|
||||
if(!isset(self::$faces[$face])){
|
||||
|
|
@ -32,7 +32,7 @@ class SignPostBlock extends TransparentBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
if($level->level->getBlockID($x, $y - 1, $z) === AIR){ //Replace with common break method
|
||||
ServerAPI::request()->api->entity->drop(new Position($x, $y, $z, $level), BlockAPI::getItem(SIGN, 0, 1));
|
||||
|
|
@ -40,15 +40,15 @@ class SignPostBlock extends TransparentBlock{
|
|||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function onBreak(Item $item, Player $player){
|
||||
$this->level->setBlock($this, new AirBlock(), true, true, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(SIGN, 0, 1),
|
||||
);
|
||||
}
|
||||
return [
|
||||
[SIGN, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -6,15 +6,15 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
|
|||
parent::__construct(TORCH, $meta, "Torch");
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
|
||||
public function getMaxLightValue(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
$side = $level->level->getBlockDamage($x, $y, $z);
|
||||
$attach = match($side){
|
||||
|
|
@ -22,9 +22,9 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
|
|||
2 => $level->level->getBlockID($x + 1, $y, $z),
|
||||
3 => $level->level->getBlockID($x, $y, $z - 1),
|
||||
4 => $level->level->getBlockID($x, $y, $z + 1),
|
||||
default => $level->level->getBlockID($x, $y - 1, $z)
|
||||
default => $level->level->getBlockID($x, $y - 1, $z)
|
||||
};
|
||||
|
||||
|
||||
if(StaticBlock::getIsTransparent($attach) && !($side === 0 && $attach === FENCE)){ //Replace with common break method
|
||||
ServerAPI::request()->api->entity->drop(new Position($x, $y, $z, $level), BlockAPI::getItem(TORCH, 0, 1));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
|
|
@ -33,13 +33,13 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
|
|||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($target->isTransparent === false and $face !== 0){
|
||||
$faces = array(
|
||||
$faces = [
|
||||
1 => 5,
|
||||
2 => 4,
|
||||
3 => 3,
|
||||
4 => 2,
|
||||
5 => 1,
|
||||
);
|
||||
];
|
||||
$this->meta = $faces[$face];
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
return true;
|
||||
|
|
@ -51,8 +51,8 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
|
|||
return false;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -17,25 +17,25 @@ class TrapdoorBlock extends TransparentBlock{
|
|||
$id = $target->getID();
|
||||
return $id === SLAB || $id === GLOWSTONE || $id === SLAB || $id === WOOD_SLAB || (!$target->isTransparent || $target instanceof StairBlock);
|
||||
}
|
||||
|
||||
|
||||
public static function isOpen($meta){
|
||||
return ($meta >> 2) & 1;
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
static::updateShape($level, $x, $y, $z);
|
||||
return StaticBlock::getAABB(static::$blockID, $x, $y, $z);
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [static::getAABB($level, $x, $y, $z)];
|
||||
}
|
||||
|
||||
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
|
||||
|
||||
StaticBlock::setBlockBounds($id, 0.0, 0.0, 0.0, 1.0, 0.1875, 1.0);
|
||||
|
||||
|
||||
if(static::isOpen($meta)){
|
||||
$facing = $meta & 3;
|
||||
switch($facing){
|
||||
|
|
@ -56,24 +56,24 @@ class TrapdoorBlock extends TransparentBlock{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if(($this->canAttachTo($target)) and $face !== 0 and $face !== 1){
|
||||
$faces = array(
|
||||
$faces = [
|
||||
2 => 0,
|
||||
3 => 1,
|
||||
4 => 2,
|
||||
5 => 3,
|
||||
);
|
||||
];
|
||||
$this->meta = $faces[$face] & 0x03;
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
$attach = match($level->level->getBlockDamage($x, $y, $z)){
|
||||
|
|
@ -83,13 +83,13 @@ class TrapdoorBlock extends TransparentBlock{
|
|||
3, 7 => $level->level->getBlockID($x - 1, $y, $z),
|
||||
default => 0
|
||||
};
|
||||
|
||||
|
||||
if($attach == AIR){ //Replace with common break method
|
||||
ServerAPI::request()->api->entity->drop(new Position($x, $y, $z, $level), BlockAPI::getItem(TRAPDOOR, 0, 1));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
$this->meta ^= 0x04;
|
||||
$this->level->setBlock($this, $this, true, false, true);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class WallSignBlock extends SignPostBlock{
|
|||
TransparentBlock::__construct(WALL_SIGN, $meta, "Wall Sign");
|
||||
$this->isSolid = false;
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
$attached = match($level->level->getBlockDamage($x, $y, $z)){
|
||||
2 => $level->level->getBlockID($x, $y, $z + 1),
|
||||
|
|
@ -19,7 +19,7 @@ class WallSignBlock extends SignPostBlock{
|
|||
5 => $level->level->getBlockID($x - 1, $y, $z),
|
||||
default => WALL_SIGN
|
||||
};
|
||||
|
||||
|
||||
if(!StaticBlock::getIsSolid($attached) && $attached != SIGN_POST && $attached != WALL_SIGN){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true, true);
|
||||
(ServerAPI::request())->api->entity->drop(new Position($x + 0.5, $y + 0.5, $z + 0.5, $level), BlockAPI::getItem(SIGN, 0, 1));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once("LiquidBlockDynamic.php"); //TODO class loader?
|
||||
|
||||
class LavaBlock extends LiquidBlockDynamic implements LightingBlock{
|
||||
|
|
@ -7,16 +8,16 @@ class LavaBlock extends LiquidBlockDynamic implements LightingBlock{
|
|||
parent::__construct(LAVA, $meta, "Lava");
|
||||
$this->hardness = 500;
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$ret = $this->level->setBlock($this, $this, true, false, true);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public static function getTickDelay(){
|
||||
return 30;
|
||||
}
|
||||
|
||||
|
||||
public function getMaxLightValue(){
|
||||
return 15;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,55 +4,55 @@ class LiquidBlockDynamic extends LiquidBlock{
|
|||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
parent::__construct($id, $meta, $name);
|
||||
}
|
||||
|
||||
|
||||
public static $blockID = 0;
|
||||
public static $sourcesAround = 0;
|
||||
public static $spread = [0, 0, 0, 0];
|
||||
|
||||
|
||||
public static function getHighest(Level $level, $x, $y, $z, $highest){
|
||||
$depth = static::getDepth($level, $x, $y, $z);
|
||||
if($depth < 0) return $highest;
|
||||
if($depth == 0) ++static::$sourcesAround;
|
||||
if($depth >= 8) $depth = 0;
|
||||
|
||||
|
||||
return $highest >= 0 && $depth >= $highest ? $highest : $depth;
|
||||
}
|
||||
|
||||
|
||||
public static function setStatic(Level $level, $x, $y, $z){
|
||||
$meta = $level->level->getBlockDamage($x, $y, $z);
|
||||
|
||||
|
||||
$level->fastSetBlockUpdate($x, $y, $z, static::$blockID + 1, $meta);
|
||||
}
|
||||
|
||||
|
||||
public static function isWaterBlocking(Level $level, $x, $y, $z){
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
|
||||
|
||||
if($id == AIR) return false;
|
||||
|
||||
|
||||
if($id == DOOR_BLOCK || $id == SIGN_POST || $id == WALL_SIGN || $id == LADDER || $id == SUGARCANE_BLOCK) return true;
|
||||
|
||||
|
||||
if($id == CARPET || $id == SNOW_LAYER || $id == RAIL || $id == POWERED_RAIL) return false; //TODO Tile::getThickness() > 0
|
||||
|
||||
|
||||
//TODO materials
|
||||
//if(!StaticBlock::getIsFlowable($id)) return true;
|
||||
return StaticBlock::getIsSolid($id);
|
||||
}
|
||||
|
||||
|
||||
public static function canSpreadTo(Level $level, $x, $y, $z){
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
if($id == LAVA || $id == STILL_LAVA) return false;
|
||||
if((static::$blockID == WATER) && ($id == WATER || $id == STILL_WATER)) return false;
|
||||
|
||||
|
||||
return static::isWaterBlocking($level, $x, $y, $z) ^ 1;
|
||||
}
|
||||
|
||||
|
||||
public static function getSpread(Level $level, $x, $y, $z){
|
||||
for($i = 0; $i < 4; ++$i){
|
||||
static::$spread[$i] = 1000;
|
||||
$xs = $x;
|
||||
$ys = $y;
|
||||
$zs = $z;
|
||||
|
||||
|
||||
switch($i){
|
||||
case 0:
|
||||
--$xs;
|
||||
|
|
@ -67,13 +67,13 @@ class LiquidBlockDynamic extends LiquidBlock{
|
|||
++$zs;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(static::isWaterBlocking($level, $xs, $ys, $zs)) continue;
|
||||
[$id, $meta] = $level->level->getBlock($xs, $ys, $zs);
|
||||
if(((static::$blockID == WATER && ($id == WATER || $id == STILL_WATER)) || (static::$blockID == LAVA && ($id == LAVA || $id == STILL_LAVA))) && $meta == 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(!static::isWaterBlocking($level, $xs, $ys - 1, $zs)) static::$spread[$i] = 0;
|
||||
else static::$spread[$i] = static::getSlopeDistance($level, $xs, $ys, $zs, 1, $i);
|
||||
}
|
||||
|
|
@ -85,18 +85,18 @@ class LiquidBlockDynamic extends LiquidBlock{
|
|||
for($i = 0; $i < 4; ++$i) $ba[$i] = ($i1 == static::$spread[$i]);
|
||||
return $ba;
|
||||
}
|
||||
|
||||
|
||||
public static function getSlopeDistance(Level $level, $x, $y, $z, $l, $i1){
|
||||
$j1 = 1000;
|
||||
for($k1 = 0; $k1 < 4; ++$k1){
|
||||
if($k1 == 0 && $i1 == 1 || $k1 == 1 && $i1 == 0 || $k1 == 2 && $i1 == 3 || $k1 == 3 && $i1 == 2){
|
||||
if($k1 == 0 && $i1 == 1 || $k1 == 1 && $i1 == 0 || $k1 == 2 && $i1 == 3 || $k1 == 3 && $i1 == 2){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$xs = $x;
|
||||
$ys = $y;
|
||||
$zs = $z;
|
||||
|
||||
|
||||
switch($k1){
|
||||
case 0:
|
||||
--$xs;
|
||||
|
|
@ -111,10 +111,10 @@ class LiquidBlockDynamic extends LiquidBlock{
|
|||
++$zs;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(static::isWaterBlocking($level, $xs, $ys, $zs)) continue;
|
||||
[$id, $meta] = $level->level->getBlock($xs, $ys, $zs);
|
||||
|
||||
|
||||
if(
|
||||
((static::$blockID == WATER && ($id == WATER || $id == STILL_WATER)) ||
|
||||
(static::$blockID == LAVA && ($id == LAVA || $id == STILL_LAVA))) &&
|
||||
|
|
@ -122,20 +122,20 @@ class LiquidBlockDynamic extends LiquidBlock{
|
|||
){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(!static::isWaterBlocking($level, $xs, $ys - 1, $zs)) return $l;
|
||||
|
||||
|
||||
if($l >= 4) continue;
|
||||
$k2 = static::getSlopeDistance($level, $xs, $ys, $zs, $l + 1, $k1);
|
||||
if($k2 < $j1) $j1 = $k2;
|
||||
}
|
||||
return $j1;
|
||||
}
|
||||
|
||||
|
||||
public static function trySpreadTo(Level $level, $x, $y, $z, $meta){
|
||||
if(static::canSpreadTo($level, $x, $y, $z)){
|
||||
[$id, $meta2] = $level->level->getBlock($x, $y, $z);
|
||||
|
||||
|
||||
if($id > 0){
|
||||
if(($id == LAVA || $id == STILL_LAVA) && (static::$blockID == LAVA || static::$blockID == STILL_LAVA)); //fizz
|
||||
else{
|
||||
|
|
@ -147,23 +147,23 @@ class LiquidBlockDynamic extends LiquidBlock{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$level->fastSetBlockUpdate($x, $y, $z, static::$blockID, $meta, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function onPlace(Level $level, $x, $y, $z){
|
||||
static::updateLiquid($level, $x, $y, $z);
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
if($id == static::$blockID) ServerAPI::request()->api->block->scheduleBlockUpdateXYZ($level, $x, $y, $z, BLOCK_UPDATE_SCHEDULED, static::getTickDelay());
|
||||
}
|
||||
|
||||
|
||||
public static function onUpdate(Level $level, $x, $y, $z, $type){
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
$depth = static::getDepth($level, $x, $y, $z);
|
||||
$flowAdd = (static::$blockID == LAVA) ? 2 : 1;
|
||||
$flag = true;
|
||||
|
||||
|
||||
if($depth > 0){
|
||||
static::$sourcesAround = 0;
|
||||
$highest = static::getHighest($level, $x - 1, $y, $z, -100);
|
||||
|
|
@ -174,19 +174,19 @@ class LiquidBlockDynamic extends LiquidBlock{
|
|||
if($j1 >= 8 || $highest < 0) $j1 = -1;
|
||||
$l1 = static::getDepth($level, $x, $y + 1, $z);
|
||||
if($l1 >= 0) $j1 = ($l1 >= 8 ? $l1 : $l1 + 8);
|
||||
|
||||
|
||||
if(static::$sourcesAround >= 2 && static::$blockID == WATER){
|
||||
$idBot = $level->level->getBlockID($x, $y - 1, $z);
|
||||
if($idBot > 0){
|
||||
if(StaticBlock::getIsSolid($idBot) || (($idBot == WATER || $idBot == STILL_WATER) && $level->level->getBlockDamage($x, $y, $z) == 0)) $j1 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//if(static::$blockID == LAVA && $depth < 8 && $j1 < 8 && $j1 > $depth && mt_rand(0, 4) != 0){ TODO fix later
|
||||
// $j1 = $depth;
|
||||
// $flag = false;
|
||||
//}
|
||||
|
||||
|
||||
if($j1 != $depth){
|
||||
$depth = $j1;
|
||||
if($depth < 0) $level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
|
|
@ -195,16 +195,16 @@ class LiquidBlockDynamic extends LiquidBlock{
|
|||
ServerAPI::request()->api->block->scheduleBlockUpdateXYZ($level, $x, $y, $z, BLOCK_UPDATE_SCHEDULED, static::getTickDelay());
|
||||
$level->updateNeighborsAt($x, $y, $z, static::$blockID); //TODO check is needed
|
||||
}
|
||||
}else if($flag){
|
||||
}elseif($flag){
|
||||
static::setStatic($level, $x, $y, $z);
|
||||
}
|
||||
}else{
|
||||
static::setStatic($level, $x, $y, $z);
|
||||
}
|
||||
|
||||
|
||||
if(static::canSpreadTo($level, $x, $y - 1, $z)){
|
||||
$level->fastSetBlockUpdate($x, $y - 1, $z, static::$blockID, ($depth >= 8 ? $depth : $depth + 8) & 0xf, true);
|
||||
}else if($depth >= 0 && ($depth == 0 || static::isWaterBlocking($level, $x, $y - 1, $z))){
|
||||
}elseif($depth >= 0 && ($depth == 0 || static::isWaterBlocking($level, $x, $y - 1, $z))){
|
||||
$flags = static::getSpread($level, $x, $y, $z);
|
||||
$k1 = $depth >= 8 ? 1 : ($depth + $flowAdd);
|
||||
if($k1 >= 8) return;
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ class LiquidBlockStatic extends LiquidBlock{
|
|||
}
|
||||
public static $blockID = 0;
|
||||
//TODO: tick: try spread fire if lava
|
||||
|
||||
|
||||
public static function setDynamic(Level $level, $x, $y, $z){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
$dynamicID = $id - 1; //very unsafe
|
||||
$level->fastSetBlockUpdate($x, $y, $z, $dynamicID, $meta);
|
||||
$level->fastSetBlockUpdate($x, $y, $z, $dynamicID, $meta);
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
$oldID = $level->level->getBlockID($x, $y, $z);
|
||||
static::updateLiquid($level, $x, $y, $z);
|
||||
|
|
@ -21,6 +21,5 @@ class LiquidBlockStatic extends LiquidBlock{
|
|||
static::setDynamic($level, $x, $y, $z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once("LiquidBlockStatic.php"); //TODO class loader?
|
||||
|
||||
class StillLavaBlock extends LiquidBlockStatic{
|
||||
|
|
@ -7,9 +8,9 @@ class StillLavaBlock extends LiquidBlockStatic{
|
|||
parent::__construct(STILL_LAVA, $meta, "Still Lava");
|
||||
$this->hardness = 500;
|
||||
}
|
||||
|
||||
|
||||
public static function getTickDelay(){
|
||||
return 30;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
|
||||
/***REM_START***/
|
||||
require_once("WaterBlock.php"); //TODO class loader?
|
||||
require_once("LiquidBlockStatic.php"); //TODO class loader?
|
||||
|
|
@ -13,7 +12,7 @@ class StillWaterBlock extends LiquidBlockStatic{
|
|||
LiquidBlock::__construct(STILL_WATER, $meta, "Still Water");
|
||||
$this->hardness = 500;
|
||||
}
|
||||
|
||||
|
||||
public static function getTickDelay(){
|
||||
return 5;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,20 @@
|
|||
<?php
|
||||
|
||||
require_once("LiquidBlockDynamic.php"); //TODO class loader?
|
||||
|
||||
class WaterBlock extends LiquidBlockDynamic{
|
||||
public static $blockID = WATER;
|
||||
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(WATER, $meta, "Water");
|
||||
$this->hardness = 500;
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$ret = $this->level->setBlock($this, $this, true, false, true);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public static function getTickDelay(){
|
||||
return 5;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class AirBlock extends TransparentBlock{
|
||||
public static $blockID;
|
||||
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(AIR, 0, "Air");
|
||||
$this->isActivable = false;
|
||||
|
|
@ -15,7 +15,7 @@ class AirBlock extends TransparentBlock{
|
|||
$this->isSolid = false;
|
||||
$this->isFullBlock = true;
|
||||
$this->hardness = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -20,37 +20,37 @@ class BedBlock extends TransparentBlock{
|
|||
$this->isFullBlock = false;
|
||||
$this->hardness = 1;
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [static::getAABB($level, $x, $y, $z)];
|
||||
}
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
|
||||
|
||||
$meta = $level->level->getBlockDamage($x, $y, $z);
|
||||
$dir = $meta & 3;
|
||||
$isHead = ($meta >> 3) & 1;
|
||||
|
||||
|
||||
$offX = self::HEAD_DIRECTION_OFFSETS[$dir][0];
|
||||
$offZ = self::HEAD_DIRECTION_OFFSETS[$dir][1];
|
||||
|
||||
|
||||
if($isHead){
|
||||
if($level->level->getBlockID($x - $offX, $y, $z - $offZ) != BED_BLOCK){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
}
|
||||
}else if($level->level->getBlockID($x + $offX, $y, $z + $offZ) != BED_BLOCK){
|
||||
}elseif($level->level->getBlockID($x + $offX, $y, $z + $offZ) != BED_BLOCK){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
|
||||
|
||||
ServerAPI::request()->api->entity->dropRawPos(
|
||||
$level,
|
||||
$x + (lcg_value() * 0.7) + 0.15,
|
||||
$y + (lcg_value() * 0.7) + 0.15,
|
||||
$z + (lcg_value() * 0.7) + 0.15,
|
||||
BlockAPI::getItem(BED, 0, 1),
|
||||
$level,
|
||||
$x + (lcg_value() * 0.7) + 0.15,
|
||||
$y + (lcg_value() * 0.7) + 0.15,
|
||||
$z + (lcg_value() * 0.7) + 0.15,
|
||||
BlockAPI::getItem(BED, 0, 1),
|
||||
lcg_value() * 0.2 - 0.1, 0.2, lcg_value() * 0.2 - 0.1
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static function findStandUpPosition(Level $level, $x, $y, $z){
|
||||
$blockMeta = $level->level->getBlockDamage($x, $y, $z);
|
||||
|
|
@ -60,7 +60,7 @@ class BedBlock extends TransparentBlock{
|
|||
$minZ = $z - self::HEAD_DIRECTION_OFFSETS[$direction][1] * $v7 - 1;
|
||||
$maxX = $minX + 2;
|
||||
$maxZ = $minZ + 2;
|
||||
|
||||
|
||||
for($xCheck = $minX; $xCheck <= $maxX; ++$xCheck){
|
||||
for($zCheck = $minZ; $zCheck <= $maxZ; ++$zCheck){
|
||||
$idCheck = $level->level->getBlockID($xCheck, $y - 1, $zCheck);
|
||||
|
|
@ -70,10 +70,10 @@ class BedBlock extends TransparentBlock{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if(ServerAPI::request()->api->time->getPhase($player->level) !== "night"){
|
||||
$pk = new ChatPacket;
|
||||
|
|
@ -81,12 +81,12 @@ class BedBlock extends TransparentBlock{
|
|||
$player->dataPacket($pk);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
$blockNorth = $this->getSide(2); //Gets the blocks around them
|
||||
$blockSouth = $this->getSide(3);
|
||||
$blockEast = $this->getSide(5);
|
||||
$blockWest = $this->getSide(4);
|
||||
if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
|
||||
if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
|
||||
$b = $this;
|
||||
}else{ //Bottom Part of Bed
|
||||
if($blockNorth->getID() === $this->id and ($blockNorth->meta & 0x08) === 0x08){
|
||||
|
|
@ -112,11 +112,11 @@ class BedBlock extends TransparentBlock{
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$down = $this->getSide(0);
|
||||
if($down->isTransparent === false){
|
||||
|
||||
|
||||
$d = $player->entity->getDirection();
|
||||
$next = $this->getSide(self::$faces[(($d + 3) % 4)]);
|
||||
$downNext = $next->getSide(0);
|
||||
|
|
@ -128,15 +128,15 @@ class BedBlock extends TransparentBlock{
|
|||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function onBreak(Item $item, Player $player){
|
||||
$blockNorth = $this->getSide(2); //Gets the blocks around them
|
||||
$blockSouth = $this->getSide(3);
|
||||
$blockEast = $this->getSide(5);
|
||||
$blockWest = $this->getSide(4);
|
||||
|
||||
if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
|
||||
|
||||
if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
|
||||
switch($this->meta & 0x7){
|
||||
case 0:
|
||||
if($blockNorth->id === $this->id) $this->level->setBlock($blockNorth, new AirBlock(), true, false, true);
|
||||
|
|
@ -170,11 +170,11 @@ class BedBlock extends TransparentBlock{
|
|||
$this->level->setBlock($this, new AirBlock(), true, false, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(BED, 0, 1),
|
||||
);
|
||||
return [
|
||||
[BED, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ class FireBlock extends FlowableBlock implements LightingBlock{
|
|||
public static $blockID;
|
||||
public static $flammability = [];
|
||||
public static $fireCatchingChance = [];
|
||||
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(FIRE, $meta, "Fire");
|
||||
$this->isReplaceable = true;
|
||||
|
|
@ -19,39 +19,39 @@ class FireBlock extends FlowableBlock implements LightingBlock{
|
|||
self::$flammability[$blockID] = $flammability;
|
||||
self::$fireCatchingChance[$blockID] = $v;
|
||||
}
|
||||
|
||||
|
||||
public static function canBurn(Level $level, $x, $y, $z){
|
||||
return self::$flammability[$level->level->getBlockID($x, $y, $z)] > 0;
|
||||
}
|
||||
|
||||
|
||||
public static function onRandomTick(Level $level, $x, $y, $z){
|
||||
if($level->level->getBlockID($x, $y - 1, $z) !== NETHERRACK){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function onPlace(Level $level, $x, $y, $z){
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdateXYZ($level, $x, $y, $z, BLOCK_UPDATE_SCHEDULED, 30);
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
public function getMaxLightValue(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
$b = $level->level->getBlockID($x, $y - 1, $z);
|
||||
if(!StaticBlock::getIsSolid($b)) $level->fastSetBlockUpdate($x, $y, $z, 0, 0, true); //TODO more vanilla later?
|
||||
}
|
||||
|
||||
|
||||
public static function onUpdate(Level $level, $x, $y, $z, $type){
|
||||
if($type === BLOCK_UPDATE_SCHEDULED){
|
||||
$idBelow = $level->level->getBlockID($x, $y - 1, $z);
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
$alwaysBurn = $idBelow == NETHERRACK;
|
||||
|
||||
|
||||
if($meta < 15){
|
||||
$newMeta = $meta + 1; //TODO better formula
|
||||
if($newMeta > 15) $newMeta = 15;
|
||||
|
|
@ -65,20 +65,19 @@ class FireBlock extends FlowableBlock implements LightingBlock{
|
|||
}
|
||||
}
|
||||
$chance = self::$fireCatchingChance[$idBelow];
|
||||
|
||||
|
||||
if(mt_rand(0, 249) < $chance){
|
||||
//TODO ignite tnt
|
||||
$level->fastSetBlockUpdate($x, $y - 1, $z, 0, 0, true);
|
||||
goto REMOVE_FIRE;
|
||||
}
|
||||
|
||||
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdateXYZ($level, $x, $y, $z, BLOCK_UPDATE_SCHEDULED, 30); //TODO looks like it also adds mt_rand(0, 9) to it
|
||||
}
|
||||
}
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
parent::place($item, $player, $block, $target, $face, $fx, $fy, $fz);
|
||||
$this->level->scheduleBlockUpdate($this, 30, BLOCK_UPDATE_SCHEDULED);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ class NetherReactorBlock extends SolidBlock{
|
|||
parent::__construct(NETHER_REACTOR, $meta, "Nether Reactor");
|
||||
$this->isActivable = true;
|
||||
}
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
//if(($item->getID() === IRON_SWORD || $item->getID() === WOODEN_SWORD || $item->getID() === STONE_SWORD || $item->getID() === DIAMOND_SWORD || $item->getID() === GOLD_SWORD) /*&& $player->gamemode === 0*/){
|
||||
if($this->getMetadata() === 0 && $this->isCorrect($this->getX(),$this->getY(),$this->getZ()) && $this->getY() < 101 && NetherReactorBlock::$enableReactor){
|
||||
|
|
@ -15,58 +15,58 @@ class NetherReactorBlock extends SolidBlock{
|
|||
$this->meta = 1;
|
||||
$this->level->setBlock($this,$this);
|
||||
$server = ServerAPI::request();
|
||||
$server->schedule(40, array($this, "glow"), 1);
|
||||
$server->schedule(60, array($this, "glow"), 2);
|
||||
$server->schedule(80, array($this, "glow"), 3);
|
||||
$server->schedule(140, array($this, "glow"), 4);
|
||||
$server->schedule(200, array($this, "spawnItems"), [0,15,2,true]); //200
|
||||
$server->schedule(260, array($this, "spawnItems"), [0,15,"checkPigmen",true]);
|
||||
$server->schedule(300, array($this, "spawnItems"), [0,15,"checkPigmen",true]);
|
||||
$server->schedule(340, array($this, "spawnItems"), [11,20,"checkPigmen",false]);
|
||||
$server->schedule(400, array($this, "spawnItems"), [0,10,"checkPigmen",false]);
|
||||
$server->schedule(500, array($this, "spawnItems"), [17,32, "checkPigmen",false]); //500
|
||||
$server->schedule(580, array($this, "spawnItems"), [17,32, "checkPigmen",false]);
|
||||
$server->schedule(620, array($this, "spawnItems"), [1,32, "checkPigmen",false]);
|
||||
$server->schedule(660, array($this, "spawnItems"), [1,32,"checkPigmen",false]);
|
||||
$server->schedule(700, array($this, "spawnItems"), [1,32,"checkPigmen",false]);
|
||||
$server->schedule(860, array($this, "glow"), 5);
|
||||
$server->schedule(880, array($this, "glow"), 6);
|
||||
$server->schedule(900, array($this, "glow"), 7);
|
||||
$server->schedule(920, array($this, "destroy"));
|
||||
$server->schedule(40, [$this, "glow"], 1);
|
||||
$server->schedule(60, [$this, "glow"], 2);
|
||||
$server->schedule(80, [$this, "glow"], 3);
|
||||
$server->schedule(140, [$this, "glow"], 4);
|
||||
$server->schedule(200, [$this, "spawnItems"], [0,15,2,true]); //200
|
||||
$server->schedule(260, [$this, "spawnItems"], [0,15,"checkPigmen",true]);
|
||||
$server->schedule(300, [$this, "spawnItems"], [0,15,"checkPigmen",true]);
|
||||
$server->schedule(340, [$this, "spawnItems"], [11,20,"checkPigmen",false]);
|
||||
$server->schedule(400, [$this, "spawnItems"], [0,10,"checkPigmen",false]);
|
||||
$server->schedule(500, [$this, "spawnItems"], [17,32, "checkPigmen",false]); //500
|
||||
$server->schedule(580, [$this, "spawnItems"], [17,32, "checkPigmen",false]);
|
||||
$server->schedule(620, [$this, "spawnItems"], [1,32, "checkPigmen",false]);
|
||||
$server->schedule(660, [$this, "spawnItems"], [1,32,"checkPigmen",false]);
|
||||
$server->schedule(700, [$this, "spawnItems"], [1,32,"checkPigmen",false]);
|
||||
$server->schedule(860, [$this, "glow"], 5);
|
||||
$server->schedule(880, [$this, "glow"], 6);
|
||||
$server->schedule(900, [$this, "glow"], 7);
|
||||
$server->schedule(920, [$this, "destroy"]);
|
||||
return true;
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function destroy(){
|
||||
$this->level->setBlock(new Vector3($this->x, $this->y, $this->z),new NetherReactorBlock(2));
|
||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 0, 17, 16, 2, 34, 1, 0, 17, 1);
|
||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 1, 16, 1, 2, 34, 1, 0, 17, 16);
|
||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 3, 14, 10, 8, 34, 1, 3, 14, 1);
|
||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 4, 13, 1, 8, 34, 1, 3, 14, 10);
|
||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 5, 12, 6, 14, 34, 1, 5, 12, 1);
|
||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 6, 11, 1, 14, 34, 1, 5, 12, 16);
|
||||
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 0, 17, 16, 2, 34, 1, 0, 17, 1);
|
||||
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 1, 16, 1, 2, 34, 1, 0, 17, 16);
|
||||
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 3, 14, 10, 8, 34, 1, 3, 14, 1);
|
||||
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 4, 13, 1, 8, 34, 1, 3, 14, 10);
|
||||
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 5, 12, 6, 14, 34, 1, 5, 12, 1);
|
||||
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 6, 11, 1, 14, 34, 1, 5, 12, 16);
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return [[NETHER_REACTOR, 0, 1]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function decay($x, $y, $z, $aOne, $aTwo, $aThree, $bOne, $bTwo, $bThree, $cOne, $cTwo, $cThree) {
|
||||
for($a = $aOne; $a < $aTwo; $a += $aThree) {
|
||||
for($b = $bOne; $b < $bTwo; $b += $bThree) {
|
||||
for($c = $cOne; $c < $cTwo; $c += $cThree) {
|
||||
if ($this->level->level->getBlockID($x+$a, $y+$b, $z+$c) === NETHERRACK && lcg_value() > 0.75){
|
||||
$this->level->fastSetBlockUpdate($x+$a, $y+$b, $z+$c, 0, 0);
|
||||
if ($this->level->level->getBlockID($x + $a, $y + $b, $z + $c) === NETHERRACK && lcg_value() > 0.75){
|
||||
$this->level->fastSetBlockUpdate($x + $a, $y + $b, $z + $c, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function pigmenCheck($x,$y,$z) {
|
||||
$pigCount = 0;
|
||||
$server = ServerAPI::request();
|
||||
|
|
@ -88,28 +88,28 @@ class NetherReactorBlock extends SolidBlock{
|
|||
$forceAmount = $data[3];
|
||||
$server = ServerAPI::request();
|
||||
if(!$forceAmount){
|
||||
$spawnNumber = $minAmount + floor(lcg_value()*($maxAmount-$minAmount+1));
|
||||
$spawnNumber = $minAmount + floor(lcg_value() * ($maxAmount - $minAmount + 1));
|
||||
}
|
||||
else{
|
||||
$spawnNumber = $maxAmount;
|
||||
}
|
||||
for($i = 0; $i < $spawnNumber; $i++) {
|
||||
$randomRange = floor(lcg_value()*5+3);
|
||||
$shiftX = cos(floor(lcg_value()*360)*(pi()/180));
|
||||
$shiftZ = sin(floor(lcg_value()*360)*(pi()/180));
|
||||
$randomRange = floor(lcg_value() * 5 + 3);
|
||||
$shiftX = cos(floor(lcg_value() * 360) * (pi() / 180));
|
||||
$shiftZ = sin(floor(lcg_value() * 360) * (pi() / 180));
|
||||
if(Utils::chance(5)) $randomID = $this->rarePossibleLoot[array_rand($this->rarePossibleLoot)];
|
||||
else $randomID = $this->possibleLoot[array_rand($this->possibleLoot)];
|
||||
$server->api->entity->drop(new Position($x+($shiftX*$randomRange)+0.5, $y, $z+($shiftZ*$randomRange)+0.5, $this->level), BlockAPI::getItem($randomID, 0, 1));
|
||||
$server->api->entity->drop(new Position($x + ($shiftX * $randomRange) + 0.5, $y, $z + ($shiftZ * $randomRange) + 0.5, $this->level), BlockAPI::getItem($randomID, 0, 1));
|
||||
}
|
||||
for($i = 0; $i < $pigmen; $i++) {
|
||||
$randomRange = floor(lcg_value()*5+3);
|
||||
$shiftX = cos(floor(lcg_value()*360)*(pi()/180));
|
||||
$shiftZ = sin(floor(lcg_value()*360)*(pi()/180));
|
||||
$data = array(
|
||||
"x" => $x+($shiftX*$randomRange)+0.5,
|
||||
"y" => $y,
|
||||
"z" => $z+($shiftZ*$randomRange)+0.5,
|
||||
);
|
||||
$randomRange = floor(lcg_value() * 5 + 3);
|
||||
$shiftX = cos(floor(lcg_value() * 360) * (pi() / 180));
|
||||
$shiftZ = sin(floor(lcg_value() * 360) * (pi() / 180));
|
||||
$data = [
|
||||
"x" => $x + ($shiftX * $randomRange) + 0.5,
|
||||
"y" => $y,
|
||||
"z" => $z + ($shiftZ * $randomRange) + 0.5,
|
||||
];
|
||||
$e = $server->api->entity->add($this->level, ENTITY_MOB, MOB_PIGMAN, $data);
|
||||
$server->api->entity->spawnToAll($e);
|
||||
}
|
||||
|
|
@ -120,63 +120,63 @@ class NetherReactorBlock extends SolidBlock{
|
|||
$z = $this->z;
|
||||
switch($part){
|
||||
case 1:
|
||||
$this->level->setBlock(new Vector3($x, $y-1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y-1, $z+1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y-1, $z-1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y - 1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y - 1, $z + 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y - 1, $z - 1),new GlowingObsidianBlock);
|
||||
break;
|
||||
case 2:
|
||||
$this->level->setBlock(new Vector3($x+1, $y, $z+1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y, $z-1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y, $z+1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y, $z-1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y, $z + 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y, $z - 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y, $z + 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y, $z - 1),new GlowingObsidianBlock);
|
||||
break;
|
||||
case 3:
|
||||
$this->level->setBlock(new Vector3($x, $y+1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y+1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y+1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y+1, $z+1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y+1, $z-1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y + 1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y + 1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y + 1, $z),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y + 1, $z + 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y + 1, $z - 1),new GlowingObsidianBlock);
|
||||
break;
|
||||
case 4:
|
||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z+1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z-1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z+1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z-1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z + 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z - 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z + 1),new GlowingObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z - 1),new GlowingObsidianBlock);
|
||||
break;
|
||||
case 5:
|
||||
$this->level->setBlock(new Vector3($x, $y+1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y+1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y+1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y+1, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y+1, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y+1, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y+1, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y+1, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y+1, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y + 1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y + 1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y + 1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y + 1, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y + 1, $z - 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y + 1, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y + 1, $z - 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y + 1, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y + 1, $z - 1),new ObsidianBlock);
|
||||
break;
|
||||
case 6:
|
||||
$this->level->setBlock(new Vector3($x, $y, $z), new NetherReactorBlock(2));
|
||||
$this->level->setBlock(new Vector3($x+1, $y, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y, $z - 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y, $z - 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y, $z - 1),new ObsidianBlock);
|
||||
break;
|
||||
case 7:
|
||||
$this->level->setBlock(new Vector3($x, $y-1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y-1, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y-1, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z+1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z-1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y - 1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y - 1, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x, $y - 1, $z - 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z - 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z + 1),new ObsidianBlock);
|
||||
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z - 1),new ObsidianBlock);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -218,18 +218,18 @@ class NetherReactorBlock extends SolidBlock{
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private $possibleLoot = [
|
||||
GLOWSTONE_DUST, QUARTZ, CACTUS, SUGARCANE, BROWN_MUSHROOM, RED_MUSHROOM, PUMPKIN_SEEDS, MELON_SEEDS
|
||||
];
|
||||
|
||||
|
||||
private $rarePossibleLoot = [
|
||||
BOW, BED, BOWL, ARROW, WOODEN_DOOR, FEATHER, PAINTING, BONE, DANDELION
|
||||
];
|
||||
|
||||
|
||||
private $core = [
|
||||
-1 => ["GCG", "CCC", "GCG"],
|
||||
0 => ["C C", " R ", "C C",],
|
||||
1 =>[" C ", "CCC", " C "]
|
||||
1 => [" C ", "CCC", " C "]
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,19 +7,19 @@ class TNTBlock extends SolidBlock{
|
|||
$this->hardness = 0;
|
||||
$this->isActivable = true;
|
||||
}
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($item->getID() === FLINT_STEEL){
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$item->useOn($this);
|
||||
}
|
||||
$data = array(
|
||||
$data = [
|
||||
"x" => $this->x + 0.5,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z + 0.5,
|
||||
"power" => 3,
|
||||
"fuse" => 20 * 4, //4 seconds
|
||||
);
|
||||
];
|
||||
$this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, 0, 0, true);
|
||||
$e = ServerAPI::request()->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data);
|
||||
ServerAPI::request()->api->entity->spawnToAll($e);
|
||||
|
|
|
|||
|
|
@ -9,18 +9,18 @@ class CakeBlock extends TransparentBlock{
|
|||
$this->meta = $meta & 0x07;
|
||||
$this->hardness = 2.5;
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
$data = $level->level->getBlockDamage($x, $y, $z);
|
||||
return [new AxisAlignedBB($x + (2*$data + 1) * 0.0625, $y, $z + 0.0625, $x + 0.9375, $y + 0.5, $z + 0.9375)];
|
||||
return [new AxisAlignedBB($x + (2 * $data + 1) * 0.0625, $y, $z + 0.0625, $x + 0.9375, $y + 0.5, $z + 0.9375)];
|
||||
}
|
||||
|
||||
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
[$id, $data] = $level->level->getBlock($x, $y, $z);
|
||||
|
||||
|
||||
StaticBlock::setBlockBounds($id, (2 * $data + 1) * 0.0625, 0.0, 0.0625, 0.9375, 0.5, 0.9375);
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() !== AIR){
|
||||
|
|
@ -29,17 +29,17 @@ class CakeBlock extends TransparentBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
if($level->level->getBlockID($x, $y - 1, $z) == AIR){ //Replace with common break method
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($player->entity->getHealth() < 20){
|
||||
++$this->meta;
|
||||
|
|
@ -53,5 +53,5 @@ class CakeBlock extends TransparentBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ class CarpetBlock extends FlowableBlock{
|
|||
public static $blockID;
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(CARPET, $meta, "Carpet");
|
||||
$names = array(
|
||||
$names = [
|
||||
0 => "White Carpet",
|
||||
1 => "Orange Carpet",
|
||||
2 => "Magenta Carpet",
|
||||
|
|
@ -21,10 +21,10 @@ class CarpetBlock extends FlowableBlock{
|
|||
13 => "Green Carpet",
|
||||
14 => "Red Carpet",
|
||||
15 => "Black Carpet",
|
||||
);
|
||||
];
|
||||
$this->name = $names[$this->meta];
|
||||
$this->hardness = 0;
|
||||
$this->isFullBlock = false;
|
||||
$this->isFullBlock = false;
|
||||
$this->isSolid = true;
|
||||
}
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
|
|
|
|||
|
|
@ -11,19 +11,19 @@ class ChestBlock extends TransparentBlock{
|
|||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [new AxisAlignedBB($x + 0.025, $y, $z + 0.025, $x + 0.975, $y + 0.95, $z + 0.975)];
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$server = ServerAPI::request();
|
||||
$faces = array(
|
||||
$faces = [
|
||||
0 => 4,
|
||||
1 => 2,
|
||||
2 => 5,
|
||||
3 => 3,
|
||||
);
|
||||
];
|
||||
|
||||
$chest = false;
|
||||
$this->meta = $faces[$player->entity->getDirection()];
|
||||
|
||||
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
if(($this->meta === 4 or $this->meta === 5) and ($side === 4 or $side === 5)){
|
||||
continue;
|
||||
|
|
@ -40,22 +40,22 @@ class ChestBlock extends TransparentBlock{
|
|||
}
|
||||
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
$tile = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
|
||||
"Items" => array(),
|
||||
$tile = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, [
|
||||
"Items" => [],
|
||||
"id" => TILE_CHEST,
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z
|
||||
));
|
||||
]);
|
||||
$server->api->tile->spawnToAll($tile);
|
||||
|
||||
|
||||
if($chest instanceof Tile){
|
||||
$chest->pairWith($tile);
|
||||
$tile->pairWith($chest);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function onBreak(Item $item, Player $player){
|
||||
$t = ServerAPI::request()->api->tile->get($this);
|
||||
if($t !== false){
|
||||
|
|
@ -64,48 +64,46 @@ class ChestBlock extends TransparentBlock{
|
|||
$this->level->setBlock($this, new AirBlock(), true, true, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
$top = $this->getSide(1);
|
||||
if($top->isTransparent !== true){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
$server = ServerAPI::request();
|
||||
$t = $server->api->tile->get($this);
|
||||
$chest = false;
|
||||
if($t !== false){
|
||||
$chest = $t;
|
||||
}else{
|
||||
$chest = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
|
||||
"Items" => array(),
|
||||
$chest = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, [
|
||||
"Items" => [],
|
||||
"id" => TILE_CHEST,
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z
|
||||
));
|
||||
"z" => $this->z
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(($player->gamemode & 0x01) === 0x01){
|
||||
return true;
|
||||
}
|
||||
|
||||
$chest->openInventory($player);
|
||||
|
||||
$chest->openInventory($player);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
$drops = array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
$drops = [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
$t = ServerAPI::request()->api->tile->get($this);
|
||||
if($t !== false and $t->class === TILE_CHEST){
|
||||
for($s = 0; $s < CHEST_SLOTS; ++$s){
|
||||
$slot = $t->getSlot($s);
|
||||
if($slot->getID() > AIR and $slot->count > 0){
|
||||
$drops[] = array($slot->getID(), $slot->getMetadata(), $slot->count);
|
||||
$drops[] = [$slot->getID(), $slot->getMetadata(), $slot->count];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@
|
|||
class CobwebBlock extends FlowableBlock{
|
||||
public static $blockID;
|
||||
public function __construct(){
|
||||
parent::__construct(COBWEB, 0, "Cobweb");
|
||||
parent::__construct(COBWEB, 0, "Cobweb");
|
||||
$this->isSolid = true;
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 25;
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if ($item->isSword()){
|
||||
return [
|
||||
|
|
@ -21,11 +21,11 @@ class CobwebBlock extends FlowableBlock{
|
|||
}
|
||||
elseif ($item->isShears()){
|
||||
return [
|
||||
array(COBWEB, 0, 1),
|
||||
[COBWEB, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function onEntityCollidedWithBlock(Level $level, $x, $y, $z, Entity $entity){
|
||||
$entity->setInWeb();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,27 +7,27 @@ class FarmlandBlock extends TransparentBlock{
|
|||
$this->hardness = 3;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(DIRT, 0, 1),
|
||||
);
|
||||
return [
|
||||
[DIRT, 0, 1],
|
||||
];
|
||||
}
|
||||
public function hasCrops(){
|
||||
//TODO vanilla 0.8.1 detection method
|
||||
$b = $this->getSide(1);
|
||||
return $b->isTransparent && $b->id != 0;
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [new AxisAlignedBB($x, $y, $z, $x + 1, $y + 1, $z + 1)];
|
||||
}
|
||||
|
||||
|
||||
public static function fallOn(Level $level, $x, $y, $z, Entity $entity, $fallDistance){
|
||||
$rv = lcg_value();
|
||||
if($rv < ($fallDistance - 0.5)){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, DIRT, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function onRandomTick(Level $level, $x, $y, $z){
|
||||
$meta = $level->level->getBlockDamage($x, $y, $z);
|
||||
$b = $level->level->getBlockID($x, $y + 1, $z);
|
||||
|
|
@ -41,8 +41,7 @@ class FarmlandBlock extends TransparentBlock{
|
|||
$level->fastSetBlockUpdate($x, $y, $z, DIRT, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static function checkWaterStatic(Level $level, $x, $y, $z)
|
||||
|
|
@ -58,7 +57,7 @@ class FarmlandBlock extends TransparentBlock{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
if(!StaticBlock::getIsTransparent($level->level->getBlockID($x, $y + 1, $z))){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, DIRT, 0, true);
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@ class FenceBlock extends TransparentBlock{
|
|||
$this->isFullBlock = false;
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
|
||||
public static function canConnectTo(Level $level, $x, $y, $z){
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
|
||||
|
||||
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 true;
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
$v9 = self::canConnectTo($level, $x, $y, $z - 1);
|
||||
$v10 = self::canConnectTo($level, $x, $y, $z + 1);
|
||||
|
|
@ -29,7 +29,7 @@ class FenceBlock extends TransparentBlock{
|
|||
StaticBlock::setBlockBounds(static::$blockID, $minX, 0, $minZ, $maxX, 1.5, $maxZ);
|
||||
return parent::getAABB($level, $x, $y, $z);
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
$v8 = self::canConnectTo($level, $x, $y, $z - 1);
|
||||
$v9 = self::canConnectTo($level, $x, $y, $z + 1);
|
||||
|
|
@ -47,11 +47,11 @@ class FenceBlock extends TransparentBlock{
|
|||
$v15 = 0.625;
|
||||
if($v10) $v12 = 0;
|
||||
if($v11) $v13 = 1;
|
||||
|
||||
|
||||
if($v10 || $v11 || !$v8 && !$v9){
|
||||
$arr[] = new AxisAlignedBB($x + $v12, $y + 0, $z + $v14, $x + $v13, $y + 1.5, $z + $v15);
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -7,21 +7,21 @@ class FenceGateBlock extends TransparentBlock{
|
|||
if($aabb == null) return [];
|
||||
return [$aabb];
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
$data = $level->level->getBlockDamage($x, $y, $z);
|
||||
|
||||
|
||||
if($data & 4){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if($data != 2 && $data != 0){
|
||||
return new AxisAlignedBB($x + 0.375, $y, $z, $x + 0.625, $y + 1.5, $z + 1.0);
|
||||
}else{
|
||||
return new AxisAlignedBB($x, $y, $z + 0.375, $x + 1, $y + 1.5, $z + 0.625);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(FENCE_GATE, $meta, "Fence Gate");
|
||||
$this->isActivable = true;
|
||||
|
|
@ -33,29 +33,29 @@ class FenceGateBlock extends TransparentBlock{
|
|||
$this->hardness = 15;
|
||||
}
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$faces = array(
|
||||
$faces = [
|
||||
0 => 3,
|
||||
1 => 0,
|
||||
2 => 1,
|
||||
3 => 2,
|
||||
);
|
||||
];
|
||||
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
return true;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
public function onActivate(Item $item, Player $player){
|
||||
|
||||
|
||||
$meta = $this->meta;
|
||||
if(($meta & 4) != 0){
|
||||
$meta ^= 4;
|
||||
}else{
|
||||
$direction = ($player->entity->yaw * 4 / 360) + 0.5;
|
||||
$blockDirection = (int)$direction;
|
||||
$blockDirection = (int) $direction;
|
||||
if($direction < $blockDirection) --$blockDirection;
|
||||
$blockDirection &= 3;
|
||||
if(($meta & 3) == (($blockDirection + 2) & 3)){
|
||||
|
|
@ -63,7 +63,7 @@ class FenceGateBlock extends TransparentBlock{
|
|||
}
|
||||
$meta |= 4;
|
||||
}
|
||||
|
||||
|
||||
$this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, $this->id, $meta);
|
||||
$players = $this->level->players;
|
||||
unset($players[$player->CID]);
|
||||
|
|
|
|||
|
|
@ -9,33 +9,33 @@ class GlassPaneBlock extends TransparentBlock{
|
|||
}
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
|
||||
|
||||
$minX = 0.4375;
|
||||
$maxX = 0.5625;
|
||||
$minZ = 0.4375;
|
||||
$maxZ = 0.5625;
|
||||
|
||||
|
||||
$var9 = self::canConnectTo($level->level->getBlockID($x, $y, $z - 1));
|
||||
$var10 = self::canConnectTo($level->level->getBlockID($x, $y, $z + 1));
|
||||
$var11 = self::canConnectTo($level->level->getBlockID($x - 1, $y, $z));
|
||||
$var12 = self::canConnectTo($level->level->getBlockID($x + 1, $y, $z));
|
||||
|
||||
|
||||
if((!$var11 || !$var12) && ($var11 || $var12 || $var9 || $var10)){
|
||||
if($var11 && !$var12) $minX = 0;
|
||||
else if(!$var11 && $var12) $maxX = 1;
|
||||
elseif(!$var11 && $var12) $maxX = 1;
|
||||
}else{
|
||||
$minX = 0;
|
||||
$maxX = 1;
|
||||
}
|
||||
|
||||
|
||||
if((!$var9 || !$var10) && ($var11 || $var12 || $var9 || $var10)){
|
||||
if($var9 && !$var10) $minZ = 0;
|
||||
else if(!$var9 && $var10) $maxZ = 1;
|
||||
elseif(!$var9 && $var10) $maxZ = 1;
|
||||
}else{
|
||||
$minZ = 0;
|
||||
$maxZ = 1;
|
||||
}
|
||||
|
||||
|
||||
StaticBlock::setBlockBounds($id, $minX, 0, $minZ, $maxX, 1, $maxZ);
|
||||
}
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
|
|
@ -51,7 +51,7 @@ class GlassPaneBlock extends TransparentBlock{
|
|||
}else{
|
||||
$arr[] = $aabb->addMinMax(0, 0, 0.4375, 1, 1, 0.5625);
|
||||
}
|
||||
|
||||
|
||||
if((!$var8 || !$var9) && ($var10 || $var11 || $var8 || $var9)){
|
||||
if($var8 && !$var9) $arr[] = $aabb->addMinMax(0.4375, 0, 0, 0.5625, 1, 0.5);
|
||||
elseif(!$var8 && $var9) $arr[] = $aabb->addMinMax(0.4375, 0, 0.5, 0.5625, 1, 1);
|
||||
|
|
@ -60,14 +60,14 @@ class GlassPaneBlock extends TransparentBlock{
|
|||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
public static function canConnectTo($blockID) : bool{
|
||||
return StaticBlock::getIsSolid($blockID) || $blockID == GLASS_PANE || $blockID == GLASS;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(GLASS_PANE, 0, 0),
|
||||
);
|
||||
return [
|
||||
[GLASS_PANE, 0, 0],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -7,39 +7,39 @@ class IronBarsBlock extends TransparentBlock{
|
|||
$this->isFullBlock = false;
|
||||
$this->isSolid = false;
|
||||
}
|
||||
|
||||
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
|
||||
|
||||
$minX = 0.4375;
|
||||
$maxX = 0.5625;
|
||||
$minZ = 0.4375;
|
||||
$maxZ = 0.5625;
|
||||
|
||||
|
||||
$var9 = self::canConnectTo($level->level->getBlockID($x, $y, $z - 1));
|
||||
$var10 = self::canConnectTo($level->level->getBlockID($x, $y, $z + 1));
|
||||
$var11 = self::canConnectTo($level->level->getBlockID($x - 1, $y, $z));
|
||||
$var12 = self::canConnectTo($level->level->getBlockID($x + 1, $y, $z));
|
||||
|
||||
|
||||
if((!$var11 || !$var12) && ($var11 || $var12 || $var9 || $var10)){
|
||||
if($var11 && !$var12) $minX = 0;
|
||||
else if(!$var11 && $var12) $maxX = 1;
|
||||
elseif(!$var11 && $var12) $maxX = 1;
|
||||
}else{
|
||||
$minX = 0;
|
||||
$maxX = 1;
|
||||
}
|
||||
|
||||
|
||||
if((!$var9 || !$var10) && ($var11 || $var12 || $var9 || $var10)){
|
||||
if($var9 && !$var10) $minZ = 0;
|
||||
else if(!$var9 && $var10) $maxZ = 1;
|
||||
elseif(!$var9 && $var10) $maxZ = 1;
|
||||
}else{
|
||||
$minZ = 0;
|
||||
$maxZ = 1;
|
||||
}
|
||||
|
||||
|
||||
StaticBlock::setBlockBounds($id, $minX, 0, $minZ, $maxX, 1, $maxZ);
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
$var8 = self::canConnectTo($level->level->getBlockID($x, $y, $z - 1));
|
||||
$var9 = self::canConnectTo($level->level->getBlockID($x, $y, $z + 1));
|
||||
|
|
@ -53,7 +53,7 @@ class IronBarsBlock extends TransparentBlock{
|
|||
}else{
|
||||
$arr[] = $aabb->addMinMax(0, 0, 0.4375, 1, 1, 0.5625);
|
||||
}
|
||||
|
||||
|
||||
if((!$var8 || !$var9) && ($var10 || $var11 || $var8 || $var9)){
|
||||
if($var8 && !$var9) $arr[] = $aabb->addMinMax(0.4375, 0, 0, 0.5625, 1, 0.5);
|
||||
elseif(!$var8 && $var9) $arr[] = $aabb->addMinMax(0.4375, 0, 0.5, 0.5625, 1, 1);
|
||||
|
|
@ -62,9 +62,9 @@ class IronBarsBlock extends TransparentBlock{
|
|||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
public static function canConnectTo($blockID) : bool{
|
||||
return StaticBlock::getIsSolid($blockID) || $blockID == IRON_BARS || $blockID == GLASS;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -21,14 +21,14 @@ class IronDoorBlock extends DoorBlock{
|
|||
default => 25,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return array(
|
||||
array(IRON_DOOR, 0, 1),
|
||||
);
|
||||
return [
|
||||
[IRON_DOOR, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
<?php
|
||||
|
||||
require_once("RailBaseBlock.php");
|
||||
class PoweredRailBlock extends RailBaseBlock{
|
||||
public static $blockID;
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(POWERED_RAIL, 0, "PoweredRailBlock");
|
||||
$this->hardness = 0.7;
|
||||
$this->isFullBlock = false;
|
||||
$this->isFullBlock = false;
|
||||
$this->isSolid = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,24 +2,24 @@
|
|||
|
||||
abstract class RailBaseBlock extends FlowableBlock //TODO move some methods here
|
||||
{
|
||||
|
||||
|
||||
public static function isRailBlock(Level $l, $x, $y, $z){
|
||||
$id = $l->level->getBlockID($x, $y, $z);
|
||||
return $id === POWERED_RAIL || $id === RAIL;
|
||||
}
|
||||
|
||||
|
||||
public static function isRailID($id){
|
||||
return $id == POWERED_RAIL || $id == RAIL;
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() !== AIR and $down instanceof SolidBlock){
|
||||
|
||||
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
$logic = new RailLogic($this);
|
||||
$logic->place(false, true);
|
||||
|
|
@ -27,16 +27,16 @@ abstract class RailBaseBlock extends FlowableBlock //TODO move some methods here
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function updateState(){}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
if($id === POWERED_RAIL){
|
||||
$meta &= 7;
|
||||
}
|
||||
if(
|
||||
($level->level->getBlockID($x, $y - 1, $z) === 0) ||
|
||||
($level->level->getBlockID($x, $y - 1, $z) === 0) ||
|
||||
(($meta == 2) && $level->level->getBlockID($x + 1, $y, $z) === 0) ||
|
||||
(($meta == 3) && $level->level->getBlockID($x - 1, $y, $z) === 0) ||
|
||||
(($meta == 4) && $level->level->getBlockID($x, $y, $z - 1) === 0) ||
|
||||
|
|
@ -45,7 +45,7 @@ abstract class RailBaseBlock extends FlowableBlock //TODO move some methods here
|
|||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
ServerAPI::request()->api->entity->drop(new Position($x, $y, $z, $level), BlockAPI::getItem($id, $meta, 1));
|
||||
}else{
|
||||
//TODO fix me pls $this->updateState();
|
||||
//TODO fix me pls $this->updateState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,20 @@
|
|||
<?php
|
||||
|
||||
require_once("RailBaseBlock.php");
|
||||
class RailBlock extends RailBaseBlock{
|
||||
public static $blockID;
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(RAIL, $meta, "Rail");
|
||||
$this->hardness = 0.7;
|
||||
$this->isFullBlock = false;
|
||||
$this->isFullBlock = false;
|
||||
$this->isSolid = false;
|
||||
}
|
||||
|
||||
|
||||
public function updateState(){
|
||||
$logic = (new RailLogic($this));
|
||||
if($logic->countPotentialConnections() == 3){
|
||||
$logic->place(false, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -12,19 +12,19 @@ class SlabBlock extends TransparentBlock{
|
|||
6 => "Quartz",
|
||||
7 => "",
|
||||
];
|
||||
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(SLAB, $meta, "Slab");
|
||||
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . self::$NAMES[$this->meta & 0x07] . " Slab";
|
||||
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . self::$NAMES[$this->meta & 0x07] . " Slab";
|
||||
if(($this->meta & 0x08) === 0x08){
|
||||
$this->isFullBlock = true;
|
||||
}else{
|
||||
$this->isFullBlock = false;
|
||||
}
|
||||
}
|
||||
$this->hardness = 30;
|
||||
}
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
|
||||
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
|
||||
if($meta & 0x08 == 0x08){
|
||||
|
|
@ -35,11 +35,11 @@ class SlabBlock extends TransparentBlock{
|
|||
else StaticBlock::setBlockBounds($id, 0, 0.5, 0, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
self::updateShape($level, $x, $y, $z);
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
|
||||
|
||||
return [
|
||||
new AxisAlignedBB(
|
||||
$x + StaticBlock::$minXs[$id], $y + StaticBlock::$minYs[$id], $z + StaticBlock::$minZs[$id],
|
||||
|
|
@ -47,7 +47,7 @@ class SlabBlock extends TransparentBlock{
|
|||
)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$this->meta &= 0x07;
|
||||
if($face === 0){
|
||||
|
|
@ -103,14 +103,14 @@ class SlabBlock extends TransparentBlock{
|
|||
default => 10,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return array(
|
||||
array($this->id, $this->meta & 0x07, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, $this->meta & 0x07, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,20 +20,20 @@ class SnowLayerBlock extends FlowableBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
if($level->level->getBlockID($x, $y - 1, $z) == AIR){ //Replace with common break method
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->isShovel() !== false){
|
||||
return array(
|
||||
array(SNOWBALL, 0, 1),
|
||||
);
|
||||
return [
|
||||
[SNOWBALL, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
return array();
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
@ -15,45 +15,45 @@ class StoneWallBlock extends TransparentBlock{
|
|||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
public static function connectsTo(Level $level, $x, $y, $z){
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
|
||||
|
||||
if($id == STONE_WALL || $id == FENCE_GATE) return true;
|
||||
if($id == 0) return false;
|
||||
|
||||
|
||||
if(StaticBlock::getIsSolid($id) && !StaticBlock::getIsTransparent($id)){ //XXX in vanilla it uses Material->isSolidBlocking() and Tile->isCubeShaped()
|
||||
return true; //XXX in vanilla it returns v7->material != Material::vegetable;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [static::getAABB($level, $x, $y, $z)];
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
static::updateShape($level, $x, $y, $z);
|
||||
StaticBlock::$maxYs[$level->level->getBlockID($x, $y, $z)] = 1.5;
|
||||
return parent::getAABB($level, $x, $y, $z);
|
||||
}
|
||||
|
||||
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
$zNeg = self::connectsTo($level, $x, $y, $z - 1);
|
||||
$zPos = self::connectsTo($level, $x, $y, $z + 1);
|
||||
$xNeg = self::connectsTo($level, $x - 1, $y, $z);
|
||||
$xPos = self::connectsTo($level, $x + 1, $y, $z);
|
||||
|
||||
|
||||
$minX = 0.25;
|
||||
$maxY = 1.0;
|
||||
$maxX = 0.75;
|
||||
|
||||
|
||||
$minZ = $zNeg ? 0 : 0.25;
|
||||
$maxZ = $zPos ? 1.0 : 0.75;
|
||||
|
||||
|
||||
if($xNeg) $minX = 0;
|
||||
if($xPos) $maxX = 1.0;
|
||||
|
||||
|
||||
if($zNeg){
|
||||
if($zPos && !$xNeg){
|
||||
if(!$xPos){
|
||||
|
|
@ -62,7 +62,7 @@ class StoneWallBlock extends TransparentBlock{
|
|||
$minX = 0.3125;
|
||||
}
|
||||
}
|
||||
}else if(!$zPos && $zNeg){
|
||||
}elseif(!$zPos && $zNeg){
|
||||
if($xPos){
|
||||
$maxY = 0.8125;
|
||||
$maxZ = 0.6875;
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ class WoodDoorBlock extends DoorBlock{
|
|||
$this->isActivable = true;
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(WOODEN_DOOR, 0, 1),
|
||||
);
|
||||
return [
|
||||
[WOODEN_DOOR, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,29 @@
|
|||
<?php
|
||||
|
||||
//TODO make it extend SlabBlock
|
||||
class WoodSlabBlock extends TransparentBlock{
|
||||
public static $blockID;
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(WOOD_SLAB, $meta, "Wooden Slab");
|
||||
$names = array(
|
||||
$names = [
|
||||
0 => "Oak",
|
||||
1 => "Spruce",
|
||||
2 => "Birch",
|
||||
3 => "Jungle",
|
||||
);
|
||||
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Wooden Slab";
|
||||
];
|
||||
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Wooden Slab";
|
||||
if(($this->meta & 0x08) === 0x08){
|
||||
$this->isFullBlock = true;
|
||||
}else{
|
||||
$this->isFullBlock = false;
|
||||
}
|
||||
}
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
|
||||
public static function updateShape(Level $level, $x, $y, $z){
|
||||
|
||||
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
|
||||
|
||||
if($meta & 0x08 == 0x08){
|
||||
StaticBlock::setBlockBounds($id, 0, 0, 0, 1, 1, 1);
|
||||
}else{
|
||||
|
|
@ -31,11 +32,11 @@ class WoodSlabBlock extends TransparentBlock{
|
|||
else StaticBlock::setBlockBounds($id, 0, 0.5, 0, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
self::updateShape($level, $x, $y, $z);
|
||||
$id = $level->level->getBlockID($x, $y, $z);
|
||||
|
||||
|
||||
return [
|
||||
new AxisAlignedBB(
|
||||
$x + StaticBlock::$minXs[$id], $y + StaticBlock::$minYs[$id], $z + StaticBlock::$minZs[$id],
|
||||
|
|
@ -43,7 +44,7 @@ class WoodSlabBlock extends TransparentBlock{
|
|||
)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$this->meta &= 0x07;
|
||||
if($face === 0){
|
||||
|
|
@ -99,10 +100,10 @@ class WoodSlabBlock extends TransparentBlock{
|
|||
default => 3,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, $this->meta & 0x07, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, $this->meta & 0x07, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ class BirchWoodStairsBlock extends StairBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -5,5 +5,5 @@ class BrickStairsBlock extends StairBlock{
|
|||
public function __construct($meta = 0){
|
||||
parent::__construct(BRICK_STAIRS, $meta, "Brick Stairs");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -5,5 +5,5 @@ class CobblestoneStairsBlock extends StairBlock{
|
|||
public function __construct($meta = 0){
|
||||
parent::__construct(COBBLESTONE_STAIRS, $meta, "Cobblestone Stairs");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -7,8 +7,8 @@ class JungleWoodStairsBlock extends StairBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -5,5 +5,5 @@ class NetherBricksStairsBlock extends StairBlock{
|
|||
public function __construct($meta = 0){
|
||||
parent::__construct(NETHER_BRICKS_STAIRS, $meta, "Nether Bricks Stairs");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -5,5 +5,5 @@ class QuartzStairsBlock extends StairBlock{
|
|||
public function __construct($meta = 0){
|
||||
parent::__construct(QUARTZ_STAIRS, $meta, "Quartz Stairs");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -5,5 +5,5 @@ class SandstoneStairsBlock extends StairBlock{
|
|||
public function __construct($meta = 0){
|
||||
parent::__construct(SANDSTONE_STAIRS, $meta, "Sandstone Stairs");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -7,8 +7,8 @@ class SpruceWoodStairsBlock extends StairBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -5,5 +5,5 @@ class StoneBrickStairsBlock extends StairBlock{
|
|||
public function __construct($meta = 0){
|
||||
parent::__construct(STONE_BRICK_STAIRS, $meta, "Stone Brick Stairs");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -21,8 +21,8 @@ class WoodStairsBlock extends StairBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class CoalOreBlock extends SolidBlock{
|
|||
parent::__construct(COAL_ORE, 0, "Coal Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
if(($player->gamemode & 0x01) === 0x01){
|
||||
return 0.20;
|
||||
|
|
@ -20,15 +20,15 @@ class CoalOreBlock extends SolidBlock{
|
|||
default => 15,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return array(
|
||||
array(COAL, 0, 1),
|
||||
);
|
||||
return [
|
||||
[COAL, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class DiamondOreBlock extends SolidBlock{
|
|||
parent::__construct(DIAMOND_ORE, 0, "Diamond Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
if(($player->gamemode & 0x01) === 0x01){
|
||||
return 0.20;
|
||||
|
|
@ -17,14 +17,14 @@ class DiamondOreBlock extends SolidBlock{
|
|||
default => 15,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 4){
|
||||
return array(
|
||||
array(DIAMOND, 0, 1),
|
||||
);
|
||||
return [
|
||||
[DIAMOND, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ class GlowingRedstoneOreBlock extends SolidBlock implements LightingBlock{
|
|||
parent::__construct(GLOWING_REDSTONE_ORE, 0, "Glowing Redstone Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
|
||||
public static function onRandomTick(Level $level, $x, $y, $z){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, REDSTONE_ORE, 0);
|
||||
}
|
||||
|
||||
|
||||
public function getMaxLightValue(){
|
||||
return 9;
|
||||
}
|
||||
|
|
@ -25,15 +25,15 @@ class GlowingRedstoneOreBlock extends SolidBlock implements LightingBlock{
|
|||
default => 15,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 4){
|
||||
return array(
|
||||
array(REDSTONE_DUST, 0, mt_rand(4, 5)),
|
||||
);
|
||||
return [
|
||||
[REDSTONE_DUST, 0, mt_rand(4, 5)],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@ class GoldOreBlock extends SolidBlock{
|
|||
default => 15,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 4){
|
||||
return array(
|
||||
array(GOLD_ORE, 0, 1),
|
||||
);
|
||||
return [
|
||||
[GOLD_ORE, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ class IronOreBlock extends SolidBlock{
|
|||
default => 15,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= ItemTool::STONE_LEVEL){
|
||||
return array(
|
||||
array(IRON_ORE, 0, 1),
|
||||
);
|
||||
return [
|
||||
[IRON_ORE, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class LapisOreBlock extends SolidBlock{
|
|||
parent::__construct(LAPIS_ORE, 0, "Lapis Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
if(($player->gamemode & 0x01) === 0x01){
|
||||
return 0.20;
|
||||
|
|
@ -21,12 +21,12 @@ class LapisOreBlock extends SolidBlock{
|
|||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 3){
|
||||
return array(
|
||||
array(DYE, 4, mt_rand(4, 8)),
|
||||
);
|
||||
return [
|
||||
[DYE, 4, mt_rand(4, 8)],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,18 +6,18 @@ class RedstoneOreBlock extends SolidBlock{
|
|||
parent::__construct(REDSTONE_ORE, 0, "Redstone Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
|
||||
public static function interact(Level $level, $x, $y, $z, Player $player){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, GLOWING_REDSTONE_ORE, 0);
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 4){
|
||||
return array(
|
||||
array(REDSTONE_DUST, 0, mt_rand(4, 5)),
|
||||
);
|
||||
return [
|
||||
[REDSTONE_DUST, 0, mt_rand(4, 5)],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ class BeetrootBlock extends FlowableBlock{
|
|||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
$drops = [];
|
||||
if($this->meta >= 0x07){
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ class BrownMushroomBlock extends FlowableBlock{
|
|||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
if(StaticBlock::getIsTransparent($level->level->getBlockID($x, $y - 1, $z))){ //Replace with common break method
|
||||
ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(BROWN_MUSHROOM));
|
||||
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(BROWN_MUSHROOM));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$down = $this->getSide(0);
|
||||
if($down->isTransparent === false){
|
||||
|
|
@ -21,5 +21,5 @@ class BrownMushroomBlock extends FlowableBlock{
|
|||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,14 +7,14 @@ class CactusBlock extends TransparentBlock{
|
|||
$this->isFullBlock = false;
|
||||
$this->hardness = 2;
|
||||
}
|
||||
|
||||
|
||||
public static function onEntityCollidedWithBlock(Level $level, $x, $y, $z, Entity $entity){
|
||||
$entity->harm(1, "cactus");
|
||||
}
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [new AxisAlignedBB($x + 0.0625, $y, $z + 0.0625, $x + 1 - 0.0625, $y + 1 - 0.0625, $z + 1 - 0.0625)];
|
||||
}
|
||||
|
||||
|
||||
public static function onRandomTick(Level $level, $x, $y, $z){
|
||||
//$b = $level->level->getBlock($x, $y - 1, $z);
|
||||
$underID = $level->level->getBlockID($x, $y - 1, $z);
|
||||
|
|
@ -38,7 +38,7 @@ class CactusBlock extends TransparentBlock{
|
|||
return BLOCK_UPDATE_RANDOM;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
$down = $level->level->getBlockID($x, $y - 1, $z);
|
||||
$b0 = $level->level->getBlockID($x, $y, $z - 1);
|
||||
|
|
@ -50,7 +50,7 @@ class CactusBlock extends TransparentBlock{
|
|||
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(CACTUS));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() === SAND or $down->getID() === CACTUS){
|
||||
|
|
@ -67,10 +67,10 @@ class CactusBlock extends TransparentBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ class CarrotBlock extends FlowableBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
|
||||
$this->meta += mt_rand(0, 3) + 2;
|
||||
|
|
@ -48,7 +48,7 @@ class CarrotBlock extends FlowableBlock{
|
|||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
$drops = [];
|
||||
if($this->meta >= 0x07){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class CyanFlowerBlock extends FlowableBlock{
|
|||
$this->isActivable = true;
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
return null;
|
||||
}
|
||||
|
|
@ -21,17 +21,14 @@ class CyanFlowerBlock extends FlowableBlock{
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
$downId = $level->level->getBlockID($x, $y - 1, $z);
|
||||
if(StaticBlock::getIsTransparent($downId) and $downId !== FARMLAND){ //Replace with common break method
|
||||
ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(CYAN_FLOWER));
|
||||
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(CYAN_FLOWER));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($item->getID() === DYE and $item->getMetadata() === 0x0F){
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class DandelionBlock extends FlowableBlock{
|
|||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
$downId = $level->level->getBlockID($x, $y - 1, $z);
|
||||
if(StaticBlock::getIsTransparent($downId) and $downId !== FARMLAND){ //Replace with common break method
|
||||
ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(CYAN_FLOWER));
|
||||
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(CYAN_FLOWER));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,33 +7,33 @@ class DeadBushBlock extends FlowableBlock{
|
|||
//$this->isReplaceable = true;
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
if(StaticBlock::getIsTransparent($level->level->getBlockID($x, $y - 1, $z))){ //Replace with common break method
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() == 12){
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->isShears()){
|
||||
return [
|
||||
[DEAD_BUSH, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ class MelonStemBlock extends FlowableBlock{
|
|||
//$this->level->setBlock($this, $this, true, false, true);
|
||||
$level->fastSetBlockUpdate($x, $y, $z, $block[0], $block[1] + 1);
|
||||
}else{
|
||||
|
||||
|
||||
$position = new AirBlock(); //feke block
|
||||
$position->x = $x;
|
||||
$position->y = $y;
|
||||
|
|
@ -46,11 +46,11 @@ class MelonStemBlock extends FlowableBlock{
|
|||
}
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
if($level->level->getBlockID($x, $y - 1, $z) != FARMLAND){
|
||||
ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(MELON_SEEDS, 0, mt_rand(0, 2)));
|
||||
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(MELON_SEEDS, 0, mt_rand(0, 2)));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
|
||||
$this->meta += mt_rand(0, 3) + 2;
|
||||
|
|
@ -65,7 +65,7 @@ class MelonStemBlock extends FlowableBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
$drops = [];
|
||||
if($this->meta >= 0x07){
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class PotatoBlock extends FlowableBlock{
|
|||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
$drops = [];
|
||||
if($this->meta >= 0x07){
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class PumpkinStemBlock extends FlowableBlock{
|
|||
//$this->level->setBlock($this, $this, true, false, true);
|
||||
$level->fastSetBlockUpdate($x, $y, $z, $block[0], $block[1] + 1);
|
||||
}else{
|
||||
|
||||
|
||||
$position = new AirBlock(); //feke block
|
||||
$position->x = $x;
|
||||
$position->y = $y;
|
||||
|
|
@ -46,11 +46,11 @@ class PumpkinStemBlock extends FlowableBlock{
|
|||
}
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
if($level->level->getBlockID($x, $y - 1, $z) != FARMLAND){
|
||||
ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(PUMPKIN_SEEDS, 0, mt_rand(0, 2)));
|
||||
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(PUMPKIN_SEEDS, 0, mt_rand(0, 2)));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
|
||||
$this->meta += mt_rand(0, 3) + 2;
|
||||
|
|
@ -65,7 +65,7 @@ class PumpkinStemBlock extends FlowableBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
$drops = [];
|
||||
if($this->meta >= 0x07){
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class RedMushroomBlock extends FlowableBlock{
|
|||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
if(StaticBlock::getIsTransparent($level->level->getBlockID($x, $y - 1, $z))){ //Replace with common break method
|
||||
ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(RED_MUSHROOM));
|
||||
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(RED_MUSHROOM));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -21,5 +21,5 @@ class RedMushroomBlock extends FlowableBlock{
|
|||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,16 +7,16 @@ class SaplingBlock extends FlowableBlock{
|
|||
const BIRCH = 2;
|
||||
const JUNGLE = 3;
|
||||
const BURN_TIME = 5;
|
||||
|
||||
|
||||
public function __construct($meta = SaplingBlock::OAK){
|
||||
parent::__construct(SAPLING, $meta, "Sapling");
|
||||
$this->isActivable = true;
|
||||
$names = array(
|
||||
$names = [
|
||||
0 => "Oak Sapling",
|
||||
1 => "Spruce Sapling",
|
||||
2 => "Birch Sapling",
|
||||
3 => "Jungle Sapling",
|
||||
);
|
||||
];
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ class SaplingBlock extends FlowableBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
|
||||
TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x03);
|
||||
|
|
@ -47,7 +47,7 @@ class SaplingBlock extends FlowableBlock{
|
|||
$downID = $level->level->getBlockID($x, $y - 1, $z);
|
||||
if(StaticBlock::getIsTransparent($downID) && $downID !== FARMLAND){ //Replace with common break method
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem($id, $meta));
|
||||
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem($id, $meta));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -64,8 +64,8 @@ class SaplingBlock extends FlowableBlock{
|
|||
}
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, $this->meta & 0x03, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, $this->meta & 0x03, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class SugarcaneBlock extends FlowableBlock{
|
|||
$this->isActivable = true;
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return [
|
||||
[SUGARCANE, 0, 1],
|
||||
|
|
@ -28,7 +28,7 @@ class SugarcaneBlock extends FlowableBlock{
|
|||
$this->meta = 0;
|
||||
$this->level->fastSetBlockUpdateMeta($this->x, $this->y, $this->z, $this->meta, true);
|
||||
}
|
||||
|
||||
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$player->removeItem(DYE,0x0F,1);
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ class SugarcaneBlock extends FlowableBlock{
|
|||
}
|
||||
}
|
||||
if(StaticBlock::getIsTransparent($down) && $down != SUGARCANE_BLOCK){ //Replace with common break method
|
||||
ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(SUGARCANE));
|
||||
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(SUGARCANE));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
}
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ class SugarcaneBlock extends FlowableBlock{
|
|||
$x = $this->x;
|
||||
$y = $this->y;
|
||||
$z = $this->z;
|
||||
|
||||
|
||||
$b0 = $level->level->getBlockID($x, $y - 1, $z - 1);
|
||||
$b1 = $level->level->getBlockID($x, $y - 1, $z + 1);
|
||||
$b2 = $level->level->getBlockID($x - 1, $y - 1, $z);
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ class TallGrassBlock extends FlowableBlock{
|
|||
public function __construct($meta = 1){
|
||||
parent::__construct(TALL_GRASS, $meta, "Tall Grass");
|
||||
$this->isReplaceable = true;
|
||||
$names = array(
|
||||
$names = [
|
||||
0 => "Dead Shrub",
|
||||
1 => "Tall Grass",
|
||||
2 => "Fern",
|
||||
);
|
||||
];
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
|
@ -17,28 +17,28 @@ class TallGrassBlock extends FlowableBlock{
|
|||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
$downID = $level->level->getBlockID($x, $y - 1, $z);
|
||||
if(StaticBlock::getIsTransparent($downID) && $downID !== FARMLAND){ //Replace with common break method
|
||||
if(Utils::chance(15)) ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(WHEAT_SEEDS));
|
||||
if(Utils::chance(15)) ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(WHEAT_SEEDS));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
$drops = array();
|
||||
if($item->isShears()) $drops[] = array($this->id, $this->meta & 0x03, 1);
|
||||
elseif(Utils::chance(15)) $drops[] = array(WHEAT_SEEDS, 0, 1);
|
||||
$drops = [];
|
||||
if($item->isShears()) $drops[] = [$this->id, $this->meta & 0x03, 1];
|
||||
elseif(Utils::chance(15)) $drops[] = [WHEAT_SEEDS, 0, 1];
|
||||
return $drops;
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() == GRASS or $down->getID() == DIRT || $down->getID() == FARMLAND){
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class WheatBlock extends FlowableBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
|
||||
$this->meta += mt_rand(0, 3) + 2;
|
||||
|
|
@ -48,7 +48,7 @@ class WheatBlock extends FlowableBlock{
|
|||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
$drops = [];
|
||||
if($this->meta >= 0x07){
|
||||
|
|
@ -59,7 +59,7 @@ class WheatBlock extends FlowableBlock{
|
|||
$drops[] = [WHEAT_SEEDS, 0, 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $drops;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,12 +7,12 @@ class BedrockBlock extends SolidBlock{
|
|||
$this->breakable = false;
|
||||
$this->hardness = 18000000;
|
||||
}
|
||||
|
||||
|
||||
public function isBreakable(Item $item, Player $player){
|
||||
if(($player->gamemode & 0x01) === 0x01){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -6,5 +6,5 @@ class BookshelfBlock extends SolidBlock{
|
|||
parent::__construct(BOOKSHELF, 0, "Bookshelf");
|
||||
$this->hardness = 7.5;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -20,14 +20,14 @@ class BricksBlock extends SolidBlock{
|
|||
default => 10,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return array(
|
||||
array(BRICKS_BLOCK, 0, 1),
|
||||
);
|
||||
return [
|
||||
[BRICKS_BLOCK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ class BurningFurnaceBlock extends SolidBlock implements LightingBlock{
|
|||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$faces = array(
|
||||
$faces = [
|
||||
0 => 4,
|
||||
1 => 2,
|
||||
2 => 5,
|
||||
3 => 3,
|
||||
);
|
||||
];
|
||||
$this->meta = $faces[$player->entity->getDirection()];
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
return true;
|
||||
|
|
@ -35,23 +35,23 @@ class BurningFurnaceBlock extends SolidBlock implements LightingBlock{
|
|||
if($t !== false){
|
||||
$furnace = $t;
|
||||
}else{
|
||||
$furnace = $server->api->tile->add($this->level, TILE_FURNACE, $this->x, $this->y, $this->z, array(
|
||||
"Items" => array(),
|
||||
$furnace = $server->api->tile->add($this->level, TILE_FURNACE, $this->x, $this->y, $this->z, [
|
||||
"Items" => [],
|
||||
"id" => TILE_FURNACE,
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z
|
||||
));
|
||||
"z" => $this->z
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
if(($player->gamemode & 0x01) === 0x01){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
$furnace->openInventory($player);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
if(($player->gamemode & 0x01) === 0x01){
|
||||
return 0.20;
|
||||
|
|
@ -65,18 +65,18 @@ class BurningFurnaceBlock extends SolidBlock implements LightingBlock{
|
|||
default => 17.5,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
$drops = array();
|
||||
$drops = [];
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
$drops[] = array(FURNACE, 0, 1);
|
||||
$drops[] = [FURNACE, 0, 1];
|
||||
}
|
||||
$t = ServerAPI::request()->api->tile->get($this);
|
||||
if($t !== false and $t->class === TILE_FURNACE){
|
||||
for($s = 0; $s < FURNACE_SLOTS; ++$s){
|
||||
$slot = $t->getSlot($s);
|
||||
if($slot->getID() > AIR and $slot->count > 0){
|
||||
$drops[] = array($slot->getID(), $slot->getMetadata(), $slot->count);
|
||||
$drops[] = [$slot->getID(), $slot->getMetadata(), $slot->count];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ class ClayBlock extends SolidBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(CLAY, 0, 4),
|
||||
);
|
||||
return [
|
||||
[CLAY, 0, 4],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -20,14 +20,14 @@ class CoalBlock extends SolidBlock{
|
|||
default => 25,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return array(
|
||||
array(COAL_BLOCK, 0, 1),
|
||||
);
|
||||
return [
|
||||
[COAL_BLOCK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@ class CobblestoneBlock extends SolidBlock{
|
|||
default => 10,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return array(
|
||||
array(COBBLESTONE, 0, 1),
|
||||
);
|
||||
return [
|
||||
[COBBLESTONE, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class DiamondBlock extends SolidBlock{
|
|||
parent::__construct(DIAMOND_BLOCK, 0, "Diamond Block");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
if(($player->gamemode & 0x01) === 0x01){
|
||||
return 0.20;
|
||||
|
|
@ -17,14 +17,14 @@ class DiamondBlock extends SolidBlock{
|
|||
default => 25,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 4){
|
||||
return array(
|
||||
array(DIAMOND_BLOCK, 0, 1),
|
||||
);
|
||||
return [
|
||||
[DIAMOND_BLOCK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,33 +32,33 @@ class DirtBlock extends SolidBlock{
|
|||
}
|
||||
|
||||
public static function getGrassInRadius(Level $level, $x, $y, $z){ //umwut (although kinda faster than for loop =D)
|
||||
if($level->level->getBlockID($x+1, $y, $z+1) == 2) return true;
|
||||
if($level->level->getBlockID($x+1, $y, $z) == 2) return true;
|
||||
if($level->level->getBlockID($x+1, $y, $z-1) == 2) return true;
|
||||
if($level->level->getBlockID($x, $y, $z+1) == 2) return true;
|
||||
if($level->level->getBlockID($x, $y, $z-1) == 2) return true;
|
||||
if($level->level->getBlockID($x-1, $y, $z+1) == 2) return true;
|
||||
if($level->level->getBlockID($x-1, $y, $z) == 2) return true;
|
||||
if($level->level->getBlockID($x-1, $y, $z-1) == 2) return true;
|
||||
if($level->level->getBlockID($x + 1, $y, $z + 1) == 2) return true;
|
||||
if($level->level->getBlockID($x + 1, $y, $z) == 2) return true;
|
||||
if($level->level->getBlockID($x + 1, $y, $z - 1) == 2) return true;
|
||||
if($level->level->getBlockID($x, $y, $z + 1) == 2) return true;
|
||||
if($level->level->getBlockID($x, $y, $z - 1) == 2) return true;
|
||||
if($level->level->getBlockID($x - 1, $y, $z + 1) == 2) return true;
|
||||
if($level->level->getBlockID($x - 1, $y, $z) == 2) return true;
|
||||
if($level->level->getBlockID($x - 1, $y, $z - 1) == 2) return true;
|
||||
|
||||
if($level->level->getBlockID($x+1, $y-1, $z+1) == 2) return true;
|
||||
if($level->level->getBlockID($x+1, $y-1, $z) == 2) return true;
|
||||
if($level->level->getBlockID($x+1, $y-1, $z-1) == 2) return true;
|
||||
if($level->level->getBlockID($x, $y-1, $z+1) == 2) return true;
|
||||
if($level->level->getBlockID($x, $y-1, $z) == 2) return true;
|
||||
if($level->level->getBlockID($x, $y-1, $z-1) == 2) return true;
|
||||
if($level->level->getBlockID($x-1, $y-1, $z+1) == 2) return true;
|
||||
if($level->level->getBlockID($x-1, $y-1, $z) == 2) return true;
|
||||
if($level->level->getBlockID($x-1, $y-1, $z-1) == 2) return true;
|
||||
if($level->level->getBlockID($x + 1, $y - 1, $z + 1) == 2) return true;
|
||||
if($level->level->getBlockID($x + 1, $y - 1, $z) == 2) return true;
|
||||
if($level->level->getBlockID($x + 1, $y - 1, $z - 1) == 2) return true;
|
||||
if($level->level->getBlockID($x, $y - 1, $z + 1) == 2) return true;
|
||||
if($level->level->getBlockID($x, $y - 1, $z) == 2) return true;
|
||||
if($level->level->getBlockID($x, $y - 1, $z - 1) == 2) return true;
|
||||
if($level->level->getBlockID($x - 1, $y - 1, $z + 1) == 2) return true;
|
||||
if($level->level->getBlockID($x - 1, $y - 1, $z) == 2) return true;
|
||||
if($level->level->getBlockID($x - 1, $y - 1, $z - 1) == 2) return true;
|
||||
|
||||
if($level->level->getBlockID($x+1, $y+1, $z+1) == 2) return true;
|
||||
if($level->level->getBlockID($x+1, $y+1, $z) == 2) return true;
|
||||
if($level->level->getBlockID($x+1, $y+1, $z-1) == 2) return true;
|
||||
if($level->level->getBlockID($x, $y+1, $z+1) == 2) return true;
|
||||
if($level->level->getBlockID($x, $y+1, $z-1) == 2) return true;
|
||||
if($level->level->getBlockID($x-1, $y+1, $z+1) == 2) return true;
|
||||
if($level->level->getBlockID($x-1, $y+1, $z) == 2) return true;
|
||||
if($level->level->getBlockID($x-1, $y+1, $z-1) == 2) return true;
|
||||
if($level->level->getBlockID($x + 1, $y + 1, $z + 1) == 2) return true;
|
||||
if($level->level->getBlockID($x + 1, $y + 1, $z) == 2) return true;
|
||||
if($level->level->getBlockID($x + 1, $y + 1, $z - 1) == 2) return true;
|
||||
if($level->level->getBlockID($x, $y + 1, $z + 1) == 2) return true;
|
||||
if($level->level->getBlockID($x, $y + 1, $z - 1) == 2) return true;
|
||||
if($level->level->getBlockID($x - 1, $y + 1, $z + 1) == 2) return true;
|
||||
if($level->level->getBlockID($x - 1, $y + 1, $z) == 2) return true;
|
||||
if($level->level->getBlockID($x - 1, $y + 1, $z - 1) == 2) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class DoubleSlabBlock extends SolidBlock{
|
|||
public static $blockID;
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(DOUBLE_SLAB, $meta, "Double Slab");
|
||||
$names = array(
|
||||
$names = [
|
||||
0 => "Stone",
|
||||
1 => "Sandstone",
|
||||
2 => "Wooden",
|
||||
|
|
@ -13,7 +13,7 @@ class DoubleSlabBlock extends SolidBlock{
|
|||
5 => "Stone Brick",
|
||||
6 => "Quartz",
|
||||
7 => "Smooth Stone",
|
||||
);
|
||||
];
|
||||
$this->name = "Double " . $names[$this->meta & 0x07] . " Slab";
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
|
@ -31,15 +31,15 @@ class DoubleSlabBlock extends SolidBlock{
|
|||
default => 10,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return array(
|
||||
array(SLAB, $this->meta & 0x07, 2),
|
||||
);
|
||||
return [
|
||||
[SLAB, $this->meta & 0x07, 2],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ class DoubleWoodSlabBlock extends SolidBlock{
|
|||
public static $blockID;
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(DOUBLE_WOOD_SLAB, $meta, "Double Wooden Slab");
|
||||
$names = array(
|
||||
$names = [
|
||||
0 => "Oak",
|
||||
1 => "Spruce",
|
||||
2 => "Birch",
|
||||
3 => "Jungle",
|
||||
);
|
||||
];
|
||||
$this->name = "Double " . $names[$this->meta & 0x07] . " Wooden Slab";
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
|
@ -27,11 +27,11 @@ class DoubleWoodSlabBlock extends SolidBlock{
|
|||
default => 3,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(WOOD_SLAB, $this->meta & 0x07, 2),
|
||||
);
|
||||
return [
|
||||
[WOOD_SLAB, $this->meta & 0x07, 2],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
require_once("BurningFurnaceBlock.php");
|
||||
/***REM_END***/
|
||||
|
||||
|
||||
class FurnaceBlock extends BurningFurnaceBlock{
|
||||
public static $blockID;
|
||||
public function __construct($meta = 0){
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ class GlassBlock extends TransparentBlock{
|
|||
parent::__construct(GLASS, 0, "Glass");
|
||||
$this->hardness = 1.5;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [new AxisAlignedBB($x, $y, $z, $x + 1, $y + 1, $z + 1)];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ class GlowingObsidianBlock extends SolidBlock implements LightingBlock{
|
|||
public function __construct($meta = 0){
|
||||
parent::__construct(GLOWING_OBSIDIAN, $meta, "Glowing Obsidian");
|
||||
}
|
||||
|
||||
|
||||
public function getMaxLightValue(){
|
||||
return 12;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -6,17 +6,17 @@ class GlowstoneBlock extends TransparentBlock implements LightingBlock{
|
|||
parent::__construct(GLOWSTONE_BLOCK, 0, "Glowstone");
|
||||
$this->hardness = 1.5;
|
||||
}
|
||||
|
||||
|
||||
public function getMaxLightValue(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(GLOWSTONE_DUST, 0, mt_rand(2, 4)),
|
||||
);
|
||||
return [
|
||||
[GLOWSTONE_DUST, 0, mt_rand(2, 4)],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [new AxisAlignedBB($x, $y, $z, $x + 1, $y + 1, $z + 1)];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@ class GoldBlock extends SolidBlock{
|
|||
default => 15,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 4){
|
||||
return array(
|
||||
array(GOLD_BLOCK, 0, 1),
|
||||
);
|
||||
return [
|
||||
[GOLD_BLOCK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ class GrassBlock extends SolidBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(DIRT, 0, 1),
|
||||
);
|
||||
return [
|
||||
[DIRT, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
|
|
@ -34,13 +34,13 @@ class GrassBlock extends SolidBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function seedsDrop(){
|
||||
$chance = lcg_value() * 100;
|
||||
if($chance <= 1){
|
||||
ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y+1, $this->z+0.5, $this->level), BlockAPI::getItem(BEETROOT_SEEDS,0,1), 10);
|
||||
ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y + 1, $this->z + 0.5, $this->level), BlockAPI::getItem(BEETROOT_SEEDS,0,1), 10);
|
||||
}elseif($chance > 1 and $chance <= 16){
|
||||
ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y+1, $this->z+0.5, $this->level), BlockAPI::getItem(SEEDS,0,1), 10);
|
||||
ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y + 1, $this->z + 0.5, $this->level), BlockAPI::getItem(SEEDS,0,1), 10);
|
||||
}
|
||||
}
|
||||
public static function onRandomTick(Level $level, $x, $y, $z){
|
||||
|
|
@ -51,12 +51,12 @@ class GrassBlock extends SolidBlock{
|
|||
$x = $x + mt_rand(0, 2) - 1;
|
||||
$y = $y + mt_rand(0, 4) - 3;
|
||||
$z = $z + mt_rand(0, 2) - 1;
|
||||
|
||||
|
||||
$blockUp = $level->level->getBlockID($x, $y + 1, $z);
|
||||
if(StaticBlock::getIsTransparent($blockUp) && !StaticBlock::getIsLiquid($blockUp) && !($blockUp === 60) && $level->level->getBlockID($x, $y, $z) === DIRT){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, GRASS, 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ class GravelBlock extends FallableBlock{
|
|||
parent::__construct(GRAVEL, 0, "Gravel");
|
||||
$this->hardness = 3;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return [
|
||||
[mt_rand(1,10) == 1 ? FLINT : GRAVEL, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -6,16 +6,16 @@ class HayBaleBlock extends SolidBlock{
|
|||
parent::__construct(HAY_BALE, $meta, "Hay Bale");
|
||||
$this->hardness = 10;
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$faces = array(
|
||||
$faces = [
|
||||
0 => 0,
|
||||
1 => 0,
|
||||
2 => 0b1000,
|
||||
3 => 0b1000,
|
||||
4 => 0b0100,
|
||||
5 => 0b0100,
|
||||
);
|
||||
];
|
||||
|
||||
$this->meta = ($this->meta & 0x03) | $faces[$face];
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
|
|
@ -23,9 +23,9 @@ class HayBaleBlock extends SolidBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -7,17 +7,17 @@ class IceBlock extends TransparentBlock{
|
|||
$this->hardness = 2.5;
|
||||
$this->slipperiness = 0.98;
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [new AxisAlignedBB($x, $y, $z, $x + 1, $y + 1, $z + 1)];
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$ret = $this->level->setBlock($this, $this, true, false, true);
|
||||
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public function onBreak(Item $item, Player $player){
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$this->level->setBlock($this, new WaterBlock(), true, false, true);
|
||||
|
|
@ -27,20 +27,20 @@ class IceBlock extends TransparentBlock{
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function scanForNearbyLightSources($offsetX, $offsetY, $offsetZ){
|
||||
|
||||
private function scanForNearbyLightSources($offsetX, $offsetY, $offsetZ){
|
||||
for($x = -$offsetX; $x <= $offsetX; ++$x){ //i hope it is possible to optimize it
|
||||
for($z = -$offsetZ; $z <= $offsetZ; ++$z){
|
||||
for($y = -$offsetY; $y <= $offsetY; ++$y){
|
||||
$pX = $this->x+$x;
|
||||
$pY = $this->y+$y;
|
||||
$pZ = $this->z+$z;
|
||||
$pX = $this->x + $x;
|
||||
$pY = $this->y + $y;
|
||||
$pZ = $this->z + $z;
|
||||
$block = $this->level->getBlock(new Vector3($pX, $pY, $pZ)); //D= slow what was u thinking of gameherobrine from 2022
|
||||
if($block instanceof LightingBlock){ //idk is it possible to make it better
|
||||
return $block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//public static function onUpdate(Level $level, $x, $y, $z, $type){ /*Taken from https://github.com/PocketMine/PocketMine-MP/issues/3249*/
|
||||
|
|
@ -69,6 +69,6 @@ class IceBlock extends TransparentBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,5 +7,5 @@ class InfoUpdate2Block extends SolidBlock{
|
|||
$this->breakable = true;
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -7,5 +7,5 @@ class InfoUpdateBlock extends SolidBlock{
|
|||
$this->breakable = true;
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -7,12 +7,12 @@ class InvisibleBedrockBlock extends SolidBlock{
|
|||
$this->breakable = false;
|
||||
$this->hardness = 3600000;
|
||||
}
|
||||
|
||||
|
||||
public function isBreakable(Item $item, Player $player){
|
||||
if(($player->gamemode & 0x01) === 0x01){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -18,14 +18,14 @@ class IronBlock extends SolidBlock{
|
|||
default => 25,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 3){
|
||||
return array(
|
||||
array(IRON_BLOCK, 0, 1),
|
||||
);
|
||||
return [
|
||||
[IRON_BLOCK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ class LapisBlock extends SolidBlock{
|
|||
default => 15,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 3){
|
||||
return array(
|
||||
array(LAPIS_BLOCK, 0, 1),
|
||||
);
|
||||
return [
|
||||
[LAPIS_BLOCK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,22 +7,22 @@ class LeavesBlock extends TransparentBlock{
|
|||
const BIRCH = 2;
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(LEAVES, $meta, "Leaves");
|
||||
$names = array(
|
||||
$names = [
|
||||
LeavesBlock::OAK => "Oak Leaves",
|
||||
LeavesBlock::SPRUCE => "Spruce Leaves",
|
||||
LeavesBlock::BIRCH => "Birch Leaves",
|
||||
3 => "",
|
||||
);
|
||||
];
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->hardness = 1;
|
||||
}
|
||||
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [new AxisAlignedBB($x, $y, $z, $x + 1, $y + 1, $z + 1)];
|
||||
}
|
||||
|
||||
|
||||
public static function createIndex($x, $y, $z){
|
||||
return $x.".".$y.".".$z;
|
||||
return $x . "." . $y . "." . $z;
|
||||
}
|
||||
public static function findLog(Level $level, $x, $y, $z, array $visited, $distance){ //port from newest pocketmine
|
||||
$index = self::createIndex($x, $y, $z);
|
||||
|
|
@ -50,7 +50,7 @@ class LeavesBlock extends TransparentBlock{
|
|||
$meta = $b[1];
|
||||
if(($meta & 0b00001100) === 0x08){
|
||||
$meta &= 0x03;
|
||||
$visited = array();
|
||||
$visited = [];
|
||||
if(!self::findLog($level, $x, $y, $z, $visited, 0)){
|
||||
//$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||
|
|
@ -72,22 +72,22 @@ class LeavesBlock extends TransparentBlock{
|
|||
$level->fastSetBlockUpdate($x, $y, $z, $id, $meta); //TODO maybe use $level->level->setBlock directly, the client doesnt need to know thism info.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$this->meta |= 0x04;
|
||||
$this->level->setBlock($this, $this, true, false, true);
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
$drops = array();
|
||||
$drops = [];
|
||||
if($item->isShears()){
|
||||
$drops[] = array(LEAVES, $this->meta & 0x03, 1);
|
||||
$drops[] = [LEAVES, $this->meta & 0x03, 1];
|
||||
}else{
|
||||
if(mt_rand(1,20) === 1){ //Saplings
|
||||
$drops[] = array(SAPLING, $this->meta & 0x03, 1);
|
||||
$drops[] = [SAPLING, $this->meta & 0x03, 1];
|
||||
}
|
||||
if(($this->meta & 0x03) === LeavesBlock::OAK and mt_rand(1,100) === 1){ //Apples
|
||||
$drops[] = array(APPLE, 0, 1);
|
||||
$drops[] = [APPLE, 0, 1];
|
||||
}
|
||||
}
|
||||
return $drops;
|
||||
|
|
|
|||
|
|
@ -8,17 +8,16 @@ class LitPumpkinBlock extends SolidBlock implements LightingBlock{
|
|||
2 => 3,
|
||||
3 => 0,
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(LIT_PUMPKIN, $meta, "Jack o'Lantern");
|
||||
$this->hardness = 5;
|
||||
}
|
||||
|
||||
|
||||
public function getMaxLightValue(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$id = $this->level->level->getBlockID($this->x, $this->y, $this->z);
|
||||
if(($id == 0 || $id == SNOW_LAYER) && $this->level->isTopSolidBlocking($this->x, $this->y - 1, $this->z)){
|
||||
|
|
@ -28,12 +27,11 @@ class LitPumpkinBlock extends SolidBlock implements LightingBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return [
|
||||
[JACK_O_LANTERN, 0, 1]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue