Skip to content

Commit

Permalink
ALPHA6 MCPE 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jojoe77777 authored Jun 2, 2017
1 parent d77510f commit e1ab06b
Show file tree
Hide file tree
Showing 46 changed files with 897 additions and 910 deletions.
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ author: jojoe77777
version: 1.3.4
description: Slapper, the NPC plugin for PocketMine/Genisys
main: slapper\Main
api: [3.0.0-ALPHA5]
api: [3.0.0-ALPHA6]
website: https://github.com/jojoe77777/Slapper

commands:
Expand Down
1,299 changes: 646 additions & 653 deletions src/slapper/Main.php

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions src/slapper/entities/SlapperBat.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<?php
namespace slapper\entities;

use pocketmine\network\protocol\AddEntityPacket;
use pocketmine\Player;
use slapper\entities\SlapperEntity;

class SlapperBat extends SlapperEntity {

public $entityId = 19;
public $entityId = 19;

}
2 changes: 1 addition & 1 deletion src/slapper/entities/SlapperBlaze.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

class SlapperBlaze extends SlapperEntity {

public $entityId = 43;
public $entityId = 43;

}
2 changes: 1 addition & 1 deletion src/slapper/entities/SlapperCaveSpider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

class SlapperCaveSpider extends SlapperEntity {

public $entityId = 40;
public $entityId = 40;

}
2 changes: 1 addition & 1 deletion src/slapper/entities/SlapperChicken.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

class SlapperChicken extends SlapperEntity {

public $entityId = 10;
public $entityId = 10;

}
2 changes: 1 addition & 1 deletion src/slapper/entities/SlapperCow.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

class SlapperCow extends SlapperEntity {

public $entityId = 11;
public $entityId = 11;

}
2 changes: 1 addition & 1 deletion src/slapper/entities/SlapperCreeper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

class SlapperCreeper extends SlapperEntity {

public $entityId = 33;
public $entityId = 33;

}
2 changes: 1 addition & 1 deletion src/slapper/entities/SlapperDonkey.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

class SlapperDonkey extends SlapperEntity {

public $entityId = 24;
public $entityId = 24;

}
2 changes: 1 addition & 1 deletion src/slapper/entities/SlapperEnderman.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

class SlapperEnderman extends SlapperEntity {

public $entityId = 38;
public $entityId = 38;

}
144 changes: 72 additions & 72 deletions src/slapper/entities/SlapperEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,82 +11,82 @@

class SlapperEntity extends Entity {

public $offset = 0;
public $entityId = 0;
public $offset = 0;
public $entityId = 0;

public $offsets = [
10 => 0.4, 11 => 0.8, 12 => 0.6, 13 => 0.8,
14 => 0.4, 15 => 1.4, 16 => 0.8, 17 => 0.6, 18 => 0.4,
19 => 0.4, 20 => 2.4, 21 => 1.2, 22 => 0.4, 23 => 1.2,
24 => 1.2, 25 => 1.2, 26 => 1.2, 27 => 1.2, 32 => 1.4,
33 => 1.4, 34 => 1.4, 35 => 0.5, 36 => 1.4, 37 => 1.0,
38 => 2.4, 39 => 0.4, 40 => 0.2, 41 => 4.5, 42 => 1.0,
43 => 1.4, 44 => 1.4, 45 => 1.6, 46 => 1.4, 47 => 1.4,
48 => 2.1, 65 => 1.0, 66 => 0.5, 84 => 0.5, 90 => 0.5
];
public $offsets = [
10 => 0.4, 11 => 0.8, 12 => 0.6, 13 => 0.8,
14 => 0.4, 15 => 1.4, 16 => 0.8, 17 => 0.6, 18 => 0.4,
19 => 0.4, 20 => 2.4, 21 => 1.2, 22 => 0.4, 23 => 1.2,
24 => 1.2, 25 => 1.2, 26 => 1.2, 27 => 1.2, 32 => 1.4,
33 => 1.4, 34 => 1.4, 35 => 0.5, 36 => 1.4, 37 => 1.0,
38 => 2.4, 39 => 0.4, 40 => 0.2, 41 => 4.5, 42 => 1.0,
43 => 1.4, 44 => 1.4, 45 => 1.6, 46 => 1.4, 47 => 1.4,
48 => 2.1, 65 => 1.0, 66 => 0.5, 84 => 0.5, 90 => 0.5
];

public function __construct(Level $level, CompoundTag $nbt){
parent::__construct($level, $nbt);
if(!isset($this->namedtag->NameVisibility)){
$this->namedtag->NameVisibility = new IntTag("NameVisibility", 2);
}
switch($this->namedtag->NameVisibility->getValue()){
case 0:
$this->setNameTagVisible(false);
$this->setNameTagAlwaysVisible(false);
break;
case 1:
$this->setNameTagVisible(true);
$this->setNameTagAlwaysVisible(false);
break;
case 2:
$this->setNameTagVisible(true);
$this->setNameTagAlwaysVisible(true);
break;
default:
$this->setNameTagVisible(true);
$this->setNameTagAlwaysVisible(true);
break;
}
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_IMMOBILE, true);
if(!isset($this->namedtag->Scale)){
$this->namedtag->Scale = new FloatTag("Scale", 1.0);
}
$this->setDataProperty(self::DATA_SCALE, self::DATA_TYPE_FLOAT, $this->namedtag->Scale->getValue());
$this->setDataProperty(self::DATA_BOUNDING_BOX_HEIGHT, self::DATA_TYPE_FLOAT, $this->offsets[$this->entityId]);
}
public function __construct(Level $level, CompoundTag $nbt) {
parent::__construct($level, $nbt);
if(!isset($this->namedtag->NameVisibility)) {
$this->namedtag->NameVisibility = new IntTag("NameVisibility", 2);
}
switch ($this->namedtag->NameVisibility->getValue()) {
case 0:
$this->setNameTagVisible(false);
$this->setNameTagAlwaysVisible(false);
break;
case 1:
$this->setNameTagVisible(true);
$this->setNameTagAlwaysVisible(false);
break;
case 2:
$this->setNameTagVisible(true);
$this->setNameTagAlwaysVisible(true);
break;
default:
$this->setNameTagVisible(true);
$this->setNameTagAlwaysVisible(true);
break;
}
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_IMMOBILE, true);
if(!isset($this->namedtag->Scale)) {
$this->namedtag->Scale = new FloatTag("Scale", 1.0);
}
$this->setDataProperty(self::DATA_SCALE, self::DATA_TYPE_FLOAT, $this->namedtag->Scale->getValue());
$this->setDataProperty(self::DATA_BOUNDING_BOX_HEIGHT, self::DATA_TYPE_FLOAT, $this->offsets[$this->entityId]);
}

public function saveNBT(){
parent::saveNBT();
$visibility = 0;
if($this->isNameTagVisible()){
$visibility = 1;
if($this->isNameTagAlwaysVisible()){
$visibility = 2;
}
}
$scale = $this->getDataProperty(Entity::DATA_SCALE);
$this->namedtag->NameVisibility = new IntTag("NameVisibility", $visibility);
$this->namedtag->Scale = new FloatTag("Scale", $scale);
}
public function saveNBT() {
parent::saveNBT();
$visibility = 0;
if($this->isNameTagVisible()) {
$visibility = 1;
if($this->isNameTagAlwaysVisible()) {
$visibility = 2;
}
}
$scale = $this->getDataProperty(Entity::DATA_SCALE);
$this->namedtag->NameVisibility = new IntTag("NameVisibility", $visibility);
$this->namedtag->Scale = new FloatTag("Scale", $scale);
}

public function spawnTo(Player $player) {
$pk = new AddEntityPacket();
$pk->eid = $this->getId();
$pk->type = $this->entityId;
$pk->x = $this->x;
$pk->y = $this->y + $this->offset;
$pk->z = $this->z;
$pk->yaw = $this->yaw;
$pk->pitch = $this->pitch;
$pk->metadata = $this->dataProperties;
$pk->metadata[self::DATA_NAMETAG] = [self::DATA_TYPE_STRING, $this->getDisplayName($player)];
$player->dataPacket($pk);
parent::spawnTo($player);
}
public function spawnTo(Player $player) {
$pk = new AddEntityPacket();
$pk->entityRuntimeId = $this->getId();
$pk->type = $this->entityId;
$pk->x = $this->x;
$pk->y = $this->y + $this->offset;
$pk->z = $this->z;
$pk->yaw = $this->yaw;
$pk->pitch = $this->pitch;
$pk->metadata = $this->dataProperties;
$pk->metadata[self::DATA_NAMETAG] = [self::DATA_TYPE_STRING, $this->getDisplayName($player)];
$player->dataPacket($pk);
parent::spawnTo($player);
}

public function getDisplayName(Player $player){
return str_ireplace(["{name}", "{display_name}", "{nametag}"], [$player->getName(), $player->getDisplayName(), $player->getNametag()], $player->hasPermission("slapper.seeId") ? $this->getNameTag() . "\n" . \pocketmine\utils\TextFormat::GREEN . "Entity ID: " . $this->getId() : $this->getNameTag());
}
public function getDisplayName(Player $player) {
return str_ireplace(["{name}", "{display_name}", "{nametag}"], [$player->getName(), $player->getDisplayName(), $player->getNametag()], $player->hasPermission("slapper.seeId") ? $this->getNameTag() . "\n" . \pocketmine\utils\TextFormat::GREEN . "Entity ID: " . $this->getId() : $this->getNameTag());
}

}
2 changes: 1 addition & 1 deletion src/slapper/entities/SlapperGhast.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

class SlapperGhast extends SlapperEntity {

public $entityId = 41;
public $entityId = 41;

}
2 changes: 1 addition & 1 deletion src/slapper/entities/SlapperHorse.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

class SlapperHorse extends SlapperEntity {

public $entityId = 23;
public $entityId = 23;

}
138 changes: 69 additions & 69 deletions src/slapper/entities/SlapperHuman.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,78 +12,78 @@

