mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-23 00:55:57 +00:00
Added block cloning fix
This commit is contained in:
parent
24ba7cbbd1
commit
54b73e5f82
@ -706,27 +706,21 @@ class BlockAPI{
|
||||
}
|
||||
}*/
|
||||
|
||||
public function blockUpdateAround(Position $pos, $type = BLOCK_UPDATE_NORMAL, $delay = false){
|
||||
if(!($pos instanceof Block)){
|
||||
$block = $pos->level->getBlock($pos);
|
||||
}else{
|
||||
$block = $pos;
|
||||
}
|
||||
|
||||
public function blockUpdateAround(Position $pos, $type = BLOCK_UPDATE_NORMAL, $delay = false){
|
||||
if($delay !== false){
|
||||
$this->scheduleBlockUpdate($block->getSide(0), $delay, $type);
|
||||
$this->scheduleBlockUpdate($block->getSide(1), $delay, $type);
|
||||
$this->scheduleBlockUpdate($block->getSide(2), $delay, $type);
|
||||
$this->scheduleBlockUpdate($block->getSide(3), $delay, $type);
|
||||
$this->scheduleBlockUpdate($block->getSide(4), $delay, $type);
|
||||
$this->scheduleBlockUpdate($block->getSide(5), $delay, $type);
|
||||
$this->scheduleBlockUpdate($pos->getSide(0), $delay, $type);
|
||||
$this->scheduleBlockUpdate($pos->getSide(1), $delay, $type);
|
||||
$this->scheduleBlockUpdate($pos->getSide(2), $delay, $type);
|
||||
$this->scheduleBlockUpdate($pos->getSide(3), $delay, $type);
|
||||
$this->scheduleBlockUpdate($pos->getSide(4), $delay, $type);
|
||||
$this->scheduleBlockUpdate($pos->getSide(5), $delay, $type);
|
||||
}else{
|
||||
$this->blockUpdate($block->getSide(0), $type);
|
||||
$this->blockUpdate($block->getSide(1), $type);
|
||||
$this->blockUpdate($block->getSide(2), $type);
|
||||
$this->blockUpdate($block->getSide(3), $type);
|
||||
$this->blockUpdate($block->getSide(4), $type);
|
||||
$this->blockUpdate($block->getSide(5), $type);
|
||||
$this->blockUpdate($pos->getSide(0), $type);
|
||||
$this->blockUpdate($pos->getSide(1), $type);
|
||||
$this->blockUpdate($pos->getSide(2), $type);
|
||||
$this->blockUpdate($pos->getSide(3), $type);
|
||||
$this->blockUpdate($pos->getSide(4), $type);
|
||||
$this->blockUpdate($pos->getSide(5), $type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ class PocketMinecraftServer{
|
||||
|
||||
public function checkTicks(){
|
||||
if($this->getTPS() < 12){
|
||||
console("[WARNING] Can\'t keep up! Is the server overloaded?");
|
||||
console("[WARNING] Can't keep up! Is the server overloaded?");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ define("ENTITY_OBJECT", 3);
|
||||
|
||||
define("ENTITY_ITEM", 4);
|
||||
|
||||
define("ENTITY_FALLING", 4);
|
||||
define("ENTITY_FALLING", 5);
|
||||
define("FALLING_SAND", 66);
|
||||
|
||||
|
||||
|
@ -33,24 +33,7 @@ class FallableBlock extends SolidBlock{
|
||||
|
||||
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($this, BLOCK_UPDATE_NORMAL);
|
||||
ServerAPI::request()->api->block->blockUpdate(clone $this, BLOCK_UPDATE_NORMAL);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
if($this->getSide(0)->getID() === AIR){
|
||||
$data = array(
|
||||
"x" => $this->x + 0.5,
|
||||
"y" => $this->y + 0.5,
|
||||
"z" => $this->z + 0.5,
|
||||
"Tile" => $this->id,
|
||||
);
|
||||
$server = ServerAPI::request();
|
||||
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||
$e = $server->api->entity->add($this->level, ENTITY_FALLING, FALLING_SAND, $data);
|
||||
$server->api->entity->spawnToAll($this->level, $e->eid);
|
||||
return BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -39,14 +39,30 @@ class GenericBlock extends Block{
|
||||
}
|
||||
|
||||
public function onBreak(Item $item, Player $player){
|
||||
return $this->level->setBlock($this, new AirBlock());
|
||||
return $this->level->setBlock($this, new AirBlock(), true, false, true);
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
if($this->hasPhysics === true){
|
||||
if($this->getSide(0)->getID() === AIR){
|
||||
$data = array(
|
||||
"x" => $this->x + 0.5,
|
||||
"y" => $this->y + 0.5,
|
||||
"z" => $this->z + 0.5,
|
||||
"Tile" => $this->id,
|
||||
);
|
||||
$server = ServerAPI::request();
|
||||
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||
$e = $server->api->entity->add($this->level, ENTITY_FALLING, FALLING_SAND, $data);
|
||||
$server->api->entity->spawnToAll($this->level, $e->eid);
|
||||
$server->api->block->blockUpdateAround(clone $this, BLOCK_UPDATE_NORMAL, 1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
return ($this->isActivable);
|
||||
return $this->isActivable;
|
||||
}
|
||||
}
|
@ -415,7 +415,7 @@ class Entity extends Position{
|
||||
}
|
||||
|
||||
if($support === false){
|
||||
$this->speedY -= ($this->class === ENTITY_FALLING ? 16:32) * $tdiff;
|
||||
$this->speedY -= ($this->class === ENTITY_FALLING ? 18:32) * $tdiff;
|
||||
$update = true;
|
||||
}elseif($this->speedY <= 0.1){
|
||||
$this->speedX = 0;
|
||||
|
@ -216,15 +216,13 @@ class Level{
|
||||
"meta" => $block->getMetadata(),
|
||||
));
|
||||
}elseif($direct === false){
|
||||
if(!($block->level instanceof Level)){
|
||||
$block->position($pos);
|
||||
}
|
||||
$block->position($pos);
|
||||
$i = ($pos->x >> 4).":".($pos->y >> 4).":".($pos->z >> 4);
|
||||
if(!isset($this->changedBlocks[$i])){
|
||||
$this->changedBlocks[$i] = array();
|
||||
$this->changedCount[$i] = 0;
|
||||
}
|
||||
$this->changedBlocks[$i][] = $block;
|
||||
$this->changedBlocks[$i][] = clone $block;
|
||||
++$this->changedCount[$i];
|
||||
}
|
||||
}
|
||||
@ -241,9 +239,8 @@ class Level{
|
||||
if(!($pos instanceof Position)){
|
||||
$pos = new Position($pos->x, $pos->y, $pos->z, $this);
|
||||
}
|
||||
if(!($block->level instanceof Level)){
|
||||
$block->position($pos);
|
||||
}
|
||||
$block->position($pos);
|
||||
|
||||
if($direct === true){
|
||||
$this->server->api->player->broadcastPacket($this->players, MC_UPDATE_BLOCK, array(
|
||||
"x" => $pos->x,
|
||||
@ -258,12 +255,11 @@ class Level{
|
||||
$this->changedBlocks[$i] = array();
|
||||
$this->changedCount[$i] = 0;
|
||||
}
|
||||
$this->changedBlocks[$i][] = $block;
|
||||
$this->changedBlocks[$i][] = clone $block;
|
||||
++$this->changedCount[$i];
|
||||
}
|
||||
|
||||
if($update === true){
|
||||
|
||||
if($update === true){
|
||||
$this->server->api->block->blockUpdateAround($pos, BLOCK_UPDATE_NORMAL, 1);
|
||||
}
|
||||
if($tiles === true){
|
||||
|
Loading…
x
Reference in New Issue
Block a user