Merge commit '42e14f749'

# Conflicts:
#	resources/vanilla
#	src/pocketmine/Player.php
#	src/pocketmine/item/Bow.php
#	src/world/World.php
This commit is contained in:
Dylan K. Taylor 2020-06-03 12:31:17 +01:00
commit 899da1b7f7
4 changed files with 13 additions and 10 deletions

View File

@ -80,7 +80,7 @@ class Bow extends Tool{
}
$ev = new EntityShootBowEvent($player, $this, $entity, $baseForce * 3);
if($baseForce < 0.1 or $diff < 5){
if($baseForce < 0.1 or $diff < 5 or $player->isSpectator()){
$ev->setCancelled();
}

View File

@ -173,11 +173,6 @@ class InGamePacketHandler extends PacketHandler{
}
public function handleInventoryTransaction(InventoryTransactionPacket $packet) : bool{
if($this->player->isSpectator()){
$this->session->getInvManager()->syncAll();
return true;
}
$result = true;
if($packet->trData instanceof NormalTransactionData){

View File

@ -1451,7 +1451,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
$item = $this->inventory->getItemInHand();
$ev = new PlayerItemUseEvent($this, $item, $directionVector);
if($this->hasItemCooldown($item)){
if($this->hasItemCooldown($item) or $this->isSpectator()){
$ev->setCancelled();
}
@ -1630,7 +1630,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
public function breakBlock(Vector3 $pos) : bool{
$this->doCloseInventory();
if($this->canInteract($pos->add(0.5, 0.5, 0.5), $this->isCreative() ? 13 : 7) and !$this->isSpectator()){
if($this->canInteract($pos->add(0.5, 0.5, 0.5), $this->isCreative() ? 13 : 7)){
$this->broadcastAnimation(new ArmSwingAnimation($this), $this->getViewers());
$this->stopBreakBlock($pos);
$item = $this->inventory->getItemInHand();
@ -1655,7 +1655,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
public function interactBlock(Vector3 $pos, int $face, Vector3 $clickOffset) : bool{
$this->setUsingItem(false);
if($this->canInteract($pos->add(0.5, 0.5, 0.5), 13) and !$this->isSpectator()){
if($this->canInteract($pos->add(0.5, 0.5, 0.5), 13)){
$this->broadcastAnimation(new ArmSwingAnimation($this), $this->getViewers());
$item = $this->inventory->getItemInHand(); //this is a copy of the real item
$oldItem = clone $item;
@ -1690,7 +1690,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
$oldItem = clone $heldItem;
$ev = new EntityDamageByEntityEvent($this, $entity, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $heldItem->getAttackPoints());
if(!$this->canInteract($entity->getLocation(), 8) or ($entity instanceof Player and !$this->server->getConfigGroup()->getConfigBool("pvp"))){
if($this->isSpectator() or !$this->canInteract($entity->getLocation(), 8) or ($entity instanceof Player and !$this->server->getConfigGroup()->getConfigBool("pvp"))){
$ev->setCancelled();
}

View File

@ -1537,6 +1537,10 @@ class World implements ChunkManager{
if($player !== null){
$ev = new PlayerInteractEvent($player, $item, $blockClicked, $clickVector, $face, PlayerInteractEvent::RIGHT_CLICK_BLOCK);
if($player->isSpectator()){
$ev->setCancelled(); //set it to cancelled so plugins can bypass this
}
$ev->call();
if(!$ev->isCancelled()){
if((!$player->isSneaking() or $item->isNull()) and $blockClicked->onInteract($item, $face, $clickVector, $player)){
@ -1576,6 +1580,10 @@ class World implements ChunkManager{
if($player !== null){
$ev = new BlockPlaceEvent($player, $hand, $blockReplace, $blockClicked, $item);
if($player->isSpectator()){
$ev->setCancelled();
}
if($player->isAdventure(true) and !$ev->isCancelled()){
$canPlace = false;
$itemParser = LegacyStringToItemParser::getInstance();