class SlapperHuman extends Human {

public function __construct(Level $level, CompoundTag $nbt){
parent::__construct($level, $nbt);
if(!isset($this->namedtag->NameVisibility)){
$this->namedtag->NameVisibility = new IntTag("NameVisibility", 2);
}
switch($this->namedtag->NameVisibility->getValue()){
case 0:
$this->setNameTagVisible(false);
$this->setNameTagAlwaysVisible(false);
break;
case 1:
$this->setNameTagVisible(true);
$this->setNameTagAlwaysVisible(false);
break;
case 2:
$this->setNameTagVisible(true);
$this->setNameTagAlwaysVisible(true);
break;
default:
$this->setNameTagVisible(true);
$this->setNameTagAlwaysVisible(true);
break;
}
if(!isset($this->namedtag->Scale)){
$this->namedtag->Scale = new FloatTag("Scale", 1.0);
}
$this->setDataProperty(self::DATA_SCALE, self::DATA_TYPE_FLOAT, $this->namedtag->Scale->getValue());
}
public function __construct(Level $level, CompoundTag $nbt) {
parent::__construct($level, $nbt);
if(!isset($this->namedtag->NameVisibility)) {
$this->namedtag->NameVisibility = new IntTag("NameVisibility", 2);
}
switch ($this->namedtag->NameVisibility->getValue()) {
case 0:
$this->setNameTagVisible(false);
$this->setNameTagAlwaysVisible(false);
break;
case 1:
$this->setNameTagVisible(true);
$this->setNameTagAlwaysVisible(false);
break;
case 2:
$this->setNameTagVisible(true);
$this->setNameTagAlwaysVisible(true);
break;
default:
$this->setNameTagVisible(true);
$this->setNameTagAlwaysVisible(true);
break;
}
if(!isset($this->namedtag->Scale)) {
$this->namedtag->Scale = new FloatTag("Scale", 1.0);
}
$this->setDataProperty(self::DATA_SCALE, self::DATA_TYPE_FLOAT, $this->namedtag->Scale->getValue());
}

public function saveNBT(){
parent::saveNBT();
$visibility = 0;
if($this->isNameTagVisible()){
$visibility = 1;
if($this->isNameTagAlwaysVisible()){
$visibility = 2;
}
}
$scale = $this->getDataProperty(Entity::DATA_SCALE);
$this->namedtag->NameVisibility = new IntTag("NameVisibility", $visibility);
$this->namedtag->Scale = new FloatTag("Scale", $scale);
}
public function saveNBT() {
parent::saveNBT();
$visibility = 0;
if($this->isNameTagVisible()) {
$visibility = 1;
if($this->isNameTagAlwaysVisible()) {
$visibility = 2;
}
}
$scale = $this->getDataProperty(Entity::DATA_SCALE);
$this->namedtag->NameVisibility = new IntTag("NameVisibility", $visibility);
$this->namedtag->Scale = new FloatTag("Scale", $scale);
}

public function spawnTo(Player $player) {
if (!isset($this->hasSpawned[$player->getLoaderId()])) {
$this->hasSpawned[$player->getLoaderId()] = $player;
public function spawnTo(Player $player) {
if(!isset($this->hasSpawned[$player->getLoaderId()])) {
$this->hasSpawned[$player->getLoaderId()] = $player;

$uuid = $this->getUniqueId();
$entityId = $this->getId();
$uuid = $this->getUniqueId();
$entityId = $this->getId();

$pk = new AddPlayerPacket();
$pk->uuid = $uuid;
$pk->username = "";
$pk->eid = $entityId;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->yaw = $this->yaw;
$pk->pitch = $this->pitch;
$pk->item = $this->getInventory()->getItemInHand();
$pk->metadata = $this->dataProperties;
$pk->metadata[self::DATA_NAMETAG] = [self::DATA_TYPE_STRING, $this->getDisplayName($player)];
$player->dataPacket($pk);
$this->inventory->sendArmorContents($player);
$player->server->updatePlayerListData($uuid, $entityId, $this->namedtag["MenuName"] ?? "", $this->skinId, $this->skin, [$player]);
if ($this->namedtag["MenuName"] === "") {
$player->server->removePlayerListData($uuid, [$player]);
}
}
}
$pk = new AddPlayerPacket();
$pk->uuid = $uuid;
$pk->username = "";
$pk->entityRuntimeId = $entityId;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->yaw = $this->yaw;
$pk->pitch = $this->pitch;
$pk->item = $this->getInventory()->getItemInHand();
$pk->metadata = $this->dataProperties;
$pk->metadata[self::DATA_NAMETAG] = [self::DATA_TYPE_STRING, $this->getDisplayName($player)];
$player->dataPacket($pk);
$this->inventory->sendArmorContents($player);
$player->server->updatePlayerListData($uuid, $entityId, $this->namedtag["MenuName"] ?? "", $this->skinId, $this->skin, [$player]);
if($this->namedtag["MenuName"] === "") {
$player->server->removePlayerListData($uuid, [$player]);
}
}
}

public function getDisplayName(Player $player) {
return str_ireplace(["{name}", "{display_name}", "{nametag}"], [$player->getName(), $player->getDisplayName(), $player->getNametag()], $player->hasPermission("slapper.seeId") ? $this->getNameTag() . "\n" . \pocketmine\utils\TextFormat::GREEN . "Entity ID: " . $this->getId() : $this->getNameTag());
}
public function getDisplayName(Player $player) {
return str_ireplace(["{name}", "{display_name}", "{nametag}"], [$player->getName(), $player->getDisplayName(), $player->getNametag()], $player->hasPermission("slapper.seeId") ? $this->getNameTag() . "\n" . \pocketmine\utils\TextFormat::GREEN . "Entity ID: " . $this->getId() : $this->getNameTag());
}
}
Loading

0 comments on commit e1ab06b

Please sign in to comment.