Updated blocks direct break

This commit is contained in:
Shoghi Cervantes 2013-09-04 12:59:08 +02:00
parent cf8e3e41ba
commit 19112f0d06
33 changed files with 97 additions and 92 deletions

View File

@ -330,7 +330,7 @@ class BlockAPI{
$hand = $item->getBlock(); $hand = $item->getBlock();
$hand->position($block); $hand->position($block);
}elseif($block->getID() === FIRE){ }elseif($block->getID() === FIRE){
$player->level->setBlock($block, new AirBlock()); $player->level->setBlock($block, new AirBlock(), true, false, true);
return false; return false;
}else{ }else{
return $this->cancelAction($block, $player, false); return $this->cancelAction($block, $player, false);

View File

@ -45,10 +45,10 @@ class DoorBlock extends TransparentBlock{
if($next->getID() === $this->id or ($next2->isTransparent === false and $next->isTransparent === true)){ //Door hinge if($next->getID() === $this->id or ($next2->isTransparent === false and $next->isTransparent === true)){ //Door hinge
$metaUp |= 0x01; $metaUp |= 0x01;
} }
$this->level->setBlock($blockUp, BlockAPI::get($this->id, $metaUp)); //Top $this->level->setBlock($blockUp, BlockAPI::get($this->id, $metaUp), true, false, true); //Top
$this->meta = $direction & 0x03; $this->meta = $direction & 0x03;
$this->level->setBlock($block, $this); //Bottom $this->level->setBlock($block, $this, true, false, true); //Bottom
return true; return true;
} }
return false; return false;
@ -58,15 +58,15 @@ class DoorBlock extends TransparentBlock{
if(($this->meta & 0x08) === 0x08){ if(($this->meta & 0x08) === 0x08){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === $this->id){ if($down->getID() === $this->id){
$this->level->setBlock($down, new AirBlock()); $this->level->setBlock($down, new AirBlock(), true, false, true);
} }
}else{ }else{
$up = $this->getSide(1); $up = $this->getSide(1);
if($up->getID() === $this->id){ if($up->getID() === $this->id){
$this->level->setBlock($up, new AirBlock()); $this->level->setBlock($up, new AirBlock(), true, false, true);
} }
} }
$this->level->setBlock($this, new AirBlock()); $this->level->setBlock($this, new AirBlock(), true, false, true);
return true; return true;
} }
@ -75,13 +75,13 @@ class DoorBlock extends TransparentBlock{
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === $this->id){ if($down->getID() === $this->id){
$meta = $down->getMetadata() ^ 0x04; $meta = $down->getMetadata() ^ 0x04;
$this->level->setBlock($down, BlockAPI::get($this->id, $meta)); $this->level->setBlock($down, BlockAPI::get($this->id, $meta), true, false, true);
return true; return true;
} }
return false; return false;
}else{ }else{
$this->meta ^= 0x04; $this->meta ^= 0x04;
$this->level->setBlock($this, $this); $this->level->setBlock($this, $this, true, false, true);
} }
return true; return true;
} }

View File

@ -40,7 +40,7 @@ class StairBlock extends TransparentBlock{
if(($fy > 0.5 and $face !== 1) or $face === 0){ if(($fy > 0.5 and $face !== 1) or $face === 0){
$this->meta |= 0x04; //Upside-down stairs $this->meta |= 0x04; //Upside-down stairs
} }
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }

View File

@ -35,7 +35,7 @@ class LadderBlock extends TransparentBlock{
); );
if(isset($faces[$face])){ if(isset($faces[$face])){
$this->meta = $faces[$face]; $this->meta = $faces[$face];
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
} }

View File

