mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-23 19:34:15 +00:00
Fixed mirrored chunk sending
This commit is contained in:
parent
643a4c1ef5
commit
6b361389ad
@ -1212,6 +1212,9 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
if(($this->gamemode & 0x01) === 0x01){
|
if(($this->gamemode & 0x01) === 0x01){
|
||||||
$this->inventory->setHeldItemSlot(0);
|
$this->inventory->setHeldItemSlot(0);
|
||||||
$this->inventory->setItemInHand(Item::get(Item::STONE, 0, 1));
|
$this->inventory->setItemInHand(Item::get(Item::STONE, 0, 1));
|
||||||
|
}else{
|
||||||
|
$this->inventory->setHeldItemSlot(0);
|
||||||
|
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
$pk = new LoginStatusPacket;
|
$pk = new LoginStatusPacket;
|
||||||
@ -1516,8 +1519,11 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->inventory->sendContents($this);
|
||||||
$target = $this->getLevel()->getBlock($vector);
|
$target = $this->getLevel()->getBlock($vector);
|
||||||
$tile = $this->getLevel()->getTile($vector);
|
$tile = $this->getLevel()->getTile($vector);
|
||||||
|
|
||||||
$pk = new UpdateBlockPacket;
|
$pk = new UpdateBlockPacket;
|
||||||
$pk->x = $target->x;
|
$pk->x = $target->x;
|
||||||
$pk->y = $target->y;
|
$pk->y = $target->y;
|
||||||
@ -1525,7 +1531,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
$pk->block = $target->getID();
|
$pk->block = $target->getID();
|
||||||
$pk->meta = $target->getDamage();
|
$pk->meta = $target->getDamage();
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
//TODO: priority
|
|
||||||
if($tile instanceof Spawnable){
|
if($tile instanceof Spawnable){
|
||||||
$tile->spawnTo($this);
|
$tile->spawnTo($this);
|
||||||
}
|
}
|
||||||
@ -1538,18 +1544,18 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
for($i = 0; $i < 4; ++$i){
|
for($i = 0; $i < 4; ++$i){
|
||||||
$s = $packet->slots[$i];
|
$s = $packet->slots[$i];
|
||||||
if($s === 0 or $s === 255){
|
if($s === 0 or $s === 255){
|
||||||
$s = Item::get(Item::AIR, 0, 0);
|
$s = Item::get(Item::AIR, 0, 1);
|
||||||
}else{
|
}else{
|
||||||
$s = Item::get($s + 256, 0, 1);
|
$s = Item::get($s + 256, 0, 1);
|
||||||
}
|
}
|
||||||
$slot = $this->inventory->getArmorItem($i);
|
$slot = $this->inventory->getArmorItem($i);
|
||||||
if($slot->getID() !== Item::AIR and $s->getID() === Item::AIR){
|
if($slot->getID() !== Item::AIR and $s->getID() === Item::AIR){
|
||||||
$this->inventory->setArmorItem($i, Item::get(Item::AIR, 0, 0));
|
$this->inventory->setArmorItem($i, Item::get(Item::AIR, 0, 1));
|
||||||
}elseif($s->getID() !== Item::AIR and $slot->getID() === Item::AIR and ($sl = $this->inventory->first($s)) !== -1){
|
}elseif($s->getID() !== Item::AIR and $slot->getID() === Item::AIR and ($sl = $this->inventory->first($s)) !== -1){
|
||||||
if($this->inventory->setArmorItem($i, $this->inventory->getItem($sl)) === false){
|
if($this->inventory->setArmorItem($i, $this->inventory->getItem($sl)) === false){
|
||||||
$this->inventory->sendContents($this);
|
$this->inventory->sendContents($this);
|
||||||
}else{
|
}else{
|
||||||
$this->inventory->setItem($sl, Item::get(Item::AIR, 0, 0));
|
$this->inventory->setItem($sl, Item::get(Item::AIR, 0, 1));
|
||||||
}
|
}
|
||||||
}elseif($s->getID() !== Item::AIR and $slot->getID() !== Item::AIR and ($slot->getID() !== $s->getID() or $slot->getDamage() !== $s->getDamage()) and ($sl = $this->inventory->first($s)) !== -1){
|
}elseif($s->getID() !== Item::AIR and $slot->getID() !== Item::AIR and ($slot->getID() !== $s->getID() or $slot->getDamage() !== $s->getDamage()) and ($sl = $this->inventory->first($s)) !== -1){
|
||||||
if($this->inventory->setArmorItem($i, $this->inventory->getItem($sl)) === false){
|
if($this->inventory->setArmorItem($i, $this->inventory->getItem($sl)) === false){
|
||||||
@ -1647,7 +1653,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
$target->harm($damage, $this->id);
|
$target->harm($damage, $this->id);
|
||||||
if($slot->isTool() === true and ($this->gamemode & 0x01) === 0){
|
if($slot->isTool() === true and ($this->gamemode & 0x01) === 0){
|
||||||
if($slot->useOn($target) and $slot->getDamage() >= $slot->getMaxDurability()){
|
if($slot->useOn($target) and $slot->getDamage() >= $slot->getMaxDurability()){
|
||||||
$this->setSlot($this->getCurrentEquipment(), new Item(AIR, 0, 0));
|
$this->setSlot($this->getCurrentEquipment(), new Item(AIR, 0, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1765,7 +1771,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0));
|
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1));
|
||||||
$motion = $this->getDirectionVector()->multiply(10);
|
$motion = $this->getDirectionVector()->multiply(10);
|
||||||
|
|
||||||
$this->getLevel()->dropItem($this->add(0, 1, 0), $item, $motion);
|
$this->getLevel()->dropItem($this->add(0, 1, 0), $item, $motion);
|
||||||
|
@ -750,9 +750,9 @@ abstract class Block extends Position implements Metadatable{
|
|||||||
if(!isset(self::$list[$this->id])){ //Unknown blocks
|
if(!isset(self::$list[$this->id])){ //Unknown blocks
|
||||||
return [];
|
return [];
|
||||||
}else{
|
}else{
|
||||||
return array(
|
return [
|
||||||
array($this->id, $this->meta, 1),
|
array($this->id, $this->meta, 1),
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ class Grass extends Solid{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
return array(
|
return [
|
||||||
array(Item::DIRT, 0, 1),
|
[Item::DIRT, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
|
@ -100,8 +100,8 @@ class ChunkRequestTask extends AsyncTask{
|
|||||||
$orderedSkyLight = "";
|
$orderedSkyLight = "";
|
||||||
$orderedLight = "";
|
$orderedLight = "";
|
||||||
|
|
||||||
for($z = 0; $z < 16; ++$z){
|
for($x = 0; $x < 16; ++$x){
|
||||||
for($x = 0; $x < 16; ++$x){
|
for($z = 0; $z < 16; ++$z){
|
||||||
$orderedIds .= $this->getColumn($this->ids, $x, $z);
|
$orderedIds .= $this->getColumn($this->ids, $x, $z);
|
||||||
$orderedData .= $this->getHalfColumn($this->meta, $x, $z);
|
$orderedData .= $this->getHalfColumn($this->meta, $x, $z);
|
||||||
$orderedSkyLight .= $this->getHalfColumn($this->skyLight, $x, $z);
|
$orderedSkyLight .= $this->getHalfColumn($this->skyLight, $x, $z);
|
||||||
|
@ -767,12 +767,11 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$ev = new BlockBreakEvent($player, $target, $item, ($player->getGamemode() & 0x01) === 1 ? true : false);
|
$ev = new BlockBreakEvent($player, $target, $item, ($player->getGamemode() & 0x01) === 1 ? true : false);
|
||||||
|
|
||||||
$lastTime = $player->lastBreak - 0.1; //TODO: replace with true lag
|
$lastTime = $player->lastBreak - 0.1; //TODO: replace with true lag
|
||||||
if(($player->getGamemode() & 0x01)){
|
if(($player->getGamemode() & 0x01) > 0){
|
||||||
$ev->setInstaBreak(true);
|
$ev->setInstaBreak(true);
|
||||||
}elseif(($lastTime + $target->getBreakTime($item)) >= microtime(true)){
|
}elseif(($lastTime + $target->getBreakTime($item)) >= microtime(true)){
|
||||||
$ev->setCancelled(true);
|
$ev->setCancelled();
|
||||||
}
|
}
|
||||||
$player->lastBreak = microtime(true);
|
|
||||||
|
|
||||||
if($item instanceof Item and !$target->isBreakable($item) and $ev->getInstaBreak() === false){
|
if($item instanceof Item and !$target->isBreakable($item) and $ev->getInstaBreak() === false){
|
||||||
$ev->setCancelled();
|
$ev->setCancelled();
|
||||||
@ -788,6 +787,9 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
if($ev->isCancelled()){
|
if($ev->isCancelled()){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$player->lastBreak = microtime(true);
|
||||||
|
|
||||||
}elseif($item instanceof Item and !$target->isBreakable($item)){
|
}elseif($item instanceof Item and !$target->isBreakable($item)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user