mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 03:59:43 +00:00
project uses tabs instead of spaces(as in CONTRIBUTING.md)
This commit is contained in:
parent
f00318b6ed
commit
62571f26cd
115 changed files with 2291 additions and 2364 deletions
|
|
@ -1,27 +1,27 @@
|
|||
<?php
|
||||
|
||||
class DoorBlock extends TransparentBlock{
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
parent::__construct($id, $meta, $name);
|
||||
$this->isSolid = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $type
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function onUpdate($type){
|
||||
/**
|
||||
* @param int $type
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function onUpdate($type){
|
||||
if($type === BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->getID() === AIR){ //Replace with common break method
|
||||
$this->level->setBlock($this, new AirBlock(), false);
|
||||
if($this->getID() == 64) ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem(324, 0, 1));
|
||||
elseif($this->getID() == 71) ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem(330, 0, 1));
|
||||
if($this->getID() == 64) ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem(324, 0, 1));
|
||||
elseif($this->getID() == 71) ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem(330, 0, 1));
|
||||
if($this->getSide(1) instanceof DoorBlock){
|
||||
$this->level->setBlock($this->getSide(1), new AirBlock(), false);
|
||||
}
|
||||
|
|
@ -32,19 +32,19 @@ 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
|
||||
* @param integer $fz
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
* @param Block $block
|
||||
* @param Block $target
|
||||
* @param integer $face
|
||||
* @param integer $fx
|
||||
* @param integer $fy
|
||||
* @param integer $fz
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($face === 1){
|
||||
$blockUp = $this->getSide(1);
|
||||
$blockDown = $this->getSide(0);
|
||||
|
|
@ -73,13 +73,13 @@ class DoorBlock extends TransparentBlock{
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function onBreak(Item $item, Player $player){
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function onBreak(Item $item, Player $player){
|
||||
if(($this->meta & 0x08) === 0x08){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() === $this->id){
|
||||
|
|
@ -95,13 +95,13 @@ class DoorBlock extends TransparentBlock{
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function onActivate(Item $item, Player $player){
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if(($this->meta & 0x08) === 0x08){ //Top
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() === $this->id){
|
||||
|
|
|
|||
|
|
@ -1,29 +1,29 @@
|
|||
<?php
|
||||
|
||||
class FallableBlock extends SolidBlock{
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
parent::__construct($id, $meta, $name);
|
||||
$this->hasPhysics = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
* @param Block $block
|
||||
* @param Block $target
|
||||
* @param int $face
|
||||
* @param int $fx
|
||||
* @param int $fy
|
||||
* @param int $fz
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
* @param Block $block
|
||||
* @param Block $target
|
||||
* @param int $face
|
||||
* @param int $fx
|
||||
* @param int $fy
|
||||
* @param int $fz
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$ret = $this->level->setBlock($this, $this, true, false, true);
|
||||
ServerAPI::request()->api->block->blockUpdate(clone $this, BLOCK_UPDATE_NORMAL);
|
||||
return $ret;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
|
||||
class FlowableBlock extends TransparentBlock{
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
parent::__construct($id, $meta, $name);
|
||||
$this->isFlowable = true;
|
||||
$this->isFullBlock = false;
|
||||
|
|
|
|||
|
|
@ -2,57 +2,57 @@
|
|||
|
||||
|
||||
class GenericBlock extends Block{
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
parent::__construct($id, $meta, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
* @param Block $block
|
||||
* @param Block $target
|
||||
* @param integer $face
|
||||
* @param integer $fx
|
||||
* @param integer $fy
|
||||
* @param integer $fz
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
* @param Block $block
|
||||
* @param Block $target
|
||||
* @param integer $face
|
||||
* @param integer $fx
|
||||
* @param integer $fy
|
||||
* @param integer $fz
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
return $this->level->setBlock($this, $this, true, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isBreakable(Item $item, Player $player){
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isBreakable(Item $item, Player $player){
|
||||
return ($this->breakable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function onBreak(Item $item, Player $player){
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function onBreak(Item $item, Player $player){
|
||||
return $this->level->setBlock($this, new AirBlock(), true, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $type
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function onUpdate($type){
|
||||
/**
|
||||
* @param integer $type
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function onUpdate($type){
|
||||
if($this->hasPhysics === true and $type === BLOCK_UPDATE_NORMAL){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() === AIR or ($down instanceof LiquidBlock)){
|
||||
|
|
@ -73,13 +73,13 @@ class GenericBlock extends Block{
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function onActivate(Item $item, Player $player){
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function onActivate(Item $item, Player $player){
|
||||
return $this->isActivable;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
|
||||
class LiquidBlock extends TransparentBlock{
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
parent::__construct($id, $meta, $name);
|
||||
$this->isLiquid = true;
|
||||
$this->breakable = false;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
|
||||
class SolidBlock extends GenericBlock{
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
parent::__construct($id, $meta, $name);
|
||||
$this->isSolid = true;
|
||||
$this->isFullBlock = true;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
|
||||
class StairBlock extends TransparentBlock{
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
parent::__construct($id, $meta, $name);
|
||||
if(($this->meta & 0x04) === 0x04){
|
||||
$this->isFullBlock = true;
|
||||
|
|
@ -16,19 +16,19 @@ class StairBlock extends TransparentBlock{
|
|||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
* @param Block $block
|
||||
* @param Block $target
|
||||
* @param int $face
|
||||
* @param int $fx
|
||||
* @param int $fy
|
||||
* @param int $fz
|
||||
*
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
* @param Block $block
|
||||
* @param Block $target
|
||||
* @param int $face
|
||||
* @param int $fx
|
||||
* @param int $fy
|
||||
* @param int $fz
|
||||
*
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$faces = array(
|
||||
0 => 0,
|
||||
1 => 2,
|
||||
|
|
@ -43,13 +43,13 @@ class StairBlock extends TransparentBlock{
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDrops(Item $item, Player $player){
|
||||
/**
|
||||
* @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),
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
|
||||
class TransparentBlock extends GenericBlock{
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
parent::__construct($id, $meta, $name);
|
||||
$this->isActivable = false;
|
||||
$this->breakable = true;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
<?php
|
||||
|
||||
class SignPostBlock extends TransparentBlock{
|
||||
|
||||
private $faces = array(
|
||||
2 => 2,
|
||||
3 => 3,
|
||||
4 => 4,
|
||||
5 => 5,
|
||||
);
|
||||
|
||||
|
||||
private $faces = array(
|
||||
2 => 2,
|
||||
3 => 3,
|
||||
4 => 4,
|
||||
5 => 5,
|
||||
);
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(SIGN_POST, $meta, "Sign Post");
|
||||
$this->isSolid = false;
|
||||
|
|
@ -17,13 +17,13 @@ class SignPostBlock extends TransparentBlock{
|
|||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($target->isSolid && $face !== 0){
|
||||
if($target->isSolid && $face !== 0){
|
||||
if(!isset($this->faces[$face])){
|
||||
$this->meta = floor((($player->entity->yaw + 180) * 16 / 360) + 0.5) & 0x0F;
|
||||
$this->level->setBlock($block, BlockAPI::get(SIGN_POST, $this->meta), true, false, true);
|
||||
return true;
|
||||
}else{
|
||||
$this->meta = $this->faces[$face];
|
||||
$this->meta = $this->faces[$face];
|
||||
$this->level->setBlock($block, BlockAPI::get(WALL_SIGN, $this->meta, true, false, true));
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ class TrapdoorBlock extends TransparentBlock{
|
|||
}
|
||||
|
||||
public function canAttachTo(Block $target){
|
||||
$id = $target->getID();
|
||||
return $id === SLAB || $id === GLOWSTONE || $id === SLAB || $id === WOOD_SLAB || (!$target->isTransparent || $target instanceof StairBlock);
|
||||
$id = $target->getID();
|
||||
return $id === SLAB || $id === GLOWSTONE || $id === SLAB || $id === WOOD_SLAB || (!$target->isTransparent || $target instanceof StairBlock);
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
|
|
|||
|
|
@ -97,8 +97,8 @@ class LavaBlock extends LiquidBlock implements LightingBlock{
|
|||
$tlevel = $sb->meta & 0x06;
|
||||
if($tlevel != 0x00){
|
||||
for ($s = 0; $s <= 5; $s++) {
|
||||
$ssb = $sb->getSide($s);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL);
|
||||
$ssb = $sb->getSide($s);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
$this->level->setBlock($sb, new AirBlock(), false, false, true);
|
||||
}
|
||||
|
|
@ -107,10 +107,10 @@ class LavaBlock extends LiquidBlock implements LightingBlock{
|
|||
if($b instanceof LavaBlock){
|
||||
$tlevel = $b->meta & 0x06;
|
||||
if($tlevel != 0x00){
|
||||
for ($s = 0; $s <= 5; $s++) {
|
||||
$ssb = $sb->getSide($s);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
for ($s = 0; $s <= 5; $s++) {
|
||||
$ssb = $sb->getSide($s);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
$this->level->setBlock($b, new AirBlock(), false, false, true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,126 +1,126 @@
|
|||
<?php
|
||||
|
||||
class WaterBlock extends LiquidBlock{
|
||||
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);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(clone $this, 5, BLOCK_UPDATE_NORMAL);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getSourceCount(){
|
||||
$count = 0;
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
if( $this->getSide($side) instanceof WaterBlock ){
|
||||
$b = $this->getSide($side);
|
||||
$level = $b->meta & 0x07;
|
||||
if($level == 0x00){
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
public function checkLava(){
|
||||
for($side = 0; $side <= 5; ++$side){
|
||||
if($side == 1){
|
||||
continue;
|
||||
}
|
||||
$b = $this->getSide($side);
|
||||
if($b instanceof LavaBlock){
|
||||
$level = $b->meta & 0x07;
|
||||
if($level == 0x00){
|
||||
$this->level->setBlock($b, new ObsidianBlock(), false, false, true);
|
||||
}else{
|
||||
$this->level->setBlock($b, new CobblestoneBlock(), false, false, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getFrom(){
|
||||
for($side = 0; $side <= 5; ++$side){
|
||||
$b = $this->getSide($side);
|
||||
if($b instanceof WaterBlock){
|
||||
$tlevel = $b->meta & 0x07;
|
||||
$level = $this->meta & 0x07;
|
||||
if( ($tlevel + 1) == $level || ($side == 0x01 && $level == 0x01 )){
|
||||
return $b;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
//return false;
|
||||
$newId = $this->id;
|
||||
$level = $this->meta & 0x07;
|
||||
if($type !== BLOCK_UPDATE_NORMAL){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->checkLava();
|
||||
|
||||
$falling = $this->meta >> 3;
|
||||
$down = $this->getSide(0);
|
||||
|
||||
$from = $this->getFrom();
|
||||
//Has Source or Its Source
|
||||
if($from !== null || $level == 0x00){
|
||||
if($down instanceof AirBlock || $down instanceof WaterBlock){
|
||||
$this->level->setBlock($down, new WaterBlock(0x00), false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
}elseif($level !== 0x07){{
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
$b = $this->getSide($side);
|
||||
if($b instanceof WaterBlock){
|
||||
if( $this->getSourceCount() >= 2 && $level != 0x00){
|
||||
$this->level->setBlock($this, new WaterBlock(0), false, false, true);
|
||||
}
|
||||
}elseif($b->isFlowable === true){
|
||||
$this->level->setBlock($b, new WaterBlock($level + 1), false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//Extend Remove for Left Waters
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
$sb = $this->getSide($side);
|
||||
if($sb instanceof WaterBlock){
|
||||
$tlevel = $sb->meta & 0x07;
|
||||
if($tlevel != 0x00){
|
||||
for ($s = 0; $s <= 5; $s++) {
|
||||
$ssb = $sb->getSide($s);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
$this->level->setBlock($sb, new AirBlock(), false, false, true);
|
||||
}
|
||||
}
|
||||
$b = $this->getSide(0)->getSide($side);
|
||||
if($b instanceof WaterBlock){
|
||||
$tlevel = $b->meta & 0x07;
|
||||
if($tlevel != 0x00){
|
||||
for ($s = 0; $s <= 5; $s++) {
|
||||
$ssb = $sb->getSide($s);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
$this->level->setBlock($b, new AirBlock(), false, false, true);
|
||||
}
|
||||
}
|
||||
//ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(clone $this, 5, BLOCK_UPDATE_NORMAL);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getSourceCount(){
|
||||
$count = 0;
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
if( $this->getSide($side) instanceof WaterBlock ){
|
||||
$b = $this->getSide($side);
|
||||
$level = $b->meta & 0x07;
|
||||
if($level == 0x00){
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
public function checkLava(){
|
||||
for($side = 0; $side <= 5; ++$side){
|
||||
if($side == 1){
|
||||
continue;
|
||||
}
|
||||
$b = $this->getSide($side);
|
||||
if($b instanceof LavaBlock){
|
||||
$level = $b->meta & 0x07;
|
||||
if($level == 0x00){
|
||||
$this->level->setBlock($b, new ObsidianBlock(), false, false, true);
|
||||
}else{
|
||||
$this->level->setBlock($b, new CobblestoneBlock(), false, false, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getFrom(){
|
||||
for($side = 0; $side <= 5; ++$side){
|
||||
$b = $this->getSide($side);
|
||||
if($b instanceof WaterBlock){
|
||||
$tlevel = $b->meta & 0x07;
|
||||
$level = $this->meta & 0x07;
|
||||
if( ($tlevel + 1) == $level || ($side == 0x01 && $level == 0x01 )){
|
||||
return $b;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
//return false;
|
||||
$newId = $this->id;
|
||||
$level = $this->meta & 0x07;
|
||||
if($type !== BLOCK_UPDATE_NORMAL){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->checkLava();
|
||||
|
||||
$falling = $this->meta >> 3;
|
||||
$down = $this->getSide(0);
|
||||
|
||||
$from = $this->getFrom();
|
||||
//Has Source or Its Source
|
||||
if($from !== null || $level == 0x00){
|
||||
if($down instanceof AirBlock || $down instanceof WaterBlock){
|
||||
$this->level->setBlock($down, new WaterBlock(0x00), false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
}elseif($level !== 0x07){{
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
$b = $this->getSide($side);
|
||||
if($b instanceof WaterBlock){
|
||||
if( $this->getSourceCount() >= 2 && $level != 0x00){
|
||||
$this->level->setBlock($this, new WaterBlock(0), false, false, true);
|
||||
}
|
||||
}elseif($b->isFlowable === true){
|
||||
$this->level->setBlock($b, new WaterBlock($level + 1), false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//Extend Remove for Left Waters
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
$sb = $this->getSide($side);
|
||||
if($sb instanceof WaterBlock){
|
||||
$tlevel = $sb->meta & 0x07;
|
||||
if($tlevel != 0x00){
|
||||
for ($s = 0; $s <= 5; $s++) {
|
||||
$ssb = $sb->getSide($s);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
$this->level->setBlock($sb, new AirBlock(), false, false, true);
|
||||
}
|
||||
}
|
||||
$b = $this->getSide(0)->getSide($side);
|
||||
if($b instanceof WaterBlock){
|
||||
$tlevel = $b->meta & 0x07;
|
||||
if($tlevel != 0x00){
|
||||
for ($s = 0; $s <= 5; $s++) {
|
||||
$ssb = $sb->getSide($s);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
$this->level->setBlock($b, new AirBlock(), false, false, true);
|
||||
}
|
||||
}
|
||||
//ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -49,12 +49,12 @@ class NetherReactorBlock extends SolidBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return array(
|
||||
[DIAMOND, 0, 3],
|
||||
[IRON_INGOT, 0, 6],
|
||||
);
|
||||
}
|
||||
if($item->getPickaxeLevel() >= 1){
|
||||
return array(
|
||||
[DIAMOND, 0, 3],
|
||||
[IRON_INGOT, 0, 6],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function decay($x, $y, $z, $aOne, $aTwo, $aThree, $bOne, $bTwo, $bThree, $cOne, $cTwo, $cThree) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class FenceGateBlock extends TransparentBlock{
|
|||
);
|
||||
}
|
||||
public function onActivate(Item $item, Player $player){
|
||||
$this->meta ^= 0x04;
|
||||
$this->meta ^= 0x04;
|
||||
$this->level->setBlock($this, $this, true, false, true);
|
||||
$players = ServerAPI::request()->api->player->getAll($this->level);
|
||||
unset($players[$player->CID]);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class RailBlock extends FlowableBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(RAIL, $meta, "Rail");
|
||||
parent::__construct(RAIL, $meta, "Rail");
|
||||
$this->hardness = 0.7;
|
||||
$this->isFullBlock = false;
|
||||
$this->isSolid = false;
|
||||
|
|
@ -11,25 +11,25 @@ class RailBlock extends FlowableBlock{
|
|||
public static $shouldconnectrails = false;
|
||||
|
||||
private function isRailBlock($id){
|
||||
return $id === RAIL || $id === POWERED_RAIL;
|
||||
}
|
||||
return $id === RAIL || $id === POWERED_RAIL;
|
||||
}
|
||||
|
||||
private function isValidRailMeta($meta){
|
||||
return !($meta < 0 || $meta > 10);
|
||||
}
|
||||
return !($meta < 0 || $meta > 10);
|
||||
}
|
||||
|
||||
private function canConnectRail($block) {
|
||||
if(!($block instanceof RailBlock)) return null;
|
||||
if($this->distanceSquared($block) > 2) return null;
|
||||
$result = $this->checkRail($this);
|
||||
if(count($result) === 2) return null;
|
||||
return $result;
|
||||
}
|
||||
if(!($block instanceof RailBlock)) return null;
|
||||
if($this->distanceSquared($block) > 2) return null;
|
||||
$result = $this->checkRail($this);
|
||||
if(count($result) === 2) return null;
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function checkRail($rail){//fixed
|
||||
if(!($rail instanceof RailBlock)) return null;
|
||||
$damage = $rail->meta;
|
||||
if ($damage < 0 || $damage > 10) return null;
|
||||
if(!($rail instanceof RailBlock)) return null;
|
||||
$damage = $rail->meta;
|
||||
if ($damage < 0 || $damage > 10) return null;
|
||||
$delta = array(
|
||||
array(array(0, 1), array(0, -1)),
|
||||
array(array(1, 0), array(-1, 0)),
|
||||
|
|
@ -44,70 +44,70 @@ class RailBlock extends FlowableBlock{
|
|||
array(array(-1, 0), array(0, -1)),
|
||||
array(array(0, -1), array(1, 0))
|
||||
);
|
||||
$deltaY = array(0, 1, -1);
|
||||
$blocks = $delta[$damage];
|
||||
$connected = array();
|
||||
$deltaY = array(0, 1, -1);
|
||||
$blocks = $delta[$damage];
|
||||
$connected = array();
|
||||
|
||||
foreach($deltaY as $y){
|
||||
$v3 = new Vector3(
|
||||
$rail->getFloorX() + $blocks[0][0],
|
||||
$rail->getFloorY() + $y,
|
||||
$rail->getFloorZ() + $blocks[0][1]
|
||||
);
|
||||
$railBlock = $rail->level->getBlock($v3);
|
||||
$idToConnect = $railBlock->getID();
|
||||
$metaToConnect = $railBlock->getMetadata();
|
||||
if (!$this->isRailBlock($idToConnect) || !$this->isValidRailMeta($metaToConnect)) continue;
|
||||
$xDiff = $this->getFloorX() - $v3->getFloorX();
|
||||
$zDiff = $this->getFloorZ() - $v3->getFloorZ();
|
||||
foreach($blocks as $xz) {
|
||||
if($xz[0] !== $xDiff || $xz[1] !== $zDiff) continue;
|
||||
$connected[] = $v3;
|
||||
}
|
||||
}
|
||||
foreach($deltaY as $y){
|
||||
$v3 = new Vector3(
|
||||
$rail->getFloorX() + $blocks[1][0],
|
||||
$rail->getFloorY() + $y,
|
||||
$rail->getFloorZ() + $blocks[1][1]
|
||||
);
|
||||
$railBlock = $rail->level->getBlock($v3);
|
||||
$idToConnect = $railBlock->getID();
|
||||
$metaToConnect = $railBlock->getMetadata();
|
||||
if(!$this->isRailBlock($idToConnect) || !$this->isValidRailMeta($metaToConnect)) continue;
|
||||
$xDiff = $this->getFloorX() - $v3->getFloorX();
|
||||
$zDiff = $this->getFloorZ() - $v3->getFloorZ();
|
||||
foreach($blocks as $xz){
|
||||
if ($xz[0] !== $xDiff || $xz[1] !== $zDiff) continue;
|
||||
$connected[] = $v3;
|
||||
}
|
||||
}
|
||||
return $connected;
|
||||
}
|
||||
foreach($deltaY as $y){
|
||||
$v3 = new Vector3(
|
||||
$rail->getFloorX() + $blocks[0][0],
|
||||
$rail->getFloorY() + $y,
|
||||
$rail->getFloorZ() + $blocks[0][1]
|
||||
);
|
||||
$railBlock = $rail->level->getBlock($v3);
|
||||
$idToConnect = $railBlock->getID();
|
||||
$metaToConnect = $railBlock->getMetadata();
|
||||
if (!$this->isRailBlock($idToConnect) || !$this->isValidRailMeta($metaToConnect)) continue;
|
||||
$xDiff = $this->getFloorX() - $v3->getFloorX();
|
||||
$zDiff = $this->getFloorZ() - $v3->getFloorZ();
|
||||
foreach($blocks as $xz) {
|
||||
if($xz[0] !== $xDiff || $xz[1] !== $zDiff) continue;
|
||||
$connected[] = $v3;
|
||||
}
|
||||
}
|
||||
foreach($deltaY as $y){
|
||||
$v3 = new Vector3(
|
||||
$rail->getFloorX() + $blocks[1][0],
|
||||
$rail->getFloorY() + $y,
|
||||
$rail->getFloorZ() + $blocks[1][1]
|
||||
);
|
||||
$railBlock = $rail->level->getBlock($v3);
|
||||
$idToConnect = $railBlock->getID();
|
||||
$metaToConnect = $railBlock->getMetadata();
|
||||
if(!$this->isRailBlock($idToConnect) || !$this->isValidRailMeta($metaToConnect)) continue;
|
||||
$xDiff = $this->getFloorX() - $v3->getFloorX();
|
||||
$zDiff = $this->getFloorZ() - $v3->getFloorZ();
|
||||
foreach($blocks as $xz){
|
||||
if ($xz[0] !== $xDiff || $xz[1] !== $zDiff) continue;
|
||||
$connected[] = $v3;
|
||||
}
|
||||
}
|
||||
return $connected;
|
||||
}
|
||||
|
||||
private function connectRail($rail){
|
||||
$connected = $this->canConnectRail($rail);
|
||||
if ($connected === null || count($connected) === 0) return;
|
||||
if(count($connected) === 1){
|
||||
$v3 = $connected[0]->subtract($this);
|
||||
$this->meta = ($v3->y !== 1) ? ($v3->x === 0 ? 0 : 1) : (int) ($v3->z === 0 ? ($v3->x / -2) + 2.5 : ($v3->z / 2) + 4.5);
|
||||
}elseif(count(connected) === 2){
|
||||
$subtract = array(new Vector3(0, 0, 0),new Vector3(0, 0, 0));
|
||||
for ($i = 0; $i < count($connected); $i++) {
|
||||
$subtract[$i] = $connected[$i]->subtract($this);
|
||||
}
|
||||
if (abs($subtract[0]->x) === abs($subtract[1]->z) && abs($subtract[1]->x) === abs($subtract[0]->z)){
|
||||
$v3 = $connected[0]->subtract($this)->add($connected[1]->subtract($this));
|
||||
$this->meta = $v3->x === 1 ? ($v3->z === 1 ? 6 : 9) : ($v3->z === 1 ? 7 : 8);
|
||||
}elseif ($subtract[0]->y === 1 || $subtract[1]->y === 1){
|
||||
$v3 = $subtract[0]->y === 1 ? $subtract[0] : $subtract[1];
|
||||
$this->meta = $v3->x === 0 ? ($v3->z === -1 ? 4 : 5) : ($v3->x === 1 ? 2 : 3);
|
||||
}else{
|
||||
$this->meta = $subtract[0]->x === 0 ? 0 : 1;
|
||||
}
|
||||
}
|
||||
$this->level->setBlock($rail, new RailBlock($this->meta), true, true);
|
||||
}
|
||||
$connected = $this->canConnectRail($rail);
|
||||
if ($connected === null || count($connected) === 0) return;
|
||||
if(count($connected) === 1){
|
||||
$v3 = $connected[0]->subtract($this);
|
||||
$this->meta = ($v3->y !== 1) ? ($v3->x === 0 ? 0 : 1) : (int) ($v3->z === 0 ? ($v3->x / -2) + 2.5 : ($v3->z / 2) + 4.5);
|
||||
}elseif(count(connected) === 2){
|
||||
$subtract = array(new Vector3(0, 0, 0),new Vector3(0, 0, 0));
|
||||
for ($i = 0; $i < count($connected); $i++) {
|
||||
$subtract[$i] = $connected[$i]->subtract($this);
|
||||
}
|
||||
if (abs($subtract[0]->x) === abs($subtract[1]->z) && abs($subtract[1]->x) === abs($subtract[0]->z)){
|
||||
$v3 = $connected[0]->subtract($this)->add($connected[1]->subtract($this));
|
||||
$this->meta = $v3->x === 1 ? ($v3->z === 1 ? 6 : 9) : ($v3->z === 1 ? 7 : 8);
|
||||
}elseif ($subtract[0]->y === 1 || $subtract[1]->y === 1){
|
||||
$v3 = $subtract[0]->y === 1 ? $subtract[0] : $subtract[1];
|
||||
$this->meta = $v3->x === 0 ? ($v3->z === -1 ? 4 : 5) : ($v3->x === 1 ? 2 : 3);
|
||||
}else{
|
||||
$this->meta = $subtract[0]->x === 0 ? 0 : 1;
|
||||
}
|
||||
}
|
||||
$this->level->setBlock($rail, new RailBlock($this->meta), true, true);
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$down = $this->getSide(0);
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ class BeetrootBlock extends FlowableBlock{
|
|||
$drops[] = array(BEETROOT, 0, 1);
|
||||
}
|
||||
for($i = 0; $i < 3; ++$i){
|
||||
if(mt_rand(0,15) <= $this->meta){ //a way from 1.4.7
|
||||
$drops[] = array(BEETROOT_SEEDS, 0, 1);
|
||||
}
|
||||
if(mt_rand(0,15) <= $this->meta){ //a way from 1.4.7
|
||||
$drops[] = array(BEETROOT_SEEDS, 0, 1);
|
||||
}
|
||||
}
|
||||
return $drops;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class CarrotBlock extends FlowableBlock{
|
|||
}
|
||||
for($i = 0; $i < 3; ++$i){
|
||||
if(mt_rand(0,15) <= $this->meta){ //a way from 1.4.7
|
||||
$drops[] = array(CARROT, 0, 1);
|
||||
$drops[] = array(CARROT, 0, 1);
|
||||
}
|
||||
}
|
||||
return $drops;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class TallGrassBlock extends FlowableBlock{
|
|||
if($type === BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){//Replace with common break method
|
||||
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||
if(Utils::chance(15)) ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(WHEAT_SEEDS));
|
||||
if(Utils::chance(15)) ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(WHEAT_SEEDS));
|
||||
return BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,11 +60,11 @@ class WheatBlock extends FlowableBlock{
|
|||
$drops[] = array(WHEAT, 0, 1);
|
||||
$drops[] = array(WHEAT_SEEDS, 0, mt_rand(0, 3));
|
||||
}else{
|
||||
for($i = 0; $i < 3; ++$i){
|
||||
if(mt_rand(0,15) <= $this->meta){ //a way from 1.4.7
|
||||
$drops[] = array(WHEAT_SEEDS, 0, 1);
|
||||
}
|
||||
}
|
||||
for($i = 0; $i < 3; ++$i){
|
||||
if(mt_rand(0,15) <= $this->meta){ //a way from 1.4.7
|
||||
$drops[] = array(WHEAT_SEEDS, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return $drops;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class DirtBlock extends SolidBlock{
|
|||
$x = $this->x;
|
||||
$y = $this->y;
|
||||
$z = $this->z;
|
||||
|
||||
|
||||
if($this->getBlockID($x+1, $y, $z+1) == 2) return true;
|
||||
if($this->getBlockID($x+1, $y, $z) == 2) return true;
|
||||
if($this->getBlockID($x+1, $y, $z-1) == 2) return true;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class DoubleSlabBlock extends SolidBlock{
|
|||
4 => "Brick",
|
||||
5 => "Stone Brick",
|
||||
6 => "Quartz",
|
||||
7 => "Smooth Stone",
|
||||
7 => "Smooth Stone",
|
||||
);
|
||||
$this->name = "Double " . $names[$this->meta & 0x07] . " Slab";
|
||||
$this->hardness = 30;
|
||||
|
|
|
|||
|
|
@ -10,15 +10,15 @@ class LitPumpkinBlock extends SolidBlock implements LightingBlock{
|
|||
return 15;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$faces = array(
|
||||
0 => 1,
|
||||
1 => 2,
|
||||
2 => 3,
|
||||
3 => 0,
|
||||
);
|
||||
$this->meta = $faces[$player->entity->getDirection()];
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
return true;
|
||||
}
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$faces = array(
|
||||
0 => 1,
|
||||
1 => 2,
|
||||
2 => 3,
|
||||
3 => 0,
|
||||
);
|
||||
$this->meta = $faces[$player->entity->getDirection()];
|
||||
$this->level->setBlock($block, $this, true, false, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue