本文整理汇总了PHP中BukkitPE\item\Item::getCreativeItemIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::getCreativeItemIndex方法的具体用法?PHP Item::getCreativeItemIndex怎么用?PHP Item::getCreativeItemIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BukkitPE\item\Item
的用法示例。
在下文中一共展示了Item::getCreativeItemIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleDataPacket
//.........这里部分代码省略.........
}
if ($this->teleportPosition !== null or $this->forceMovement instanceof Vector3 and (($dist = $newPos->distanceSquared($this->forceMovement)) > 0.1 or $revert)) {
if ($this->forceMovement instanceof Vector3) {
$this->sendPosition($this->forceMovement, $packet->yaw, $packet->pitch);
}
} else {
$packet->yaw %= 360;
$packet->pitch %= 360;
if ($packet->yaw < 0) {
$packet->yaw += 360;
}
$this->setRotation($packet->yaw, $packet->pitch);
$this->newPosition = $newPos;
$this->forceMovement = null;
}
break;
case ProtocolInfo::MOB_EQUIPMENT_PACKET:
if ($this->spawned === false or !$this->isAlive()) {
break;
}
if ($packet->slot === 0x28 or $packet->slot === 0 or $packet->slot === 255) {
//0 for 0.8.0 compatibility
$packet->slot = -1;
//Air
} else {
$packet->slot -= 9;
//Get real block slot
}
/** @var Item $item */
$item = null;
if ($this->isCreative()) {
//Creative mode match
$item = $packet->item;
$slot = Item::getCreativeItemIndex($item);
} else {
$item = $this->inventory->getItem($packet->slot);
$slot = $packet->slot;
}
if ($packet->slot === -1) {
//Air
if ($this->isCreative()) {
$found = false;
for ($i = 0; $i < $this->inventory->getHotbarSize(); ++$i) {
if ($this->inventory->getHotbarSlotIndex($i) === -1) {
$this->inventory->setHeldItemIndex($i);
$found = true;
break;
}
}
if (!$found) {
//couldn't find a empty slot (error)
$this->inventory->sendContents($this);
break;
}
} else {
if ($packet->selectedSlot >= 0 and $packet->selectedSlot < 9) {
$this->inventory->setHeldItemIndex($packet->selectedSlot);
$this->inventory->setHeldItemSlot($packet->slot);
} else {
$this->inventory->sendContents($this);
break;
}
}
} elseif ($item === null or $slot === -1 or !$item->deepEquals($packet->item)) {
// packet error or not implemented
$this->inventory->sendContents($this);