mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 05:55:33 +00:00
Fixed tool metadata [partial]
This commit is contained in:
parent
e9683ff5d2
commit
3463db04a6
@ -1171,7 +1171,7 @@ class Player{
|
|||||||
$this->entity->updateMetadata();
|
$this->entity->updateMetadata();
|
||||||
}
|
}
|
||||||
if($this->blocked === true or Utils::distance($this->entity->position, $data) > 10){
|
if($this->blocked === true or Utils::distance($this->entity->position, $data) > 10){
|
||||||
}elseif($this->getSlot($this->slot)->getID() !== $data["block"] or $this->getSlot($this->slot)->getMetadata() !== $data["meta"]){
|
}elseif($this->getSlot($this->slot)->getID() !== $data["block"] or ($this->getSlot($this->slot)->isTool() === false and $this->getSlot($this->slot)->getMetadata() !== $data["meta"])){
|
||||||
$this->sendInventorySlot($this->slot);
|
$this->sendInventorySlot($this->slot);
|
||||||
}else{
|
}else{
|
||||||
$this->server->api->block->playerBlockAction($this, new Vector3($data["x"], $data["y"], $data["z"]), $data["face"], $data["fx"], $data["fy"], $data["fz"]);
|
$this->server->api->block->playerBlockAction($this, new Vector3($data["x"], $data["y"], $data["z"]), $data["face"], $data["fx"], $data["fy"], $data["fz"]);
|
||||||
@ -1287,7 +1287,8 @@ class Player{
|
|||||||
}elseif($target->class === ENTITY_PLAYER and ($this->server->api->getProperty("pvp") == false or $this->server->difficulty <= 0 or ($target->player->gamemode & 0x01) === 0x01)){
|
}elseif($target->class === ENTITY_PLAYER and ($this->server->api->getProperty("pvp") == false or $this->server->difficulty <= 0 or ($target->player->gamemode & 0x01) === 0x01)){
|
||||||
break;
|
break;
|
||||||
}elseif($this->server->handle("player.interact", $data) !== false){
|
}elseif($this->server->handle("player.interact", $data) !== false){
|
||||||
switch($this->getSlot($this->slot)->getID()){
|
$slot = $this->getSlot($this->slot);
|
||||||
|
switch($slot->getID()){
|
||||||
case WOODEN_SWORD:
|
case WOODEN_SWORD:
|
||||||
case GOLD_SWORD:
|
case GOLD_SWORD:
|
||||||
$damage = 4;
|
$damage = 4;
|
||||||
@ -1348,6 +1349,11 @@ class Player{
|
|||||||
$damage = 1;//$this->server->difficulty;
|
$damage = 1;//$this->server->difficulty;
|
||||||
}
|
}
|
||||||
$this->server->api->entity->harm($data["target"], $damage, $this->eid);
|
$this->server->api->entity->harm($data["target"], $damage, $this->eid);
|
||||||
|
if($slot->isSword() !== false){
|
||||||
|
$slot->meta++;
|
||||||
|
}elseif($slot->isTool() === true){
|
||||||
|
$slot->meta += 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1407,7 +1413,8 @@ class Player{
|
|||||||
RAW_FISH => 2,
|
RAW_FISH => 2,
|
||||||
|
|
||||||
);
|
);
|
||||||
if($this->entity->getHealth() < 20 and isset($items[($slot = $this->getSlot($this->slot))->getID()])){
|
$slot = $this->getSlot($this->slot);
|
||||||
|
if($this->entity->getHealth() < 20 and isset($items[$slot->getID()])){
|
||||||
$this->dataPacket(MC_ENTITY_EVENT, array(
|
$this->dataPacket(MC_ENTITY_EVENT, array(
|
||||||
"eid" => 0,
|
"eid" => 0,
|
||||||
"event" => 9,
|
"event" => 9,
|
||||||
|
@ -131,6 +131,10 @@ class Item{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final public function isTool(){
|
||||||
|
return ($this->isPickaxe !== false or $this->isAxe !== false or $this->isShovel !== false or $this->isSword !== false or $this->isHoe !== false);
|
||||||
|
}
|
||||||
|
|
||||||
final public function isPickaxe(){ //Returns false or level of the pickaxe
|
final public function isPickaxe(){ //Returns false or level of the pickaxe
|
||||||
switch($this->id){
|
switch($this->id){
|
||||||
case IRON_PICKAXE:
|
case IRON_PICKAXE:
|
||||||
@ -148,6 +152,40 @@ class Item{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final public function isAxe(){
|
||||||
|
switch($this->id){
|
||||||
|
case IRON_AXE:
|
||||||
|
return 4;
|
||||||
|
case WOODEN_AXE:
|
||||||
|
return 1;
|
||||||
|
case STONE_AXE:
|
||||||
|
return 3;
|
||||||
|
case DIAMOND_AXE:
|
||||||
|
return 5;
|
||||||
|
case GOLD_AXE:
|
||||||
|
return 2;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function isSword(){
|
||||||
|
switch($this->id){
|
||||||
|
case IRON_SWORD:
|
||||||
|
return 4;
|
||||||
|
case WOODEN_SWORD:
|
||||||
|
return 1;
|
||||||
|
case STONE_SWORD:
|
||||||
|
return 3;
|
||||||
|
case DIAMOND_SWORD:
|
||||||
|
return 5;
|
||||||
|
case GOLD_SWORD:
|
||||||
|
return 2;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final public function isShovel(){
|
final public function isShovel(){
|
||||||
switch($this->id){
|
switch($this->id){
|
||||||
case IRON_SHOVEL:
|
case IRON_SHOVEL:
|
||||||
|
@ -33,6 +33,7 @@ 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->meta++;
|
||||||
$this->level->setBlock($this, BlockAPI::get(FARMLAND, 0));
|
$this->level->setBlock($this, BlockAPI::get(FARMLAND, 0));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ class GrassBlock extends SolidBlock{
|
|||||||
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->meta++;
|
||||||
$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