My problem is that I have a code that should spawn an entityHuman but my code doesn't. I have a command that does that but nothing works and no error appears. PHP: public function __construct(string $name, string $description = "", string $usageMessage = null, $aliases = [], array $overloads = null){ parent::__construct($name, $description, $usageMessage, $aliases, $overloads);}public function execute(CommandSender $sender, string $commandLabel, array $args){ if ($sender instanceof Player){ if ($sender->isOp()){ if (isset($args[0])){ if ($args[0] == "create"){ if (isset($args[1])) { Slapper::getInstance()->createSlapper($sender/*, $args[1]*/); $sender->sendMessage(TextFormat::DARK_GREEN."Slapper gespawnt"); } } } } } return true;} PHP: public function createSlapper(Player $player){ $nbt = new CompoundTag(); $nbt->setTag(new ListTag("Pos", [ new DoubleTag("", $player->getX()), new DoubleTag("", $player->getY()), new DoubleTag("", $player->getZ()) ])); $nbt->setTag(new ListTag("Motion", [ new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0) ])); $nbt->setTag(new ListTag("Rotation", [ new FloatTag("", $player->getYaw()), new FloatTag("", $player->getPitch()) ])); $nbt->setTag(new ShortTag("Health", 20)); $nbt->setTag(new CompoundTag("Skin", [ "Data" => new StringTag("Data", $player->getSkin()->getSkinData()), "Name" => new StringTag("Name", $player->getSkin()->getSkinId()) ])); $human = new Human($player->getLevel(), $nbt); $human->setNameTag($player->getNameTag()); $human->setNameTagVisible(false); $human->spawnToAll(); $player->getLevel()->addEntity($human);}
Reasons could be you aren’t op, you aren’t a player or args[0] is create Other reason could be you didn’t register command
I would try: PHP: $slapper = $this->getServer()->getPluginManager()->getPlugin("Slapper");$nbt = $slapper->makeNBT("Human", $sender, "Slapper");$entity = Entity::createEntity("SlapperHuman", $sender->getLevel(), $nbt);$entity->spawnToAll(); Didn’t tried but should work if doesn’t add slapper event I think
Are you sure the plugin is loaded? Every time I did something wrong with a plugin with commands and the plugin did not load, the commands were registered but not calling onCommand or something.