mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
More changes!
This commit is contained in:
parent
99df6f8edc
commit
fabb632286
@ -32,6 +32,10 @@ class Attribute{
|
||||
|
||||
const MAX_HEALTH = 0;
|
||||
|
||||
|
||||
const EXPERIENCE = 1;
|
||||
const EXPERIENCE_LEVEL = 2;
|
||||
|
||||
private $id;
|
||||
protected $minValue;
|
||||
protected $maxValue;
|
||||
@ -45,6 +49,8 @@ class Attribute{
|
||||
|
||||
public static function init(){
|
||||
self::addAttribute(self::MAX_HEALTH, "generic.health", 0, 0x7fffffff, 20, true);
|
||||
self::addAttribute(self::EXPERIENCE, "player.experience", 0, 1, 0, true);
|
||||
self::addAttribute(self::EXPERIENCE_LEVEL, "player.level", 0, 24791, 0, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -155,6 +155,8 @@ class Enchantment{
|
||||
|
||||
public function setLevel($level){
|
||||
$this->level = (int) $level;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
55
src/pocketmine/item/enchantment/EnchantmentEntry.php
Normal file
55
src/pocketmine/item/enchantment/EnchantmentEntry.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\item\enchantment;
|
||||
|
||||
|
||||
class EnchantmentEntry{
|
||||
|
||||
/** @var Enchantment[] */
|
||||
private $enchantments;
|
||||
private $cost;
|
||||
private $randomName;
|
||||
|
||||
/**
|
||||
* @param Enchantment[] $enchantments
|
||||
* @param $cost
|
||||
* @param $randomName
|
||||
*/
|
||||
public function __construct(array $enchantments, $cost, $randomName){
|
||||
$this->enchantments = $enchantments;
|
||||
$this->cost = (int) $cost;
|
||||
$this->randomName = $randomName;
|
||||
}
|
||||
|
||||
public function getEnchantments(){
|
||||
return $this->enchantments;
|
||||
}
|
||||
|
||||
public function getCost(){
|
||||
return $this->cost;
|
||||
}
|
||||
|
||||
public function getRandomName(){
|
||||
return $this->randomName;
|
||||
}
|
||||
|
||||
}
|
54
src/pocketmine/item/enchantment/EnchantmentList.php
Normal file
54
src/pocketmine/item/enchantment/EnchantmentList.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\item\enchantment;
|
||||
|
||||
|
||||
class EnchantmentList{
|
||||
|
||||
/** @var EnchantmentEntry[] */
|
||||
private $enchantments;
|
||||
|
||||
public function __construct($size){
|
||||
$this->enchantments = new \SplFixedArray($size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $slot
|
||||
* @param EnchantmentEntry $entry
|
||||
*/
|
||||
public function setSlot($slot, EnchantmentEntry $entry){
|
||||
$this->enchantments[$slot] = $entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $slot
|
||||
* @return EnchantmentEntry
|
||||
*/
|
||||
public function getSlot($slot){
|
||||
return $this->enchantments[$slot];
|
||||
}
|
||||
|
||||
public function getSize(){
|
||||
return $this->enchantments->getSize();
|
||||
}
|
||||
|
||||
}
|
@ -27,6 +27,8 @@ namespace pocketmine\network\protocol;
|
||||
use pocketmine\inventory\FurnaceRecipe;
|
||||
use pocketmine\inventory\ShapedRecipe;
|
||||
use pocketmine\inventory\ShapelessRecipe;
|
||||
use pocketmine\item\enchantment\Enchantment;
|
||||
use pocketmine\item\enchantment\EnchantmentList;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
|
||||
class CraftingDataPacket extends DataPacket{
|
||||
@ -36,7 +38,7 @@ class CraftingDataPacket extends DataPacket{
|
||||
const ENTRY_SHAPED = 1;
|
||||
const ENTRY_FURNACE = 2;
|
||||
const ENTRY_FURNACE_DATA = 3;
|
||||
const ENTRY_ENCHANT = 4;
|
||||
const ENTRY_ENCHANT_LIST = 4;
|
||||
|
||||
/** @var object[] */
|
||||
public $entries = [];
|
||||
@ -49,6 +51,8 @@ class CraftingDataPacket extends DataPacket{
|
||||
return self::writeShapedRecipe($entry, $stream);
|
||||
}elseif($entry instanceof FurnaceRecipe){
|
||||
return self::writeFurnaceRecipe($entry, $stream);
|
||||
}elseif($entry instanceof EnchantmentList){
|
||||
return self::writeEnchantList($entry, $stream);
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -100,16 +104,21 @@ class CraftingDataPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
private static function writeEnchant($slot, $enchantmentId, $enchantmentLevel, $cost, $name, BinaryStream $stream){
|
||||
//TODO
|
||||
private static function writeEnchantList(EnchantmentList $list, BinaryStream $stream){
|
||||
|
||||
$stream->putInt($slot);
|
||||
$stream->putInt($enchantmentId);
|
||||
$stream->putInt($enchantmentLevel);
|
||||
$stream->putInt($cost);
|
||||
$stream->putString($name);
|
||||
$stream->putByte($list->getSize());
|
||||
for($i = 0; $i < $list->getSize(); ++$i){
|
||||
$entry = $list->getSlot($i);
|
||||
$stream->putInt($entry->getCost());
|
||||
$stream->putByte(count($entry->getEnchantments()));
|
||||
foreach($entry->getEnchantments() as $enchantment){
|
||||
$stream->putInt($enchantment->getId());
|
||||
$stream->putInt($enchantment->getLevel());
|
||||
}
|
||||
$stream->putString($entry->getRandomName());
|
||||
}
|
||||
|
||||
return CraftingDataPacket::ENTRY_ENCHANT;
|
||||
return CraftingDataPacket::ENTRY_ENCHANT_LIST;
|
||||
}
|
||||
|
||||
public function addShapelessRecipe(ShapelessRecipe $recipe){
|
||||
@ -124,8 +133,8 @@ class CraftingDataPacket extends DataPacket{
|
||||
$this->entries[] = $recipe;
|
||||
}
|
||||
|
||||
public function addEnchant(){
|
||||
//TODO
|
||||
public function addEnchantList(EnchantmentList $list){
|
||||
$this->entries[] = $list;
|
||||
}
|
||||
|
||||
public function clean(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user