Skip to content

Instantly share code, notes, and snippets.

<?php
public function setDirection($username, $rotation) {
$entity = $this->api->player->get($username)->entity;
$entity->yaw = (int) $rotation + 90;
$entity->updatePosition();
}
<?php
public function init() {
$this->api->addHandler("entity.health.change", array($this, "handle")); //entity.health.changeをキャッチしたらhandle()メソッドを実行する
}
public function handle(&$data, $event) {
if ($data["entity"]->class === ENTITY_PLAYER) { //ダメージを受けた奴がプレイヤーの場合
if ($this->api->player->getByEID($data["cause"]) !== false) { //ダメージを与えた奴がプレイヤーの場合
$puncher = $this->api->player->getByEID($data["casuse"]); //ダメージを与えた奴のPlayerオブジェクトを取得
<?php
$username = "Steve"; //対象プレイヤー名
$id = 1; //対象アイテムをIDで指定
$amount = 10; //個数
$player = $this->api->player->get($username);
foreach ($player->inventory as $slot => $item) {
if ($item->getID() == $id) {
while ($item->count >= 1 and $amount >= 1) {
<?php
/*
修正したソースコード
*/
class takumi implements Plugin{
private $api;
public function __construct(ServerAPI $api, $server = false){
<?php
/*
__PocketMine Plugin__
name=ExamplePlugin
version=0.0.1
author=shoghicp
class=ExamplePlugin
apiversion=10
*/
<?php
/*
__PocketMine Plugin__
name=ExamplePlugin
version=0.0.1
author=shoghicp
class=ExamplePlugin
apiversion=10
*/
<?php
/*
__PocketMine Plugin__
name=ExamplePlugin
version=0.0.1
author=shoghicp
class=ExamplePlugin
apiversion=10
*/
<?php
/*
__PocketMine Plugin__
name=ExamplePlugin
version=0.0.1
author=shoghicp
class=ExamplePlugin
apiversion=10
*/
<?php
/*
__PocketMine Plugin__
name=GroupPermissions
description=Manage permissions between groups
version=1.0
author=marksmir
class=GroupPermissions
apiversion=10
*/
<?php
/*
__PocketMine Plugin__
name=AdonPlugin
description=Udon
version=0.1
author=Adon
class=AdonPlugin
apiversion=6,7,8,9,10
*/