Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Tungst_geo;
- use pocketmine\plugin\PluginBase;
- use pocketmine\Player;
- use pocketmine\Server;
- use pocketmine\event\Listener;
- use pocketmine\command\Command;
- use pocketmine\command\CommandSender;
- use pocketmine\event\Event;
- use pocketmine\event\player\PlayerJoinEvent;
- use pocketmine\entity\Skin;
- use pocketmine\utils\TextFormat as C;
- use pocketmine\entity\Entity;
- use pocketmine\math\Vector3;
- use pocketmine\entity\Human;
- use pocketmine\nbt\tag\CompoundTag;
- use pocketmine\nbt\tag\StringTag;
- use pocketmine\nbt\tag\ListTag;
- use pocketmine\nbt\tag\NamedTag;
- use pocketmine\nbt\tag\DoubleTag;
- use pocketmine\nbt\tag\ShortTag;
- use pocketmine\nbt\ReaderTracker;
- use pocketmine\nbt\NBTStream;
- use tungst_geo\EntityZ;
- class Main extends PluginBase implements Listener {
- public function onEnable(){
- $this->getLogger()->info("How to play enable");
- $this->getServer()->getPluginManager()->registerEvents($this, $this);
- Entity::registerEntity(EntityZ::class, true,["EnityZ",EntityZ::class]);
- }
- public function onCommand(CommandSender $sender, Command $command, String $label, array $args) : bool {
- if($sender instanceof Player){
- switch(strtolower($command->getName())){
- case "a":
- $this->skin($sender);
- break;
- case "npc":
- $this->createnpc($sender);
- break;
- }
- }else{
- };
- return true;
- }
- public function createnpc($sen){//$sen is sender from onCommand
- $skin = $sen->getSkin();
- $path = $this->getDataFolder() . "poop.png";
- $img = @imagecreatefrompng($path);
- $skinbytes = "";
- $s = (int)@getimagesize($path)[1];
- for($y = 0; $y < $s; $y++){
- for($x = 0; $x < 64; $x++){
- $colorat = @imagecolorat($img, $x, $y);
- $a = ((~((int)($colorat >> 24))) << 1) & 0xff;
- $r = ($colorat >> 16) & 0xff;
- $g = ($colorat >> 8) & 0xff;
- $b = $colorat & 0xff;
- $skinbytes .= chr($r) . chr($g) . chr($b) . chr($a);
- }
- }
- @imagedestroy($img);
- $player = $sen;
- $nbt = Entity::createBaseNBT($sen, null, $sen->getYaw(), $sen->getPitch());
- $skinTag = $sen->namedtag->getCompoundTag("Skin");
- assert($skinTag !== null);
- $nbt->setTag(clone $skinTag);
- $npc = Entity::createEntity("EntityZ",$sen->getLevel(),$nbt);
- $npc->setSkin(new Skin("nothing", $skinbytes, "", "geometry.poop", file_get_contents($this->getDataFolder() . "poop.json")));
- $npc->sendSkin();
- $npc->setScale(0.5);
- $npc->spawnToAll();
- }
- public function skin($player){
- $skin = $player->getSkin();
- $path = $this->getDataFolder() . "texture.png";
- $img = @imagecreatefrompng($path);
- $skinbytes = "";
- $s = (int)@getimagesize($path)[1];
- for($y = 0; $y < $s; $y++){
- for($x = 0; $x < 64; $x++){
- $colorat = @imagecolorat($img, $x, $y);
- $a = ((~((int)($colorat >> 24))) << 1) & 0xff;
- $r = ($colorat >> 16) & 0xff;
- $g = ($colorat >> 8) & 0xff;
- $b = $colorat & 0xff;
- $skinbytes .= chr($r) . chr($g) . chr($b) . chr($a);
- }
- }
- @imagedestroy($img);
- $player->setSkin(new Skin($skin->getSkinId(), $skin->getSkinData(),@imagecreatefrompng("texture.png"), $skin->getGeometryName(), $skin->getGeometryData()));
- $player->sendSkin();
- //$player->sendMessage("ok");
- }
- }
- <?php
- namespace Tungst_geo;
- use pocketmine\entity\Human;
- use pocketmine\level\Level;
- use pocketmine\nbt\tag\CompoundTag;
- use pocketmine\Server;
- use pocketmine\network\mcpe\protocol\EntityEventPacket;
- class EntityZ extends Human{
- public function entityBaseTick(int $tickDiff = 1) : bool{
- print("Hi");
- return parent::entityBaseTick($tickDiff);
- }
- public function getName(): string{
- return "EntityZ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement