Fixed block placing in creative mode

This commit is contained in:
Shoghi Cervantes 2014-06-16 00:19:46 +02:00
parent 40bf7fd22a
commit e1c0976927

View File

@ -1142,7 +1142,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$nbt["lastPlayed"] = floor(microtime(true) * 1000); $nbt["lastPlayed"] = floor(microtime(true) * 1000);
$this->server->saveOfflinePlayerData($this->username, $nbt); $this->server->saveOfflinePlayerData($this->username, $nbt);
parent::__construct($this->getLevel()->getChunkAt($nbt["Pos"][0], $nbt["Pos"][2], true), $nbt); parent::__construct($this->getLevel()->getChunkAt($nbt["Pos"][0], $nbt["Pos"][2], true), $nbt);
$this->inventory->setHeldItemSlot($this->getCreativeBlock(Item::get(Item::STONE, 0, 1)));
$this->loggedIn = true; $this->loggedIn = true;
if(($this->gamemode & 0x01) === 0x01){ if(($this->gamemode & 0x01) === 0x01){
@ -1150,6 +1149,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->hotbar[0] = 0; $this->hotbar[0] = 0;
}else{ }else{
$this->slot = $this->hotbar[0]; $this->slot = $this->hotbar[0];
$this->inventory->setItemInHand(Item::get(Item::STONE, 0, 1));
} }
$this->server->getPluginManager()->callEvent($ev = new PlayerLoginEvent($this, "Plugin reason")); $this->server->getPluginManager()->callEvent($ev = new PlayerLoginEvent($this, "Plugin reason"));
@ -1282,6 +1282,13 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
if(!isset($item) or $packet->slot === -1){ if(!isset($item) or $packet->slot === -1){
$this->inventory->sendSlot($packet->slot, $this); $this->inventory->sendSlot($packet->slot, $this);
}elseif(($this->gamemode & 0x01) === Player::CREATIVE){
$item = Item::get(
Block::$creative[$packet->slot][0],
Block::$creative[$packet->slot][1],
1
);
$this->inventory->setItemInHand($item);
}else{ }else{
$this->inventory->setHeldItemSlot($packet->slot); $this->inventory->setHeldItemSlot($packet->slot);
} }
@ -1331,11 +1338,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
if($blockVector->distance($this) > 10){ if($blockVector->distance($this) > 10){
}elseif(($this->gamemode & 0x01) === 1){ }elseif(($this->gamemode & 0x01) === 1){
$item = Item::get( $item = $this->inventory->getItemInHand();
Block::$creative[$this->inventory->getHeldItemSlot()][0],
Block::$creative[$this->inventory->getHeldItemSlot()][1],
1
);
if($this->getLevel()->useItemOn($blockVector, $item, $packet->face, $packet->fx, $packet->fy, $packet->fz, $this) === true){ if($this->getLevel()->useItemOn($blockVector, $item, $packet->face, $packet->fx, $packet->fy, $packet->fz, $this) === true){
break; break;
} }
@ -1463,11 +1466,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
if(($this->gamemode & 0x01) === 1){ if(($this->gamemode & 0x01) === 1){
$item = Item::get( $item = $this->inventory->getItemInHand();
Block::$creative[$this->inventory->getHeldItemSlot()][0],
Block::$creative[$this->inventory->getHeldItemSlot()][1],
1
);
}else{ }else{
$item = clone $this->inventory->getItemInHand(); $item = clone $this->inventory->getItemInHand();
} }