mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 22:45:28 +00:00
Fixed items being consumed on CREATIVE mode
This commit is contained in:
parent
6fa0ef652e
commit
9d1369bfe9
@ -266,10 +266,11 @@ class BlockAPI{
|
|||||||
$player->lastBreak = microtime(true);
|
$player->lastBreak = microtime(true);
|
||||||
|
|
||||||
if($this->server->api->dhandle("player.block.break", array("player" => $player, "target" => $target, "item" => $item)) !== false){
|
if($this->server->api->dhandle("player.block.break", array("player" => $player, "target" => $target, "item" => $item)) !== false){
|
||||||
$drops = $target->getDrops($item, $player);
|
|
||||||
if($target->onBreak($item, $player) === false){
|
if($target->onBreak($item, $player) === false){
|
||||||
return $this->cancelAction($target, $player, false);
|
return $this->cancelAction($target, $player, false);
|
||||||
}
|
}
|
||||||
|
$item->useOn($target);
|
||||||
|
$drops = $target->getDrops($item, $player);
|
||||||
}else{
|
}else{
|
||||||
return $this->cancelAction($target, $player, false);
|
return $this->cancelAction($target, $player, false);
|
||||||
}
|
}
|
||||||
|
@ -365,13 +365,19 @@ class Player{
|
|||||||
return;
|
return;
|
||||||
$s = (int) $s;
|
$s = (int) $s;
|
||||||
if(!isset($this->inventory[$s])){
|
if(!isset($this->inventory[$s])){
|
||||||
return false;
|
$this->dataPacket(MC_CONTAINER_SET_SLOT, array(
|
||||||
|
"windowid" => 0,
|
||||||
|
"slot" => (int) $s,
|
||||||
|
"block" => AIR,
|
||||||
|
"stack" => 0,
|
||||||
|
"meta" => 0,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$slot = $this->inventory[$s];
|
$slot = $this->inventory[$s];
|
||||||
$this->dataPacket(MC_CONTAINER_SET_SLOT, array(
|
$this->dataPacket(MC_CONTAINER_SET_SLOT, array(
|
||||||
"windowid" => 0,
|
"windowid" => 0,
|
||||||
"slot" => ((int) $s) + 9,
|
"slot" => (int) $s,
|
||||||
"block" => $slot->getID(),
|
"block" => $slot->getID(),
|
||||||
"stack" => $slot->count,
|
"stack" => $slot->count,
|
||||||
"meta" => $slot->getMetadata(),
|
"meta" => $slot->getMetadata(),
|
||||||
@ -1349,7 +1355,7 @@ class Player{
|
|||||||
$damage = 1;//$this->server->difficulty;
|
$damage = 1;//$this->server->difficulty;
|
||||||
}
|
}
|
||||||
$target->harm($damage, $this->eid);
|
$target->harm($damage, $this->eid);
|
||||||
if($slot->isTool() === true){
|
if($slot->isTool() === true and ($this->gamemode & 0x01) === 0){
|
||||||
$slot->useOn($target);
|
$slot->useOn($target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1630,7 +1636,7 @@ class Player{
|
|||||||
$this->dataPacket(MC_CONTAINER_SET_CONTENT, array(
|
$this->dataPacket(MC_CONTAINER_SET_CONTENT, array(
|
||||||
"windowid" => 0,
|
"windowid" => 0,
|
||||||
"count" => count($this->inventory),
|
"count" => count($this->inventory),
|
||||||
"slots" => $this->inventory
|
"slots" => $this->inventory,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,9 @@ class MelonStemBlock extends FlowableBlock{
|
|||||||
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);
|
||||||
$item->count--;
|
if(($player->gamemode & 0x01) === 0){
|
||||||
|
$item->count--;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -55,7 +55,9 @@ class SaplingBlock 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
|
||||||
TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x03);
|
TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x03);
|
||||||
$item->count--;
|
if(($player->gamemode & 0x01) === 0){
|
||||||
|
$item->count--;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -45,7 +45,9 @@ class WheatBlock extends FlowableBlock{
|
|||||||
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);
|
||||||
$item->count--;
|
if(($player->gamemode & 0x01) === 0){
|
||||||
|
$item->count--;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -33,7 +33,9 @@ class DirtBlock extends SolidBlock{
|
|||||||
|
|
||||||
public function onActivate(Item $item, Player $player){
|
public function onActivate(Item $item, Player $player){
|
||||||
if($item->isHoe()){
|
if($item->isHoe()){
|
||||||
$item->useOn($this);
|
if(($this->gamemode & 0x01) === 0){
|
||||||
|
$item->useOn($this);
|
||||||
|
}
|
||||||
$this->level->setBlock($this, BlockAPI::get(FARMLAND, 0));
|
$this->level->setBlock($this, BlockAPI::get(FARMLAND, 0));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,15 @@ class GrassBlock extends SolidBlock{
|
|||||||
|
|
||||||
public function onActivate(Item $item, Player $player){
|
public function onActivate(Item $item, Player $player){
|
||||||
if($item->getID() === DYE and $item->getMetadata() === 0x0F){
|
if($item->getID() === DYE and $item->getMetadata() === 0x0F){
|
||||||
$item->count--;
|
if(($player->gamemode & 0x01) === 0){
|
||||||
|
$item->count--;
|
||||||
|
}
|
||||||
TallGrassObject::growGrass($this->level, $this, new Random());
|
TallGrassObject::growGrass($this->level, $this, new Random());
|
||||||
return true;
|
return true;
|
||||||
}elseif($item->isHoe()){
|
}elseif($item->isHoe()){
|
||||||
$item->useOn($this);
|
if(($this->gamemode & 0x01) === 0){
|
||||||
|
$item->useOn($this);
|
||||||
|
}
|
||||||
$this->level->setBlock($this, new FarmlandBlock());
|
$this->level->setBlock($this, new FarmlandBlock());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user