@ -49,7 +49,7 @@ class SignPostBlock extends TransparentBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === AIR){ //Replace wit common break method if($this->getSide(0)->getID() === AIR){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SIGN, 0, 1)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SIGN, 0, 1));
$this->level->setBlock($this, new AirBlock(), true, true, true); $this->level->setBlock($this, new AirBlock(), true, true, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;

View File

@ -37,9 +37,9 @@ class TorchBlock extends FlowableBlock{
0 => 0, 0 => 0,
); );
if($this->getSide($faces[$side])->isTransparent === true and !($side === 0 and $this->getSide(0)->getID() === FENCE)){ //Replace wit common break method if($this->getSide($faces[$side])->isTransparent === true and !($side === 0 and $this->getSide(0)->getID() === FENCE)){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, 0, 1)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, 0, 1));
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), true, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
@ -56,11 +56,11 @@ class TorchBlock extends FlowableBlock{
5 => 1, 5 => 1,
); );
$this->meta = $faces[$face]; $this->meta = $faces[$face];
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
}elseif($this->getSide(0)->isTransparent === false or $this->getSide(0)->getID() === FENCE){ }elseif($this->getSide(0)->isTransparent === false or $this->getSide(0)->getID() === FENCE){
$this->meta = 0; $this->meta = 0;
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
return false; return false;

View File

@ -41,7 +41,7 @@ class TrapdoorBlock extends TransparentBlock{
if($fy > 0.5){ if($fy > 0.5){
$this->meta |= 0x08; $this->meta |= 0x08;
} }
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
} }
@ -52,7 +52,7 @@ class TrapdoorBlock extends TransparentBlock{
} }
public function onActivate(Item $item, Player $player){ public function onActivate(Item $item, Player $player){
$this->meta ^= 0x04; $this->meta ^= 0x04;
$this->level->setBlock($this, $this); $this->level->setBlock($this, $this, true, false, true);
return true; return true;
} }
} }

View File

@ -55,8 +55,8 @@ class BedBlock extends TransparentBlock{
$downNext = $this->getSide(0); $downNext = $this->getSide(0);
if($next->isReplaceable === true and $downNext->isTransparent === false){ if($next->isReplaceable === true and $downNext->isTransparent === false){
$meta = (($d + 3) % 4) & 0x03; $meta = (($d + 3) % 4) & 0x03;
$this->level->setBlock($block, BlockAPI::get($this->id, $meta)); $this->level->setBlock($block, BlockAPI::get($this->id, $meta), true, false, true);
$this->level->setBlock($next, BlockAPI::get($this->id, $meta | 0x08)); $this->level->setBlock($next, BlockAPI::get($this->id, $meta | 0x08), true, false, true);
return true; return true;
} }
} }

View File

@ -39,11 +39,11 @@ class FireBlock extends FlowableBlock{
return false; return false;
} }
} }
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), true, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
}elseif($type === BLOCK_UPDATE_RANDOM){ }elseif($type === BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getID() !== NETHERRACK){ if($this->getSide(0)->getID() !== NETHERRACK){
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), true, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }

View File

@ -29,8 +29,8 @@ class CakeBlock extends TransparentBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === AIR){ //Replace wit common break method if($this->getSide(0)->getID() === AIR){ //Replace with common break method
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), true, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
@ -46,9 +46,9 @@ class CakeBlock extends TransparentBlock{
++$this->meta; ++$this->meta;
$player->entity->heal(3, "cake"); $player->entity->heal(3, "cake");
if($this->meta >= 0x06){ if($this->meta >= 0x06){
$this->level->setBlock($this, new AirBlock()); $this->level->setBlock($this, new AirBlock(), true, false, true);
}else{ }else{
$this->level->setBlock($this, $this); $this->level->setBlock($this, $this, true, false, true);
} }
return true; return true;
} }

View File

@ -37,7 +37,7 @@ class FenceGateBlock extends TransparentBlock{
3 => 2, 3 => 2,
); );
$this->meta = $faces[$player->entity->getDirection()] & 0x03; $this->meta = $faces[$player->entity->getDirection()] & 0x03;
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
@ -53,7 +53,12 @@ class FenceGateBlock extends TransparentBlock{
3 => 2, 3 => 2,
); );
$this->meta = ($faces[$player->entity->getDirection()] & 0x03) | ((~$this->meta) & 0x04); $this->meta = ($faces[$player->entity->getDirection()] & 0x03) | ((~$this->meta) & 0x04);
$this->level->setBlock($this, $this); if(($this->meta & 0x04) === 0x04){
$this->isFullBlock = true;
}else{
$this->isFullBlock = false;
}
$this->level->setBlock($this, $this, true, false, true);
return true; return true;
} }
} }

View File

@ -27,7 +27,7 @@ class IronDoorBlock extends DoorBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === AIR){ //Replace wit common break method if($this->getSide(0)->getID() === AIR){ //Replace with common break method
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false);
if($this->getSide(1) instanceof DoorBlock){ if($this->getSide(1) instanceof DoorBlock){
$this->level->setBlock($this->getSide(1), new AirBlock(), false); $this->level->setBlock($this->getSide(1), new AirBlock(), false);

View File

@ -44,20 +44,20 @@ class SlabBlock extends TransparentBlock{
$this->meta &= 0x07; $this->meta &= 0x07;
if($face === 0){ if($face === 0){
if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){ if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($target, BlockAPI::get(DOUBLE_SLAB, $this->meta)); $this->level->setBlock($target, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true);
return true; return true;
}else{ }else{
$this->meta |= 0x08; $this->meta |= 0x08;
} }
}elseif($face === 1){ }elseif($face === 1){
if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){ if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($target, BlockAPI::get(DOUBLE_SLAB, $this->meta)); $this->level->setBlock($target, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true);
return true; return true;
} }
}elseif(!$player->entity->inBlock($block)){ }elseif(!$player->entity->inBlock($block)){
if($block->getID() === SLAB){ if($block->getID() === SLAB){
if(($block->getMetadata() & 0x07) === ($this->meta & 0x07)){ if(($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($block, BlockAPI::get(DOUBLE_SLAB, $this->meta)); $this->level->setBlock($block, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true);
return true; return true;
} }
return false; return false;
@ -72,7 +72,7 @@ class SlabBlock extends TransparentBlock{
if($block->getID() === SLAB and ($target->getMetadata() & 0x07) !== ($this->meta & 0x07)){ if($block->getID() === SLAB and ($target->getMetadata() & 0x07) !== ($this->meta & 0x07)){
return false; return false;
} }
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }

View File

@ -29,8 +29,8 @@ class SnowLayerBlock extends FlowableBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === AIR){ //Replace wit common break method if($this->getSide(0)->getID() === AIR){ //Replace with common break method
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), true, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }

View File

@ -26,7 +26,7 @@ class GlowingRedstoneOreBlock extends SolidBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_SCHEDULED or $type === BLOCK_UPDATE_RANDOM){ if($type === BLOCK_UPDATE_SCHEDULED or $type === BLOCK_UPDATE_RANDOM){
$this->level->setBlock($this, BlockAPI::get(REDSTONE_ORE, $this->meta), false); $this->level->setBlock($this, BlockAPI::get(REDSTONE_ORE, $this->meta), false, false, true);
return BLOCK_UPDATE_WEAK; return BLOCK_UPDATE_WEAK;
}else{ }else{
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);

View File

@ -26,7 +26,7 @@ class RedstoneOreBlock extends SolidBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL or $type === BLOCK_UPDATE_TOUCH){ if($type === BLOCK_UPDATE_NORMAL or $type === BLOCK_UPDATE_TOUCH){
$this->level->setBlock($this, BlockAPI::get(GLOWING_REDSTONE_ORE, $this->meta), false); $this->level->setBlock($this, BlockAPI::get(GLOWING_REDSTONE_ORE, $this->meta), false, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return BLOCK_UPDATE_WEAK; return BLOCK_UPDATE_WEAK;
} }

View File

@ -26,9 +26,9 @@ class BrownMushroomBlock extends FlowableBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
@ -38,7 +38,7 @@ class BrownMushroomBlock extends FlowableBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->isTransparent === false){ if($down->isTransparent === false){
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
return false; return false;

View File

@ -28,7 +28,7 @@ class CactusBlock extends TransparentBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() !== SAND and $down->getID() !== CACTUS){ //Replace wit common break method if($down->getID() !== SAND and $down->getID() !== CACTUS){ //Replace with common break method
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false);
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
@ -39,15 +39,15 @@ class CactusBlock extends TransparentBlock{
for($y = 1; $y < 3; ++$y){ for($y = 1; $y < 3; ++$y){
$b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z)); $b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
if($b->getID() === AIR){ if($b->getID() === AIR){
$this->level->setBlock($b, new CactusBlock()); $this->level->setBlock($b, new CactusBlock(), true, false, true);
break; break;
} }
} }
$this->meta = 0; $this->meta = 0;
$this->level->setBlock($this, $this); $this->level->setBlock($this, $this, false);
}else{ }else{
++$this->meta; ++$this->meta;
$this->level->setBlock($this, $this); $this->level->setBlock($this, $this, false);
} }
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
@ -63,7 +63,7 @@ class CactusBlock extends TransparentBlock{
$block2 = $this->getSide(4); $block2 = $this->getSide(4);
$block3 = $this->getSide(5); $block3 = $this->getSide(5);
if($block0->isTransparent === true and $block1->isTransparent === true and $block2->isTransparent === true and $block3->isTransparent === true){ if($block0->isTransparent === true and $block1->isTransparent === true and $block2->isTransparent === true and $block3->isTransparent === true){
$this->level->setBlock($this, $this); $this->level->setBlock($this, $this, true, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true; return true;
} }

View File

@ -27,7 +27,7 @@ class CyanFlowerBlock extends FlowableBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){ if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
return false; return false;
@ -35,9 +35,9 @@ class CyanFlowerBlock extends FlowableBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }

View File

@ -27,7 +27,7 @@ class DandelionBlock extends FlowableBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){ if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
return false; return false;
@ -35,9 +35,9 @@ class DandelionBlock extends FlowableBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }

View File

@ -27,8 +27,8 @@ class DeadBushBlock extends FlowableBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }

View File

@ -27,7 +27,7 @@ class MelonStemBlock extends FlowableBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === FARMLAND){ if($down->getID() === FARMLAND){
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true; return true;
} }
@ -36,16 +36,16 @@ class MelonStemBlock extends FlowableBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(MELON_SEEDS, 0, mt_rand(0, 2))); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(MELON_SEEDS, 0, mt_rand(0, 2)));
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
}elseif($type === BLOCK_UPDATE_RANDOM){ }elseif($type === BLOCK_UPDATE_RANDOM){
if(mt_rand(0, 2) == 1){ if(mt_rand(0, 2) == 1){
if($this->meta < 0x07){ if($this->meta < 0x07){
++$this->meta; ++$this->meta;
$this->level->setBlock($this, $this); $this->level->setBlock($this, $this, true, false, true);
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
}else{ }else{
for($side = 2; $side <= 5; ++$side){ for($side = 2; $side <= 5; ++$side){
@ -57,7 +57,7 @@ class MelonStemBlock extends FlowableBlock{
$side = $this->getSide(mt_rand(2,5)); $side = $this->getSide(mt_rand(2,5));
$d = $side->getSide(0); $d = $side->getSide(0);
if($side->getID() === AIR and ($d->getID() === FARMLAND or $d->getID() === GRASS or $d->getID() === DIRT)){ if($side->getID() === AIR and ($d->getID() === FARMLAND or $d->getID() === GRASS or $d->getID() === DIRT)){
$this->level->setBlock($side, new MelonBlock()); $this->level->setBlock($side, new MelonBlock(), true, false, true);
} }
} }
} }
@ -69,7 +69,7 @@ class MelonStemBlock extends FlowableBlock{
public function onActivate(Item $item, Player $player){ public function onActivate(Item $item, Player $player){
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
$this->meta = 0x07; $this->meta = 0x07;
$this->level->setBlock($this, $this); $this->level->setBlock($this, $this, true, false, true);
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$item->count--; $item->count--;
} }

View File

@ -26,7 +26,7 @@ class RedMushroomBlock extends FlowableBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
@ -38,7 +38,7 @@ class RedMushroomBlock extends FlowableBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->isTransparent === false){ if($down->isTransparent === false){
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
return false; return false;

View File

@ -39,7 +39,7 @@ class SaplingBlock extends FlowableBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === FARMLAND){ if($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === FARMLAND){
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true; return true;
} }
@ -58,9 +58,9 @@ class SaplingBlock extends FlowableBlock{
} }
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
}elseif($type === BLOCK_UPDATE_RANDOM){ //Growth }elseif($type === BLOCK_UPDATE_RANDOM){ //Growth
@ -69,7 +69,7 @@ class SaplingBlock extends FlowableBlock{
TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x03); TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x03);
}else{ }else{
$this->meta |= 0x08; $this->meta |= 0x08;
$this->level->setBlock($this, $this); $this->level->setBlock($this, $this, true, false, true);
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
}else{ }else{

View File

@ -33,9 +33,9 @@ class SugarcaneBlock extends FlowableBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->isTransparent === true and $down->getID() !== SUGARCANE_BLOCK){ //Replace wit common break method if($down->isTransparent === true and $down->getID() !== SUGARCANE_BLOCK){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SUGARCANE)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SUGARCANE));
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
}elseif($type === BLOCK_UPDATE_RANDOM){ }elseif($type === BLOCK_UPDATE_RANDOM){
@ -44,15 +44,15 @@ class SugarcaneBlock extends FlowableBlock{
for($y = 1; $y < 3; ++$y){ for($y = 1; $y < 3; ++$y){
$b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z)); $b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
if($b->getID() === AIR){ if($b->getID() === AIR){
$this->level->setBlock($b, new SugarcaneBlock()); $this->level->setBlock($b, new SugarcaneBlock(), true, false, true);
break; break;
} }
} }
$this->meta = 0; $this->meta = 0;
$this->level->setBlock($this, $this); $this->level->setBlock($this, $this, true, false, true);
}else{ }else{
++$this->meta; ++$this->meta;
$this->level->setBlock($this, $this); $this->level->setBlock($this, $this, true, false, true);
} }
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
@ -63,7 +63,7 @@ class SugarcaneBlock extends FlowableBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === SUGARCANE_BLOCK){ if($down->getID() === SUGARCANE_BLOCK){
$this->level->setBlock($block, new SugarcaneBlock()); $this->level->setBlock($block, new SugarcaneBlock(), true, false, true);
return true; return true;
}elseif($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === SAND){ }elseif($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === SAND){
$block0 = $down->getSide(2); $block0 = $down->getSide(2);
@ -71,7 +71,7 @@ class SugarcaneBlock extends FlowableBlock{
$block2 = $down->getSide(4); $block2 = $down->getSide(4);
$block3 = $down->getSide(5); $block3 = $down->getSide(5);
if(($block0 instanceof WaterBlock) or ($block1 instanceof WaterBlock) or ($block2 instanceof WaterBlock) or ($block3 instanceof WaterBlock)){ if(($block0 instanceof WaterBlock) or ($block1 instanceof WaterBlock) or ($block2 instanceof WaterBlock) or ($block3 instanceof WaterBlock)){
$this->level->setBlock($block, new SugarcaneBlock()); $this->level->setBlock($block, new SugarcaneBlock(), true, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true; return true;
} }

View File

@ -33,8 +33,8 @@ class TallGrassBlock extends FlowableBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }

View File

@ -28,7 +28,7 @@ class WheatBlock extends FlowableBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === FARMLAND){ if($down->getID() === FARMLAND){
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true; return true;
} }
@ -38,7 +38,7 @@ class WheatBlock extends FlowableBlock{
public function onActivate(Item $item, Player $player){ public function onActivate(Item $item, Player $player){
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
$this->meta = 0x07; $this->meta = 0x07;
$this->level->setBlock($this, $this); $this->level->setBlock($this, $this, true, false, true);
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$item->count--; $item->count--;
} }
@ -49,16 +49,16 @@ class WheatBlock extends FlowableBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(WHEAT_SEEDS, 0, 1)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(WHEAT_SEEDS, 0, 1));
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
}elseif($type === BLOCK_UPDATE_RANDOM){ }elseif($type === BLOCK_UPDATE_RANDOM){
if(mt_rand(0, 2) == 1){ if(mt_rand(0, 2) == 1){
if($this->meta < 0x07){ if($this->meta < 0x07){
++$this->meta; ++$this->meta;
$this->level->setBlock($this, $this); $this->level->setBlock($this, $this, true, false, true);
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
}else{ }else{

View File

@ -33,12 +33,12 @@ class BurningFurnaceBlock extends SolidBlock{
3 => 3, 3 => 3,
); );
$this->meta = $faces[$player->entity->getDirection()]; $this->meta = $faces[$player->entity->getDirection()];
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
public function onBreak(Item $item, Player $player){ public function onBreak(Item $item, Player $player){
$this->level->setBlock($this, new AirBlock(), true, true); $this->level->setBlock($this, new AirBlock(), true, true, true);
return true; return true;
} }

View File

@ -51,7 +51,7 @@ class ChestBlock extends TransparentBlock{
} }
} }
$this->level->setBlock($block, $this); $this->level->setBlock($block, $this, true, false, true);
$tile = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array( $tile = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
"Items" => array(), "Items" => array(),
"id" => TILE_CHEST, "id" => TILE_CHEST,
@ -72,7 +72,7 @@ class ChestBlock extends TransparentBlock{
if($t !== false){ if($t !== false){
$t->unpair(); $t->unpair();
} }
$this->level->setBlock($this, new AirBlock(), true, true); $this->level->setBlock($this, new AirBlock(), true, true, true);
return true; return true;
} }

View File

@ -30,7 +30,7 @@ class DirtBlock extends SolidBlock{
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$item->useOn($this); $item->useOn($this);
} }
$this->level->setBlock($this, BlockAPI::get(FARMLAND, 0)); $this->level->setBlock($this, BlockAPI::get(FARMLAND, 0), true, false, true);
return true; return true;
} }
return false; return false;

