mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +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"){
|
||||
$this->id = $id & 0xffff;
|
||||
$this->meta = $meta !== -1 ? $meta & 0xffff : -1;
|
||||
$this->setDamage($meta);
|
||||
$this->name = $name;
|
||||
if(!isset($this->block) and $this->id <= 0xff){
|
||||
$this->block = BlockFactory::get($this->id, $this->meta);
|
||||
@ -738,7 +738,7 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
* @return $this
|
||||
*/
|
||||
public function setDamage(int $meta){
|
||||
$this->meta = $meta !== -1 ? $meta & 0xFFFF : -1;
|
||||
$this->meta = $meta !== -1 ? $meta & 0x7FFF : -1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user