mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 20:49:43 +00:00
interact event fixed
This commit is contained in:
parent
6bc20a0a02
commit
834bb3d486
2 changed files with 9 additions and 6 deletions
|
|
@ -1794,7 +1794,11 @@ class Player{
|
||||||
$this->toCraft = [];
|
$this->toCraft = [];
|
||||||
$target = $this->server->api->entity->get($packet->target);
|
$target = $this->server->api->entity->get($packet->target);
|
||||||
if($target instanceof Entity and $this->entity instanceof Entity and $this->gamemode !== VIEW and $this->blocked === false and ($target instanceof Entity) and $this->entity->distance($target) <= 8){
|
if($target instanceof Entity and $this->entity instanceof Entity and $this->gamemode !== VIEW and $this->blocked === false and ($target instanceof Entity) and $this->entity->distance($target) <= 8){
|
||||||
$target->interactWith($this->entity, $packet->action);
|
$data["targetentity"] = $packet->target;
|
||||||
|
$data["entity"] = $this;
|
||||||
|
if($this->server->handle("player.interact", $data) !== false){
|
||||||
|
$target->interactWith($this->entity, $packet->action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -2385,4 +2389,4 @@ class PlayerNull extends Player{
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -762,9 +762,8 @@ class Entity extends Position
|
||||||
if($this->class === ENTITY_PLAYER and ($this->server->api->getProperty("pvp") == false or $this->server->difficulty <= 0 or ($e->player->gamemode & 0x01) === 0x01)){
|
if($this->class === ENTITY_PLAYER and ($this->server->api->getProperty("pvp") == false or $this->server->difficulty <= 0 or ($e->player->gamemode & 0x01) === 0x01)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$data["targetentity"] = $this;
|
|
||||||
$data["entity"] = $e;
|
if($action === InteractPacket::ACTION_ATTACK && $e->isPlayer()){
|
||||||
if($this->server->handle("player.interact", $data) !== false && $action === InteractPacket::ACTION_ATTACK && $e->isPlayer()){
|
|
||||||
$slot = $e->player->getHeldItem();
|
$slot = $e->player->getHeldItem();
|
||||||
$damage = $slot->getDamageAgainstOf($e);
|
$damage = $slot->getDamageAgainstOf($e);
|
||||||
$this->harm($damage, $e->eid);
|
$this->harm($damage, $e->eid);
|
||||||
|
|
@ -1411,4 +1410,4 @@ class Entity extends Position
|
||||||
{
|
{
|
||||||
throw new Exception("Use getHeight or getWidth method instead of this.");
|
throw new Exception("Use getHeight or getWidth method instead of this.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue