mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-14 07:25:31 +00:00
Restrict item meta values to max signed short value, closes #1101
This commit is contained in:
parent
f7ee78233b
commit
7dc5dc3a9f
@ -200,7 +200,7 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
*/
|
*/
|
||||||
public function __construct(int $id, int $meta = 0, string $name = "Unknown"){
|
public function __construct(int $id, int $meta = 0, string $name = "Unknown"){
|
||||||
$this->id = $id & 0xffff;
|
$this->id = $id & 0xffff;
|
||||||
$this->meta = $meta !== -1 ? $meta & 0xffff : -1;
|
$this->setDamage($meta);
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
if(!isset($this->block) and $this->id <= 0xff){
|
if(!isset($this->block) and $this->id <= 0xff){
|
||||||
$this->block = BlockFactory::get($this->id, $this->meta);
|
$this->block = BlockFactory::get($this->id, $this->meta);
|
||||||
@ -738,7 +738,7 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setDamage(int $meta){
|
public function setDamage(int $meta){
|
||||||
$this->meta = $meta !== -1 ? $meta & 0xFFFF : -1;
|
$this->meta = $meta !== -1 ? $meta & 0x7FFF : -1;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user