View File

@ -103,7 +103,7 @@ class LeavesBlock extends TransparentBlock{
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if(($this->meta & 0b00001100) === 0){ if(($this->meta & 0b00001100) === 0){
$this->meta |= 0x08; $this->meta |= 0x08;
$this->level->setBlock($this, $this, false); $this->level->setBlock($this, $this, false, false, true);
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
}elseif($type === BLOCK_UPDATE_RANDOM){ }elseif($type === BLOCK_UPDATE_RANDOM){
@ -112,9 +112,9 @@ class LeavesBlock extends TransparentBlock{
$visited = array(); $visited = array();
$check = 0; $check = 0;
if($this->findLog($this, $visited, 0, $check) === true){ if($this->findLog($this, $visited, 0, $check) === true){
$this->level->setBlock($this, $this, false); $this->level->setBlock($this, $this, false, false, true);
}else{ }else{
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false, false, true);
if(mt_rand(1,20) === 1){ //Saplings if(mt_rand(1,20) === 1){ //Saplings
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SAPLING, $this->meta & 0x03, 1)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SAPLING, $this->meta & 0x03, 1));
} }
@ -130,7 +130,7 @@ class LeavesBlock extends TransparentBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$this->meta |= 0x04; $this->meta |= 0x04;
$this->level->setBlock($this, $this); $this->level->setBlock($this, $this, true, false, true);
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){

View File

@ -29,7 +29,7 @@ class BucketItem extends Item{
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if($this->meta === AIR){ if($this->meta === AIR){
if($target instanceof LiquidBlock){ if($target instanceof LiquidBlock){
$level->setBlock($target, new AirBlock()); $level->setBlock($target, new AirBlock(), true, false, true);
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$this->meta = ($target instanceof WaterBlock) ? WATER:LAVA; $this->meta = ($target instanceof WaterBlock) ? WATER:LAVA;
} }
@ -37,7 +37,7 @@ class BucketItem extends Item{
} }
}elseif($this->meta === WATER){ }elseif($this->meta === WATER){
if($block->getID() === AIR){ if($block->getID() === AIR){
$level->setBlock($block, new StillWaterBLock()); $level->setBlock($block, new StillWaterBlock(), true, false, true);
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$this->meta = 0; $this->meta = 0;
} }
@ -45,7 +45,7 @@ class BucketItem extends Item{
} }
}elseif($this->meta === LAVA){ }elseif($this->meta === LAVA){
if($block->getID() === AIR){ if($block->getID() === AIR){
$level->setBlock($block, new StillLavaBlock()); $level->setBlock($block, new StillLavaBlock(), true, false, true);
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$this->meta = 0; $this->meta = 0;
} }

View File

@ -246,7 +246,7 @@ class Tile extends Position{
$this->setSlot(1, $fuel, false); $this->setSlot(1, $fuel, false);
$current = $this->level->getBlock($this); $current = $this->level->getBlock($this);
if($current->getID() === FURNACE){ if($current->getID() === FURNACE){
$this->level->setBlock($this, BlockAPI::get(BURNING_FURNACE, $current->getMetadata())); $this->level->setBlock($this, BlockAPI::get(BURNING_FURNACE, $current->getMetadata()), true, false, true);
} }
} }
if($this->data["BurnTime"] > 0){ if($this->data["BurnTime"] > 0){
@ -278,7 +278,7 @@ class Tile extends Position{
}else{ }else{
$current = $this->level->getBlock($this); $current = $this->level->getBlock($this);
if($current->getID() === BURNING_FURNACE){ if($current->getID() === BURNING_FURNACE){
$this->level->setBlock($this, BlockAPI::get(FURNACE, $current->getMetadata())); $this->level->setBlock($this, BlockAPI::get(FURNACE, $current->getMetadata()), true, false, true);
} }
$this->data["CookTime"] = 0; $this->data["CookTime"] = 0;
$this->data["BurnTime"] = 0; $this->data["BurnTime"] = 0;