GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
Item Class Reference

Public Member Functions

 canBeActivated ()
 
 __construct (int $id, int $meta=0, int $count=1, string $name="Unknown")
 
 setCompoundTag ($tags)
 
 getCompoundTag ()
 
 hasCompoundTag ()
 
 hasCustomBlockData ()
 
 clearCustomBlockData ()
 
 setCustomBlockData (CompoundTag $compound)
 
 getCustomBlockData ()
 
 hasEnchantments ()
 
 getEnchantment (int $id)
 
 hasEnchantment (int $id, int $level=1, bool $compareLevel=false)
 
 getEnchantmentLevel (int $id)
 
 addEnchantment (Enchantment $ench)
 
 getEnchantments ()
 
 hasRepairCost ()
 
 getRepairCost ()
 
 setRepairCost (int $cost)
 
 clearRepairCost ()
 
 hasCustomName ()
 
 getCustomName ()
 
 setCustomName (string $name)
 
 clearCustomName ()
 
 getLore ()
 
 setLore (array $lines)
 
 getNamedTagEntry ($name)
 
 getNamedTag ()
 
 setNamedTag (CompoundTag $tag)
 
 clearNamedTag ()
 
 getCount ()
 
 setCount (int $count)
 
 getName ()
 
 canBePlaced ()
 
 isPlaceable ()
 
 canBeConsumed ()
 
 canBeConsumedBy (Entity $entity)
 
 onConsume (Entity $entity)
 
 getBlock ()
 
 getId ()
 
 getDamage ()
 
 setDamage (int $meta)
 
 hasAnyDamageValue ()
 
 getMaxStackSize ()
 
 getFuelTime ()
 
 useOn ($object)
 
 isTool ()
 
 getMaxDurability ()
 
 isPickaxe ()
 
 isAxe ()
 
 isSword ()
 
 isShovel ()
 
 isHoe ()
 
 isShears ()
 
 isArmor ()
 
 getArmorValue ()
 
 isBoots ()
 
 isHelmet ()
 
 isLeggings ()
 
 isChestplate ()
 
 getAttackDamage ()
 
 getModifyAttackDamage (Entity $target)
 
 getDestroySpeed (Block $block, Player $player)
 
 onActivate (Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 
 equals (Item $item, bool $checkDamage=true, bool $checkCompound=true, $checkCount=false)
 
 __toString ()
 
 jsonSerialize ()
 
 nbtSerialize (int $slot=-1, string $tagName="")
 

Static Public Member Functions

static init ($readFromJson=false)
 
static clearCreativeItems ()
 
static getCreativeItems ()
 
static addCreativeItem (Item $item)
 
static removeCreativeItem (Item $item)
 
static isCreativeItem (Item $item)
 
static getCreativeItem (int $index)
 
static getCreativeItemIndex (Item $item)
 
static get (int $id, int $meta=0, int $count=1, string $tags="")
 
static fromString (string $str, bool $multiple=false)
 
static nbtDeserialize (CompoundTag $tag)
 

Data Fields

 $count
 
- Data Fields inherited from ItemIds
const IRON_SHOVEL = 256
 
const IRON_PICKAXE = 257
 
const IRON_AXE = 258
 
const FLINT_AND_STEEL = 259
 
const FLINT_STEEL = 259
 
const APPLE = 260
 
const BOW = 261
 
const ARROW = 262
 
const COAL = 263
 
const DIAMOND = 264
 
const IRON_INGOT = 265
 
const GOLD_INGOT = 266
 
const IRON_SWORD = 267
 
const WOODEN_SWORD = 268
 
const WOODEN_SHOVEL = 269
 
const WOODEN_PICKAXE = 270
 
const WOODEN_AXE = 271
 
const STONE_SWORD = 272
 
const STONE_SHOVEL = 273
 
const STONE_PICKAXE = 274
 
const STONE_AXE = 275
 
const DIAMOND_SWORD = 276
 
const DIAMOND_SHOVEL = 277
 
const DIAMOND_PICKAXE = 278
 
const DIAMOND_AXE = 279
 
const STICK = 280
 
const STICKS = 280
 
const BOWL = 281
 
const MUSHROOM_STEW = 282
 
const GOLD_SWORD = 283
 
const GOLDEN_SWORD = 283
 
const GOLD_SHOVEL = 284
 
const GOLDEN_SHOVEL = 284
 
const GOLD_PICKAXE = 285
 
const GOLDEN_PICKAXE = 285
 
const GOLD_AXE = 286
 
const GOLDEN_AXE = 286
 
const STRING = 287
 
const FEATHER = 288
 
const GUNPOWDER = 289
 
const WOODEN_HOE = 290
 
const STONE_HOE = 291
 
const IRON_HOE = 292
 
const DIAMOND_HOE = 293
 
const GOLD_HOE = 294
 
const GOLDEN_HOE = 294
 
const SEEDS = 295
 
const WHEAT_SEEDS = 295
 
const WHEAT = 296
 
const BREAD = 297
 
const LEATHER_CAP = 298
 
const LEATHER_TUNIC = 299
 
const LEATHER_PANTS = 300
 
const LEATHER_BOOTS = 301
 
const CHAIN_HELMET = 302
 
const CHAIN_CHESTPLATE = 303
 
const CHAIN_LEGGINGS = 304
 
const CHAIN_BOOTS = 305
 
const IRON_HELMET = 306
 
const IRON_CHESTPLATE = 307
 
const IRON_LEGGINGS = 308
 
const IRON_BOOTS = 309
 
const DIAMOND_HELMET = 310
 
const DIAMOND_CHESTPLATE = 311
 
const DIAMOND_LEGGINGS = 312
 
const DIAMOND_BOOTS = 313
 
const GOLD_HELMET = 314
 
const GOLD_CHESTPLATE = 315
 
const GOLD_LEGGINGS = 316
 
const GOLD_BOOTS = 317
 
const FLINT = 318
 
const RAW_PORKCHOP = 319
 
const COOKED_PORKCHOP = 320
 
const PAINTING = 321
 
const GOLDEN_APPLE = 322
 
const SIGN = 323
 
const WOODEN_DOOR = 324
 
const OAK_DOOR = 324
 
const BUCKET = 325
 
const MINECART = 328
 
const SADDLE = 329
 
const IRON_DOOR = 330
 
const REDSTONE = 331
 
const REDSTONE_DUST = 331
 
const SNOWBALL = 332
 
const BOAT = 333
 
const LEATHER = 334
 
const BRICK = 336
 
const CLAY = 337
 
const SUGARCANE = 338
 
const SUGAR_CANE = 338
 
const SUGAR_CANES = 338
 
const PAPER = 339
 
const BOOK = 340
 
const SLIMEBALL = 341
 
const MINECART_WITH_CHEST = 342
 
const EGG = 344
 
const COMPASS = 345
 
const FISHING_ROD = 346
 
const CLOCK = 347
 
const GLOWSTONE_DUST = 348
 
const RAW_FISH = 349
 
const COOKED_FISH = 350
 
const DYE = 351
 
const BONE = 352
 
const SUGAR = 353
 
const CAKE = 354
 
const BED = 355
 
const REPEATER = 356
 
const COOKIE = 357
 
const FILLED_MAP = 358
 
const SHEARS = 359
 
const MELON = 360
 
const MELON_SLICE = 360
 
const PUMPKIN_SEEDS = 361
 
const MELON_SEEDS = 362
 
const RAW_BEEF = 363
 
const STEAK = 364
 
const COOKED_BEEF = 364
 
const RAW_CHICKEN = 365
 
const COOKED_CHICKEN = 366
 
const ROTTEN_FLESH = 367
 
const ENDER_PEARL = 368
 
const BLAZE_ROD = 369
 
const GHAST_TEAR = 370
 
const GOLD_NUGGET = 371
 
const GOLDEN_NUGGET = 371
 
const NETHER_WART = 372
 
const POTION = 373
 
const GLASS_BOTTLE = 374
 
const SPIDER_EYE = 375
 
const FERMENTED_SPIDER_EYE = 376
 
const BLAZE_POWDER = 377
 
const MAGMA_CREAM = 378
 
const BREWING_STAND = 379
 
const CAULDRON = 380
 
const EYE_OF_ENDER = 381
 
const GLISTERING_MELON = 382
 
const SPAWN_EGG = 383
 
const BOTTLE_O_ENCHANTING = 384
 
const ENCHANTING_BOTTLE = 384
 
const FIRE_CHARGE = 385
 
const EMERALD = 388
 
const ITEM_FRAME = 389
 
const FLOWER_POT = 390
 
const CARROT = 391
 
const CARROTS = 391
 
const POTATO = 392
 
const POTATOES = 392
 
const BAKED_POTATO = 393
 
const BAKED_POTATOES = 393
 
const POISONOUS_POTATO = 394
 
const MAP = 395
 
const EMPTY_MAP = 395
 
const GOLDEN_CARROT = 396
 
const MOB_HEAD = 397
 
const SKULL = 397
 
const CARROT_ON_A_STICK = 398
 
const NETHER_STAR = 399
 
const PUMPKIN_PIE = 400
 
const ENCHANTED_BOOK = 403
 
const COMPARATOR = 404
 
const NETHER_BRICK = 405
 
const QUARTZ = 406
 
const NETHER_QUARTZ = 406
 
const MINECART_WITH_TNT = 407
 
const MINECART_WITH_HOPPER = 408
 
const PRISMARINE_SHARD = 409
 
const HOPPER = 410
 
const RAW_RABBIT = 411
 
const COOKED_RABBIT = 412
 
const RABBIT_STEW = 413
 
const RABBIT_FOOT = 414
 
const RABBIT_HIDE = 415
 
const LEATHER_HORSE_ARMOR = 416
 
const IRON_HORSE_ARMOR = 417
 
const GOLD_HORSE_ARMOR = 418
 
const DIAMOND_HORSE_ARMOR = 419
 
const LEAD = 420
 
const LEASH = 420
 
const NAMETAG = 421
 
const PRISMARINE_CRYSTALS = 422
 
const RAW_MUTTON = 423
 
const COOKED_MUTTON = 424
 
const SPRUCE_DOOR = 427
 
const BIRCH_DOOR = 428
 
const JUNGLE_DOOR = 429
 
const ACACIA_DOOR = 430
 
const DARK_OAK_DOOR = 431
 
const CHORUS_FRUIT = 432
 
const POPPED_CHORUS_FRUIT = 433
 
const DRAGONS_BREATH = 437
 
const SPLASH_POTION = 438
 
const ELYTRA = 444
 
const ELYTRA_WINGS = 444
 
const SHULKER_SHELL = 445
 
const TOTEM = 450
 
const BEETROOT = 457
 
const BEETROOT_SEEDS = 458
 
const BEETROOT_SEED = 458
 
const BEETROOT_SOUP = 459
 
const RAW_SALMON = 460
 
const CLOWN_FISH = 461
 
const PUFFER_FISH = 462
 
const COOKED_SALMON = 463
 
const ENCHANTED_GOLDEN_APPLE = 466
 
const CAMERA = 498
 
- Data Fields inherited from BlockIds
const AIR = 0
 
const STONE = 1
 
const GRASS = 2
 
const DIRT = 3
 
const COBBLESTONE = 4
 
const COBBLE = 4
 
const PLANK = 5
 
const PLANKS = 5
 
const WOODEN_PLANK = 5
 
const WOODEN_PLANKS = 5
 
const SAPLING = 6
 
const SAPLINGS = 6
 
const BEDROCK = 7
 
const WATER = 8
 
const STILL_WATER = 9
 
const LAVA = 10
 
const STILL_LAVA = 11
 
const SAND = 12
 
const GRAVEL = 13
 
const GOLD_ORE = 14
 
const IRON_ORE = 15
 
const COAL_ORE = 16
 
const LOG = 17
 
const WOOD = 17
 
const TRUNK = 17
 
const LEAVES = 18
 
const SPONGE = 19
 
const GLASS = 20
 
const LAPIS_ORE = 21
 
const LAPIS_BLOCK = 22
 
const DISPENSER = 23
 
const SANDSTONE = 24
 
const NOTEBLOCK = 25
 
const BED_BLOCK = 26
 
const POWERED_RAIL = 27
 
const DETECTOR_RAIL = 28
 
const STICKY_PISTON = 29
 
const COBWEB = 30
 
const TALL_GRASS = 31
 
const BUSH = 32
 
const DEAD_BUSH = 32
 
const PISTON = 33
 
const PISTON_HEAD = 34
 
const WOOL = 35
 
const DANDELION = 37
 
const POPPY = 38
 
const ROSE = 38
 
const RED_FLOWER = 38
 
const BROWN_MUSHROOM = 39
 
const RED_MUSHROOM = 40
 
const GOLD_BLOCK = 41
 
const IRON_BLOCK = 42
 
const DOUBLE_SLAB = 43
 
const DOUBLE_SLABS = 43
 
const SLAB = 44
 
const SLABS = 44
 
const STONE_SLAB = 44
 
const BRICKS = 45
 
const BRICKS_BLOCK = 45
 
const TNT = 46
 
const BOOKSHELF = 47
 
const MOSS_STONE = 48
 
const MOSSY_STONE = 48
 
const OBSIDIAN = 49
 
const TORCH = 50
 
const FIRE = 51
 
const MONSTER_SPAWNER = 52
 
const WOOD_STAIRS = 53
 
const WOODEN_STAIRS = 53
 
const OAK_WOOD_STAIRS = 53
 
const OAK_WOODEN_STAIRS = 53
 
const CHEST = 54
 
const REDSTONE_WIRE = 55
 
const DIAMOND_ORE = 56
 
const DIAMOND_BLOCK = 57
 
const CRAFTING_TABLE = 58
 
const WORKBENCH = 58
 
const WHEAT_BLOCK = 59
 
const FARMLAND = 60
 
const FURNACE = 61
 
const BURNING_FURNACE = 62
 
const LIT_FURNACE = 62
 
const SIGN_POST = 63
 
const DOOR_BLOCK = 64
 
const WOODEN_DOOR_BLOCK = 64
 
const WOOD_DOOR_BLOCK = 64
 
const LADDER = 65
 
const RAIL = 66
 
const COBBLESTONE_STAIRS = 67
 
const COBBLE_STAIRS = 67
 
const WALL_SIGN = 68
 
const LEVER = 69
 
const STONE_PRESSURE_PLATE = 70
 
const IRON_DOOR_BLOCK = 71
 
const WOODEN_PRESSURE_PLATE = 72
 
const REDSTONE_ORE = 73
 
const GLOWING_REDSTONE_ORE = 74
 
const UNLIT_REDSTONE_TORCH = 75
 
const REDSTONE_TORCH = 76
 
const LIT_REDSTONE_TORCH = 76
 
const STONE_BUTTON = 77
 
const SNOW = 78
 
const SNOW_LAYER = 78
 
const ICE = 79
 
const SNOW_BLOCK = 80
 
const CACTUS = 81
 
const CLAY_BLOCK = 82
 
const REEDS = 83
 
const SUGARCANE_BLOCK = 83
 
const FENCE = 85
 
const PUMPKIN = 86
 
const NETHERRACK = 87
 
const SOUL_SAND = 88
 
const GLOWSTONE = 89
 
const GLOWSTONE_BLOCK = 89
 
const PORTAL_BLOCK = 90
 
const PORTAL = 90
 
const JACK_O_LANTERN = 91
 
const LIT_PUMPKIN = 91
 
const CAKE_BLOCK = 92
 
const UNPOWERED_REPEATER_BLOCK = 93
 
const POWERED_REPEATER_BLOCK = 94
 
const INVISIBLE_BEDROCK = 95
 
const TRAPDOOR = 96
 
const WOODEN_TRAPDOOR = 96
 
const MONSTER_EGG_BLOCK = 97
 
const STONE_BRICKS = 98
 
const STONE_BRICK = 98
 
const BROWN_MUSHROOM_BLOCK = 99
 
const RED_MUSHROOM_BLOCK = 100
 
const IRON_BARS = 101
 
const IRON_BAR = 101
 
const GLASS_PANE = 102
 
const GLASS_PANEL = 102
 
const MELON_BLOCK = 103
 
const PUMPKIN_STEM = 104
 
const MELON_STEM = 105
 
const VINES = 106
 
const VINE = 106
 
const FENCE_GATE = 107
 
const OAK_FENCE_GATE = 107
 
const BRICK_STAIRS = 108
 
const STONE_BRICK_STAIRS = 109
 
const MYCELIUM = 110
 
const LILY_PAD = 111
 
const WATER_LILY = 111
 
const NETHER_BRICKS = 112
 
const NETHER_BRICK_BLOCK = 112
 
const NETHER_BRICK_FENCE = 113
 
const NETHER_BRICK_STAIRS = 114
 
const NETHER_BRICKS_STAIRS = 114
 
const NETHER_WART_BLOCK = 115
 
const ENCHANTING_TABLE = 116
 
const ENCHANT_TABLE = 116
 
const ENCHANTMENT_TABLE = 116
 
const BREWING_STAND_BLOCK = 117
 
const CAULDRON_BLOCK = 118
 
const END_PORTAL = 119
 
const END_PORTAL_FRAME = 120
 
const END_STONE = 121
 
const DRAGON_EGG = 122
 
const REDSTONE_LAMP = 123
 
const INACTIVE_REDSTONE_LAMP = 123
 
const LIT_REDSTONE_LAMP = 124
 
const ACTIVE_REDSTONE_LAMP = 124
 
const DROPPER = 125
 
const ACTIVATOR_RAIL = 126
 
const COCOA_BLOCK = 127
 
const COCOA_PODS = 127
 
const SANDSTONE_STAIRS = 128
 
const EMERALD_ORE = 129
 
const ENDER_CHEST = 130
 
const TRIPWIRE_HOOK = 131
 
const TRIPWIRE = 132
 
const EMERALD_BLOCK = 133
 
const SPRUCE_WOOD_STAIRS = 134
 
const SPRUCE_WOODEN_STAIRS = 134
 
const BIRCH_WOOD_STAIRS = 135
 
const BIRCH_WOODEN_STAIRS = 135
 
const JUNGLE_WOOD_STAIRS = 136
 
const JUNGLE_WOODEN_STAIRS = 136
 
const COMMAND_BLOCK = 137
 
const BEACON = 138
 
const COBBLESTONE_WALL = 139
 
const COBBLE_WALL = 139
 
const STONE_WALL = 139
 
const FLOWER_POT_BLOCK = 140
 
const CARROT_BLOCK = 141
 
const POTATO_BLOCK = 142
 
const WOODEN_BUTTON = 143
 
const MOB_HEAD_BLOCK = 144
 
const SKULL_BLOCK = 144
 
const ANVIL = 145
 
const TRAPPED_CHEST = 146
 
const WEIGHTED_PRESSURE_PLATE_LIGHT = 147
 
const LIGHT_WEIGHTED_PRESSURE_PLATE = 147
 
const GOLD_PRESSURE_PLATE = 147
 
const WEIGHTED_PRESSURE_PLATE_HEAVY = 148
 
const HEAVY_WEIGHTED_PRESSURE_PLATE = 148
 
const IRON_PRESSURE_PLATE = 148
 
const COMPARATOR_BLOCK = 149
 
const UNPOWERED_COMPARATOR_BLOCK = 149
 
const POWERED_COMPARATOR_BLOCK = 150
 
const DAYLIGHT_SENSOR = 151
 
const REDSTONE_BLOCK = 152
 
const NETHER_QUARTZ_ORE = 153
 
const HOPPER_BLOCK = 154
 
const QUARTZ_BLOCK = 155
 
const QUARTZ_STAIRS = 156
 
const DOUBLE_WOOD_SLAB = 157
 
const DOUBLE_WOODEN_SLAB = 157
 
const DOUBLE_WOOD_SLABS = 157
 
const DOUBLE_WOODEN_SLABS = 157
 
const WOOD_SLAB = 158
 
const WOODEN_SLAB = 158
 
const WOOD_SLABS = 158
 
const WOODEN_SLABS = 158
 
const STAINED_CLAY = 159
 
const STAINED_HARDENED_CLAY = 159
 
const STAINED_GLASS_PANE = 160
 
const STAINED_GLASS_PANEL = 160
 
const LEAVES2 = 161
 
const WOOD2 = 162
 
const TRUNK2 = 162
 
const LOG2 = 162
 
const ACACIA_WOOD_STAIRS = 163
 
const ACACIA_WOODEN_STAIRS = 163
 
const DARK_OAK_WOOD_STAIRS = 164
 
const DARK_OAK_WOODEN_STAIRS = 164
 
const SLIME_BLOCK = 165
 
const IRON_TRAPDOOR = 167
 
const PRISMARINE = 168
 
const SEA_LANTERN = 169
 
const HAY_BALE = 170
 
const CARPET = 171
 
const HARDENED_CLAY = 172
 
const COAL_BLOCK = 173
 
const PACKED_ICE = 174
 
const DOUBLE_PLANT = 175
 
const INVERTED_DAYLIGHT_SENSOR = 178
 
const DAYLIGHT_SENSOR_INVERTED = 178
 
const RED_SANDSTONE = 179
 
const RED_SANDSTONE_STAIRS = 180
 
const DOUBLE_RED_SANDSTONE_SLAB = 181
 
const DOUBLE_PURPUR_SLAB = 181
 
const RED_SANDSTONE_SLAB = 182
 
const PURPUR_SLAB = 182
 
const SPRUCE_FENCE_GATE = 183
 
const FENCE_GATE_SPRUCE = 183
 
const BIRCH_FENCE_GATE = 184
 
const FENCE_GATE_BIRCH = 184
 
const JUNGLE_FENCE_GATE = 185
 
const FENCE_GATE_JUNGLE = 185
 
const DARK_OAK_FENCE_GATE = 186
 
const FENCE_GATE_DARK_OAK = 186
 
const ACACIA_FENCE_GATE = 187
 
const FENCE_GATE_ACACIA = 187
 
const REPEATING_COMMAND_BLOCK = 188
 
const CHAIN_COMMAND_BLOCK = 189
 
const SPRUCE_DOOR_BLOCK = 193
 
const BIRCH_DOOR_BLOCK = 194
 
const JUNGLE_DOOR_BLOCK = 195
 
const ACACIA_DOOR_BLOCK = 196
 
const DARK_OAK_DOOR_BLOCK = 197
 
const GRASS_PATH = 198
 
const ITEM_FRAME_BLOCK = 199
 
const CHORUS_FLOWER = 200
 
const PURPUR = 201
 
const PURPUR_STAIRS = 203
 
const END_STONE_BRICKS = 206
 
const FROSTED_ICE = 207
 
const END_ROD = 208
 
const SHULKER_BOX = 218
 
const PURPLE_GLAZED_TERRACOTTA = 219
 
const WHITE_GLAZED_TERRACOTTA = 220
 
const ORANGE_GLAZED_TERRACOTTA = 221
 
const MAGENTA_GLAZED_TERRACOTTA = 222
 
const LIGHT_BLUE_GLAZED_TERRACOTTA = 223
 
const YELLOW_GLAZED_TERRACOTTA = 224
 
const LIME_GLAZED_TERRACOTTA = 225
 
const PINK_GLAZED_TERRACOTTA = 226
 
const GRAY_GLAZED_TERRACOTTA = 227
 
const SILVER_GLAZED_TERRACOTTA = 228
 
const CYAN_GLAZED_TERRACOTTA = 229
 
const BLUE_GLAZED_TERRACOTTA = 231
 
const BROWN_GLAZED_TERRACOTTA = 232
 
const GREEN_GLAZED_TERRACOTTA = 233
 
const RED_GLAZED_TERRACOTTA = 234
 
const BLACK_GLAZED_TERRACOTTA = 235
 
const CONCRETE = 236
 
const CONCRETE_POWDER = 237
 
const CHORUS_PLANT = 240
 
const STAINED_GLASS = 241
 
const PODZOL = 243
 
const BEETROOT_BLOCK = 244
 
const STONECUTTER = 245
 
const GLOWING_OBSIDIAN = 246
 
const NETHER_REACTOR = 247
 
const UPDATE_BLOCK = 248
 
const ATEUPD_BLOCK = 249
 
const BLOCK_MOVED_BY_PISTON = 250
 
const OBSERVER = 251
 
const INFO_RESERVED6 = 255
 

Static Public Attributes

static $list = null
 

Protected Attributes

 $block
 
 $id
 
 $meta
 
 $durability = 0
 
 $name
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( int  $id,
int  $meta = 0,
int  $count = 1,
string  $name = "Unknown" 
)

Item constructor.

Parameters
int$id
int$meta
int$count
string$name
436  {
437  $this->id = $id & 0xffff;
438  $this->meta = $meta !== -1 ? $meta & 0xffff : -1;
439  $this->count = $count;
440  $this->name = $name;
441  if(!isset($this->block) and $this->id <= 0xff and isset(Block::$list[$this->id])){
442  $this->block = Block::get($this->id, $this->meta);
443  $this->name = $this->block->getName();
444  }
445  }

Member Function Documentation

◆ __toString()

__toString ( )
final
Returns
string
1265  : string{
1266  return "Item " . $this->name . " (" . $this->id . ":" . ($this->meta === null ? "?" : $this->meta) . ")x" . $this->count . ($this->hasCompoundTag() ? " tags:0x" . bin2hex($this->getCompoundTag()) : "");
1267  }

◆ addCreativeItem()

static addCreativeItem ( Item  $item)
static
Parameters
Item$item
317  {
318  Item::$creative[] = clone $item;
319  }

◆ addEnchantment()

addEnchantment ( Enchantment  $ench)
Parameters
Enchantment$ench
636  {
637  if(!$this->hasCompoundTag()){
638  $tag = new CompoundTag("", []);
639  }else{
640  $tag = $this->getNamedTag();
641  }
642 
643  if(!isset($tag->ench)){
644  $tag->ench = new ListTag("ench", []);
645  $tag->ench->setTagType(NBT::TAG_Compound);
646  }
647 
648  $found = false;
649 
650  foreach($tag->ench as $k => $entry){
651  if($entry["id"] === $ench->getId()){
652  $tag->ench->{$k} = new CompoundTag("", [
653  "id" => new ShortTag("id", $ench->getId()),
654  "lvl" => new ShortTag("lvl", $ench->getLevel())
655  ]);
656  $found = true;
657  break;
658  }
659  }
660 
661  if(!$found){
662  $count = 0;
663  foreach($tag->ench as $key => $value){
664  if(is_numeric($key)){
665  $count++;
666  }
667  }
668  $tag->ench->{$count + 1} = new CompoundTag("", [
669  "id" => new ShortTag("id", $ench->getId()),
670  "lvl" => new ShortTag("lvl", $ench->getLevel())
671  ]);
672  }
673 
674  $this->setNamedTag($tag);
675  }

◆ canBeActivated()

canBeActivated ( )
Returns
bool
102  : bool{
103  return false;
104  }

◆ canBeConsumed()

canBeConsumed ( )
Returns
bool
991  : bool{
992  return false;
993  }

◆ canBeConsumedBy()

canBeConsumedBy ( Entity  $entity)
Parameters
Entity$entity
Returns
bool
1000  : bool{
1001  return $this->canBeConsumed();
1002  }

◆ canBePlaced()

canBePlaced ( )
final
Returns
bool
977  : bool{
978  return $this->block !== null and $this->block->canBePlaced();
979  }

◆ clearCreativeItems()

static clearCreativeItems ( )
static
303  {
304  Item::$creative = [];
305  }

◆ clearCustomBlockData()

clearCustomBlockData ( )
Returns
$this
496  {
497  if(!$this->hasCompoundTag()){
498  return $this;
499  }
500  $tag = $this->getNamedTag();
501 
502  if(isset($tag->BlockEntityTag) and $tag->BlockEntityTag instanceof CompoundTag){
503  unset($tag->display->BlockEntityTag);
504  $this->setNamedTag($tag);
505  }
506 
507  return $this;
508  }

◆ clearCustomName()

clearCustomName ( )
Returns
$this
850  {
851  if(!$this->hasCompoundTag()){
852  return $this;
853  }
854  $tag = $this->getNamedTag();
855 
856  if(isset($tag->display) and $tag->display instanceof CompoundTag){
857  unset($tag->display->Name);
858  if($tag->display->getCount() === 0){
859  unset($tag->display);
860  }
861 
862  $this->setNamedTag($tag);
863  }
864 
865  return $this;
866  }

◆ clearNamedTag()

clearNamedTag ( )
Returns
Item
949  {
950  return $this->setCompoundTag("");
951  }

◆ clearRepairCost()

clearRepairCost ( )
Returns
$this
763  {
764  if(!$this->hasCompoundTag()){
765  return $this;
766  }
767  $tag = $this->getNamedTag();
768 
769  if(isset($tag->RepairCost) and $tag->RepairCost instanceof IntTag){
770  unset($tag->RepairCost);
771  $this->setNamedTag($tag);
772  }
773 
774  return $this;
775  }

◆ equals()

equals ( Item  $item,
bool  $checkDamage = true,
bool  $checkCompound = true,
  $checkCount = false 
)
final
Parameters
Item$item
bool$checkDamage
bool$checkCompound
bool$checkCount
Returns
bool
1246  : bool{
1247  if($this->id === $item->getId() and ($checkDamage === false or $this->getDamage() === $item->getDamage()) and ($checkCount === false or $this->getCount() === $item->getCount())){
1248  if($checkCompound){
1249  if($item->getCompoundTag() === $this->getCompoundTag()){
1250  return true;
1251  }elseif($this->hasCompoundTag() and $item->hasCompoundTag()){
1252  //Serialized NBT didn't match, check the cached object tree.
1253  return NBT::matchTree($this->getNamedTag(), $item->getNamedTag());
1254  }
1255  }else{
1256  return true;
1257  }
1258  }
1259  return false;
1260  }

◆ fromString()

static fromString ( string  $str,
bool  $multiple = false 
)
static
Parameters
string$str
bool$multiple
Returns
Item[]|Item
399  {
400  if($multiple === true){
401  $blocks = [];
402  foreach(explode(",", $str) as $b){
403  $blocks[] = self::fromString($b, false);
404  }
405 
406  return $blocks;
407  }else{
408  $b = explode(":", str_replace([" ", "minecraft:"], ["_", ""], trim($str)));
409  if(!isset($b[1])){
410  $meta = 0;
411  }else{
412  $meta = $b[1] & 0xFFFF;
413  }
414 
415  if(defined(Item::class . "::" . strtoupper($b[0]))){
416  $item = self::get(constant(Item::class . "::" . strtoupper($b[0])), $meta);
417  if($item->getId() === self::AIR and strtoupper($b[0]) !== "AIR"){
418  $item = self::get($b[0] & 0xFFFF, $meta);
419  }
420  }else{
421  $item = self::get($b[0] & 0xFFFF, $meta);
422  }
423 
424  return $item;
425  }
426  }

◆ get()

static get ( int  $id,
int  $meta = 0,
int  $count = 1,
string  $tags = "" 
)
static
Parameters
int$id
int$meta
int$count
string$tags
Returns
Item
378  : Item{
379  try{
380  $class = self::$list[$id];
381  if($class === null){
382  return (new Item($id, $meta, $count))->setCompoundTag($tags);
383  }elseif($id < 256){
384  return (new ItemBlock(new $class($meta), $meta, $count))->setCompoundTag($tags);
385  }else{
386  return (new $class($meta, $count))->setCompoundTag($tags);
387  }
388  }catch(\RuntimeException $e){
389  return (new Item($id, $meta, $count))->setCompoundTag($tags);
390  }
391  }

◆ getArmorValue()

getArmorValue ( )
Returns
bool
1145  {
1146  return false;
1147  }

◆ getAttackDamage()

getAttackDamage ( )
Returns
int
1180  {
1181  return 1;
1182  }

◆ getBlock()

getBlock ( )
Returns
Block
1013  : Block{
1014  if($this->block instanceof Block){
1015  return clone $this->block;
1016  }else{
1017  return Block::get(self::AIR);
1018  }
1019  }

◆ getCompoundTag()

getCompoundTag ( )
Returns
string
466  : string{
467  return $this->tags;
468  }

◆ getCount()

getCount ( )
Returns
int
956  : int{
957  return $this->count;
958  }

◆ getCreativeItem()

static getCreativeItem ( int  $index)
static
Parameters
$index
Returns
Item
351  {
352  return isset(Item::$creative[$index]) ? Item::$creative[$index] : null;
353  }

◆ getCreativeItemIndex()

static getCreativeItemIndex ( Item  $item)
static
Parameters
Item$item
Returns
int
360  : int{
361  foreach(Item::$creative as $i => $d){
362  if($item->equals($d, !$item->isTool())){
363  return $i;
364  }
365  }
366 
367  return -1;
368  }

◆ getCreativeItems()

static getCreativeItems ( )
static
Returns
array
310  : array{
311  return Item::$creative;
312  }

◆ getCustomBlockData()

getCustomBlockData ( )
Returns
null
534  {
535  if(!$this->hasCompoundTag()){
536  return null;
537  }
538 
539  $tag = $this->getNamedTag();
540  if(isset($tag->BlockEntityTag) and $tag->BlockEntityTag instanceof CompoundTag){
541  return $tag->BlockEntityTag;
542  }
543 
544  return null;
545  }

◆ getCustomName()

getCustomName ( )
Returns
string
800  : string{
801  if(!$this->hasCompoundTag()){
802  return "";
803  }
804 
805  $tag = $this->getNamedTag();
806  if(isset($tag->display)){
807  $tag = $tag->display;
808  if($tag instanceof CompoundTag and isset($tag->Name) and $tag->Name instanceof StringTag){
809  return $tag->Name->getValue();
810  }
811  }
812 
813  return "";
814  }

◆ getDamage()

getDamage ( )
final
Returns
int
1031  : int{
1032  return $this->meta;
1033  }

◆ getDestroySpeed()

getDestroySpeed ( Block  $block,
Player  $player 
)
Parameters
Block$block
Player$player
Returns
int
1218  {
1219  return 1;
1220  }

◆ getEnchantment()

getEnchantment ( int  $id)
Parameters
$id
Returns
Enchantment|null
571  {
572  if(!$this->hasEnchantments()){
573  return null;
574  }
575 
576  foreach($this->getNamedTag()->ench as $entry){
577  if($entry["id"] === $id){
578  $e = Enchantment::getEnchantment($entry["id"]);
579  $e->setLevel($entry["lvl"]);
580  return $e;
581  }
582  }
583 
584  return null;
585  }

◆ getEnchantmentLevel()

getEnchantmentLevel ( int  $id)
Parameters
$id
Returns
Int level|0(for null)
616  {
617  if(!$this->hasEnchantments()){
618  return 0;
619  }
620 
621  foreach($this->getNamedTag()->ench as $entry){
622  if($entry["id"] === $id){
623  $e = Enchantment::getEnchantment($entry["id"]);
624  $e->setLevel($entry["lvl"]);
625  $E_level = $e->getLevel() > Enchantment::getEnchantMaxLevel($id) ? Enchantment::getEnchantMaxLevel($id) : $e->getLevel();
626  return $E_level;
627  }
628  }
629 
630  return 0;
631  }

◆ getEnchantments()

getEnchantments ( )
Returns
Enchantment[]
680  : array{
681  if(!$this->hasEnchantments()){
682  return [];
683  }
684 
685  $enchantments = [];
686 
687  foreach($this->getNamedTag()->ench as $entry){
688  $e = Enchantment::getEnchantment($entry["id"]);
689  $e->setLevel($entry["lvl"]);
690  $enchantments[] = $e;
691  }
692 
693  return $enchantments;
694  }

◆ getFuelTime()

getFuelTime ( )
final
Returns
null
1059  {
1060  if(!isset(Fuel::$duration[$this->id])){
1061  return null;
1062  }
1063  if($this->id !== self::BUCKET or $this->meta === 10){
1064  return Fuel::$duration[$this->id];
1065  }
1066 
1067  return null;
1068  }

◆ getId()

getId ( )
final
Returns
int
1024  : int{
1025  return $this->id;
1026  }

◆ getLore()

getLore ( )
Returns
array
871  : array{
872  $tag = $this->getNamedTagEntry("display");
873  if($tag instanceof CompoundTag and isset($tag->Lore) and $tag->Lore instanceof ListTag){
874  $lines = [];
875  foreach($tag->Lore->getValue() as $line){
876  $lines[] = $line->getValue();
877  }
878  return $lines;
879  }
880  return [];
881  }

◆ getMaxDurability()

getMaxDurability ( )
Returns
int|bool
1089  {
1090  return false;
1091  }

◆ getMaxStackSize()

getMaxStackSize ( )
Returns
int
1052  : int{
1053  return 64;
1054  }

◆ getModifyAttackDamage()

getModifyAttackDamage ( Entity  $target)
Parameters
Entity$target
Returns
float|int
1189  {
1190  $rec = $this->getAttackDamage();
1192  if($sharpL > 0){
1193  $rec += 0.5 * ($sharpL + 1);
1194  }
1195 
1196  if($target instanceof Skeleton or $target instanceof Zombie or
1197  $target instanceof Witch or $target instanceof PigZombie
1198  ){
1199  //SMITE wither skeletons
1201 
1202  }elseif($target instanceof Spider or $target instanceof CaveSpider or
1203  $target instanceof Silverfish
1204  ){
1205  //Bane of Arthropods wither skeletons
1207 
1208  }
1209  return $rec;
1210  }

◆ getName()

getName ( )
final
Returns
string
970  : string{
971  return $this->hasCustomName() ? $this->getCustomName() : $this->name;
972  }

◆ getNamedTag()

getNamedTag ( )
Returns
null|CompoundTag
921  {
922  if(!$this->hasCompoundTag()){
923  return null;
924  }elseif($this->cachedNBT !== null){
925  return $this->cachedNBT;
926  }
927  return $this->cachedNBT = self::parseCompoundTag($this->tags);
928  }

◆ getNamedTagEntry()

getNamedTagEntry (   $name)
Parameters
$name
Returns
null
909  {
910  $tag = $this->getNamedTag();
911  if($tag !== null){
912  return isset($tag->{$name}) ? $tag->{$name} : null;
913  }
914 
915  return null;
916  }

◆ getRepairCost()

getRepairCost ( )
Returns
int
718  : int{
719  if(!$this->hasCompoundTag()){
720  return 1;
721  }
722 
723  $tag = $this->getNamedTag();
724  if(isset($tag->display)){
725  $tag = $tag->RepairCost;
726  if($tag instanceof IntTag){
727  return $tag->getValue();
728  }
729  }
730 
731  return 1;
732  }

◆ hasAnyDamageValue()

hasAnyDamageValue ( )
Returns
bool
1045  : bool{
1046  return $this->meta === -1;
1047  }

◆ hasCompoundTag()

hasCompoundTag ( )
Returns
bool
473  : bool{
474  return $this->tags !== "";
475  }

◆ hasCustomBlockData()

hasCustomBlockData ( )
Returns
bool
480  : bool{
481  if(!$this->hasCompoundTag()){
482  return false;
483  }
484 
485  $tag = $this->getNamedTag();
486  if(isset($tag->BlockEntityTag) and $tag->BlockEntityTag instanceof CompoundTag){
487  return true;
488  }
489 
490  return false;
491  }

◆ hasCustomName()

hasCustomName ( )
Returns
bool
781  : bool{
782  if(!$this->hasCompoundTag()){
783  return false;
784  }
785 
786  $tag = $this->getNamedTag();
787  if(isset($tag->display)){
788  $tag = $tag->display;
789  if($tag instanceof CompoundTag and isset($tag->Name) and $tag->Name instanceof StringTag){
790  return true;
791  }
792  }
793 
794  return false;
795  }

◆ hasEnchantment()

hasEnchantment ( int  $id,
int  $level = 1,
bool  $compareLevel = false 
)
Parameters
int$id
int$level
bool$compareLevel
Returns
bool
594  : bool{
595  if($this->hasEnchantments()){
596  foreach($this->getEnchantments() as $enchantment){
597  if($enchantment->getId() == $id){
598  if($compareLevel){
599  if($enchantment->getLevel() == $level){
600  return true;
601  }
602  }else{
603  return true;
604  }
605  }
606  }
607  }
608  return false;
609  }

◆ hasEnchantments()

hasEnchantments ( )
Returns
bool
550  : bool{
551  if(!$this->hasCompoundTag()){
552  return false;
553  }
554 
555  $tag = $this->getNamedTag();
556  if(isset($tag->ench)){
557  $tag = $tag->ench;
558  if($tag instanceof ListTag){
559  return true;
560  }
561  }
562 
563  return false;
564  }

◆ hasRepairCost()

hasRepairCost ( )
Returns
bool
699  : bool{
700  if(!$this->hasCompoundTag()){
701  return false;
702  }
703 
704  $tag = $this->getNamedTag();
705  if(isset($tag->RepairCost)){
706  $tag = $tag->RepairCost;
707  if($tag instanceof IntTag){
708  return true;
709  }
710  }
711 
712  return false;
713  }

◆ init()

static init (   $readFromJson = false)
static
Parameters
bool$readFromJson
109  {
110  if(self::$list === null){
111  //TODO: Sort this mess into some kind of order
112  self::$list = new \SplFixedArray(65536);
113  self::$list[self::SUGARCANE] = Sugarcane::class;
114  self::$list[self::ENDER_PEARL] = EnderPearl::class;
115  self::$list[self::EYE_OF_ENDER] = EyeOfEnder::class;
116  self::$list[self::DRAGONS_BREATH] = DragonsBreath::class;
117  self::$list[self::SHULKER_SHELL] = ShulkerShell::class;
118  self::$list[self::POPPED_CHORUS_FRUIT] = PoppedChorusFruit::class;
119  self::$list[self::WHEAT_SEEDS] = WheatSeeds::class;
120  self::$list[self::PUMPKIN_SEEDS] = PumpkinSeeds::class;
121  self::$list[self::MELON_SEEDS] = MelonSeeds::class;
122  self::$list[self::MUSHROOM_STEW] = MushroomStew::class;
123  self::$list[self::RABBIT_STEW] = RabbitStew::class;
124  self::$list[self::BEETROOT_SOUP] = BeetrootSoup::class;
125  self::$list[self::BEETROOT_SEEDS] = BeetrootSeeds::class;
126  self::$list[self::SIGN] = Sign::class;
127  self::$list[self::WOODEN_DOOR] = WoodenDoor::class;
128  self::$list[self::SPRUCE_DOOR] = SpruceDoor::class;
129  self::$list[self::BIRCH_DOOR] = BirchDoor::class;
130  self::$list[self::JUNGLE_DOOR] = JungleDoor::class;
131  self::$list[self::ACACIA_DOOR] = AcaciaDoor::class;
132  self::$list[self::DARK_OAK_DOOR] = DarkOakDoor::class;
133  self::$list[self::BUCKET] = Bucket::class;
134  self::$list[self::IRON_DOOR] = IronDoor::class;
135  self::$list[self::CAKE] = Cake::class;
136  self::$list[self::BED] = Bed::class;
137  self::$list[self::PAINTING] = Painting::class;
138  self::$list[self::COAL] = Coal::class;
139  self::$list[self::APPLE] = Apple::class;
140  self::$list[self::SPAWN_EGG] = SpawnEgg::class;
141  self::$list[self::DIAMOND] = Diamond::class;
142  self::$list[self::STICK] = Stick::class;
143  self::$list[self::SNOWBALL] = Snowball::class;
144  self::$list[self::BOWL] = Bowl::class;
145  self::$list[self::FEATHER] = Feather::class;
146  self::$list[self::BRICK] = Brick::class;
147  self::$list[self::LEATHER_CAP] = LeatherCap::class;
148  self::$list[self::LEATHER_TUNIC] = LeatherTunic::class;
149  self::$list[self::LEATHER_PANTS] = LeatherPants::class;
150  self::$list[self::LEATHER_BOOTS] = LeatherBoots::class;
151  self::$list[self::CHAIN_HELMET] = ChainHelmet::class;
152  self::$list[self::CHAIN_CHESTPLATE] = ChainChestplate::class;
153  self::$list[self::CHAIN_LEGGINGS] = ChainLeggings::class;
154  self::$list[self::CHAIN_BOOTS] = ChainBoots::class;
155  self::$list[self::IRON_HELMET] = IronHelmet::class;
156  self::$list[self::IRON_CHESTPLATE] = IronChestplate::class;
157  self::$list[self::IRON_LEGGINGS] = IronLeggings::class;
158  self::$list[self::IRON_BOOTS] = IronBoots::class;
159  self::$list[self::GOLD_HELMET] = GoldHelmet::class;
160  self::$list[self::GOLD_CHESTPLATE] = GoldChestplate::class;
161  self::$list[self::GOLD_LEGGINGS] = GoldLeggings::class;
162  self::$list[self::GOLD_BOOTS] = GoldBoots::class;
163  self::$list[self::DIAMOND_HELMET] = DiamondHelmet::class;
164  self::$list[self::DIAMOND_CHESTPLATE] = DiamondChestplate::class;
165  self::$list[self::DIAMOND_LEGGINGS] = DiamondLeggings::class;
166  self::$list[self::DIAMOND_BOOTS] = DiamondBoots::class;
167  self::$list[self::IRON_SWORD] = IronSword::class;
168  self::$list[self::IRON_INGOT] = IronIngot::class;
169  self::$list[self::GOLD_INGOT] = GoldIngot::class;
170  self::$list[self::IRON_SHOVEL] = IronShovel::class;
171  self::$list[self::IRON_PICKAXE] = IronPickaxe::class;
172  self::$list[self::IRON_AXE] = IronAxe::class;
173  self::$list[self::IRON_HOE] = IronHoe::class;
174  self::$list[self::DIAMOND_SWORD] = DiamondSword::class;
175  self::$list[self::DIAMOND_SHOVEL] = DiamondShovel::class;
176  self::$list[self::DIAMOND_PICKAXE] = DiamondPickaxe::class;
177  self::$list[self::DIAMOND_AXE] = DiamondAxe::class;
178  self::$list[self::DIAMOND_HOE] = DiamondHoe::class;
179  self::$list[self::GOLD_SWORD] = GoldSword::class;
180  self::$list[self::GOLD_SHOVEL] = GoldShovel::class;
181  self::$list[self::GOLD_PICKAXE] = GoldPickaxe::class;
182  self::$list[self::GOLD_AXE] = GoldAxe::class;
183  self::$list[self::GOLD_HOE] = GoldHoe::class;
184  self::$list[self::STONE_SWORD] = StoneSword::class;
185  self::$list[self::STONE_SHOVEL] = StoneShovel::class;
186  self::$list[self::STONE_PICKAXE] = StonePickaxe::class;
187  self::$list[self::STONE_AXE] = StoneAxe::class;
188  self::$list[self::STONE_HOE] = StoneHoe::class;
189  self::$list[self::WOODEN_SWORD] = WoodenSword::class;
190  self::$list[self::WOODEN_SHOVEL] = WoodenShovel::class;
191  self::$list[self::WOODEN_PICKAXE] = WoodenPickaxe::class;
192  self::$list[self::WOODEN_AXE] = WoodenAxe::class;
193  self::$list[self::WOODEN_HOE] = WoodenHoe::class;
194  self::$list[self::FLINT_STEEL] = FlintSteel::class;
195  self::$list[self::SHEARS] = Shears::class;
196  self::$list[self::BOW] = Bow::class;
197 
198  self::$list[self::RAW_FISH] = Fish::class;
199  self::$list[self::COOKED_FISH] = CookedFish::class;
200 
201  self::$list[self::NETHER_QUARTZ] = NetherQuartz::class;
202  self::$list[self::POTION] = Potion::class;
203  self::$list[self::GLASS_BOTTLE] = GlassBottle::class;
204  self::$list[self::SPLASH_POTION] = SplashPotion::class;
205  self::$list[self::ENCHANTING_BOTTLE] = EnchantingBottle::class;
206  self::$list[self::BOAT] = Boat::class;
207  self::$list[self::MINECART] = Minecart::class;
208 
209  self::$list[self::ARROW] = Arrow::class;
210  self::$list[self::STRING] = ItemString::class;
211  self::$list[self::GUNPOWDER] = Gunpowder::class;
212  self::$list[self::WHEAT] = Wheat::class;
213  self::$list[self::BREAD] = Bread::class;
214  self::$list[self::FLINT] = Flint::class;
215  self::$list[self::FLINT] = Flint::class;
216  self::$list[self::RAW_PORKCHOP] = RawPorkchop::class;
217  self::$list[self::COOKED_PORKCHOP] = CookedPorkchop::class;
218  self::$list[self::GOLDEN_APPLE] = GoldenApple::class;
219  self::$list[self::MINECART] = Minecart::class;
220  self::$list[self::REDSTONE] = Redstone::class;
221  self::$list[self::LEATHER] = Leather::class;
222  self::$list[self::CLAY] = Clay::class;
223  self::$list[self::PAPER] = Paper::class;
224  self::$list[self::BOOK] = Book::class;
225  self::$list[self::SLIMEBALL] = Slimeball::class;
226  self::$list[self::EGG] = Egg::class;
227  self::$list[self::COMPASS] = Compass::class;
228  self::$list[self::CLOCK] = Clock::class;
229  self::$list[self::GLOWSTONE_DUST] = GlowstoneDust::class;
230  self::$list[self::DYE] = Dye::class;
231  self::$list[self::BONE] = Bone::class;
232  self::$list[self::SUGAR] = Sugar::class;
233  self::$list[self::COOKIE] = Cookie::class;
234  self::$list[self::MELON] = Melon::class;
235  self::$list[self::RAW_BEEF] = RawBeef::class;
236  self::$list[self::STEAK] = Steak::class;
237  self::$list[self::RAW_CHICKEN] = RawChicken::class;
238  self::$list[self::COOKED_CHICKEN] = CookedChicken::class;
239  self::$list[self::GOLD_NUGGET] = GoldNugget::class;
240  self::$list[self::EMERALD] = Emerald::class;
241  self::$list[self::ITEM_FRAME] = ItemFrame::class;
242  self::$list[self::FLOWER_POT] = FlowerPot::class;
243  self::$list[self::CARROT] = Carrot::class;
244  self::$list[self::POTATO] = Potato::class;
245  self::$list[self::BAKED_POTATO] = BakedPotato::class;
246  self::$list[self::PUMPKIN_PIE] = PumpkinPie::class;
247  self::$list[self::NETHER_BRICK] = NetherBrick::class;
248  self::$list[self::QUARTZ] = Quartz::class;
249  self::$list[self::BREWING_STAND] = BrewingStand::class;
250  self::$list[self::CAMERA] = Camera::class;
251  self::$list[self::BEETROOT] = Beetroot::class;
252  self::$list[self::SKULL] = Skull::class;
253  self::$list[self::RAW_RABBIT] = RawRabbit::class;
254  self::$list[self::COOKED_RABBIT] = CookedRabbit::class;
255  self::$list[self::GOLDEN_CARROT] = GoldenCarrot::class;
256  self::$list[self::NETHER_WART] = NetherWart::class;
257  self::$list[self::SPIDER_EYE] = SpiderEye::class;
258  self::$list[self::FERMENTED_SPIDER_EYE] = FermentedSpiderEye::class;
259  self::$list[self::BLAZE_POWDER] = BlazePowder::class;
260  self::$list[self::MAGMA_CREAM] = MagmaCream::class;
261  self::$list[self::GLISTERING_MELON] = GlisteringMelon::class;
262  self::$list[self::ENCHANTED_BOOK] = EnchantedBook::class;
263  self::$list[self::REPEATER] = Repeater::class;
264  self::$list[self::CAULDRON] = Cauldron::class;
265  self::$list[self::ROTTEN_FLESH] = RottenFlesh::class;
266  self::$list[self::ENCHANTED_GOLDEN_APPLE] = EnchantedGoldenApple::class;
267  self::$list[self::RAW_MUTTON] = RawMutton::class;
268  self::$list[self::COOKED_MUTTON] = CookedMutton::class;
269  self::$list[self::HOPPER] = Hopper::class;
270  self::$list[self::ELYTRA] = Elytra::class;
271  self::$list[self::NETHER_STAR] = NetherStar::class;
272  self::$list[self::CHORUS_FRUIT] = ChorusFruit::class;
273  self::$list[self::PRISMARINE_CRYSTALS] = PrismarineCrystals::class;
274  self::$list[self::PRISMARINE_SHARD] = PrismarineShard::class;
275  self::$list[self::FIRE_CHARGE] = FireCharge::class;
276 
277  for($i = 0; $i < 256; ++$i){
278  if(Block::$list[$i] !== null){
279  self::$list[$i] = Block::$list[$i];
280  }
281  }
282  }
283 
284  self::initCreativeItems();
285  }

◆ isArmor()

isArmor ( )
Returns
bool
1138  {
1139  return false;
1140  }

◆ isAxe()

isAxe ( )
Returns
bool
1103  {
1104  return false;
1105  }

◆ isBoots()

isBoots ( )
Returns
bool
1152  {
1153  return false;
1154  }

◆ isChestplate()

isChestplate ( )
Returns
bool
1173  {
1174  return false;
1175  }

◆ isCreativeItem()

static isCreativeItem ( Item  $item)
static
Parameters
Item$item
Returns
bool
336  : bool{
337  foreach(Item::$creative as $i => $d){
338  if($item->equals($d, !$item->isTool())){
339  return true;
340  }
341  }
342 
343  return false;
344  }

◆ isHelmet()

isHelmet ( )
Returns
bool
1159  {
1160  return false;
1161  }

◆ isHoe()

isHoe ( )
Returns
bool
1124  {
1125  return false;
1126  }

◆ isLeggings()

isLeggings ( )
Returns
bool
1166  {
1167  return false;
1168  }

◆ isPickaxe()

isPickaxe ( )
Returns
bool
1096  {
1097  return false;
1098  }

◆ isPlaceable()

isPlaceable ( )
final
Returns
bool
984  : bool{
985  return $this->canBePlaced();
986  }

◆ isShears()

isShears ( )
Returns
bool
1131  {
1132  return false;
1133  }

◆ isShovel()

isShovel ( )
Returns
bool
1117  {
1118  return false;
1119  }

◆ isSword()

isSword ( )
Returns
bool
1110  {
1111  return false;
1112  }

◆ isTool()

isTool ( )
Returns
bool
1082  {
1083  return false;
1084  }

◆ jsonSerialize()

jsonSerialize ( )
final
Returns
array
1272  {
1273  return [
1274  "id" => $this->id,
1275  "damage" => $this->meta,
1276  "count" => $this->count, //TODO: separate items and stacks
1277  "nbt" => $this->tags
1278  ];
1279  }

◆ nbtDeserialize()

static nbtDeserialize ( CompoundTag  $tag)
static

Deserializes an Item from an NBT CompoundTag

Parameters
CompoundTag$tag
Returns
Item
1315  : Item{
1316  if(!isset($tag->id) or !isset($tag->Count)){
1317  return Item::get(0);
1318  }
1319 
1320  if($tag->id instanceof ShortTag){
1321  $item = Item::get($tag->id->getValue(), !isset($tag->Damage) ? 0 : $tag->Damage->getValue(), $tag->Count->getValue());
1322  }elseif($tag->id instanceof StringTag){ //PC item save format
1323  $item = Item::fromString($tag->id->getValue());
1324  $item->setDamage(!isset($tag->Damage) ? 0 : $tag->Damage->getValue());
1325  $item->setCount($tag->Count->getValue());
1326  }else{
1327  throw new \InvalidArgumentException("Item CompoundTag ID must be an instance of StringTag or ShortTag, " . get_class($tag->id) . " given");
1328  }
1329 
1330  if(isset($tag->tag) and $tag->tag instanceof CompoundTag){
1331  $item->setNamedTag($tag->tag);
1332  }
1333 
1334  return $item;
1335  }

◆ nbtSerialize()

nbtSerialize ( int  $slot = -1,
string  $tagName = "" 
)

Serializes the item to an NBT CompoundTag

Parameters
int$slotoptional, the inventory slot of the item
string$tagNamethe name to assign to the CompoundTag object
Returns
CompoundTag
1289  : CompoundTag{
1290  $tag = new CompoundTag($tagName, [
1291  "id" => new ShortTag("id", $this->id),
1292  "Count" => new ByteTag("Count", $this->count ?? -1),
1293  "Damage" => new ShortTag("Damage", $this->meta),
1294  ]);
1295 
1296  if($this->hasCompoundTag()){
1297  $tag->tag = clone $this->getNamedTag();
1298  $tag->tag->setName("tag");
1299  }
1300 
1301  if($slot !== -1){
1302  $tag->Slot = new ByteTag("Slot", $slot);
1303  }
1304 
1305  return $tag;
1306  }

◆ onActivate()

onActivate ( Level  $level,
Player  $player,
Block  $block,
Block  $target,
  $face,
  $fx,
  $fy,
  $fz 
)
Parameters
Level$level
Player$player
Block$block
Block$target
$face
$fx
$fy
$fz
Returns
bool
1234  {
1235  return false;
1236  }

◆ onConsume()

onConsume ( Entity  $entity)
Parameters
Entity$entity
1007  {
1008  }

◆ removeCreativeItem()

static removeCreativeItem ( Item  $item)
static
Parameters
Item$item
324  {
325  $index = self::getCreativeItemIndex($item);
326  if($index !== -1){
327  unset(Item::$creative[$index]);
328  }
329  }

◆ setCompoundTag()

setCompoundTag (   $tags)
Parameters
$tags
Returns
$this
452  {
453  if($tags instanceof CompoundTag){
454  $this->setNamedTag($tags);
455  }else{
456  $this->tags = (string) $tags;
457  $this->cachedNBT = null;
458  }
459 
460  return $this;
461  }

◆ setCount()

setCount ( int  $count)
Parameters
int$count
963  {
964  $this->count = $count;
965  }

◆ setCustomBlockData()

setCustomBlockData ( CompoundTag  $compound)
Parameters
CompoundTag$compound
Returns
$this
515  {
516  $tags = clone $compound;
517  $tags->setName("BlockEntityTag");
518 
519  if(!$this->hasCompoundTag()){
520  $tag = new CompoundTag("", []);
521  }else{
522  $tag = $this->getNamedTag();
523  }
524 
525  $tag->BlockEntityTag = $tags;
526  $this->setNamedTag($tag);
527 
528  return $this;
529  }

◆ setCustomName()

setCustomName ( string  $name)
Parameters
string$name
Returns
$this
821  {
822  if($name === ""){
823  $this->clearCustomName();
824  }
825 
826  if(!($hadCompoundTag = $this->hasCompoundTag())){
827  $tag = new CompoundTag("", []);
828  }else{
829  $tag = $this->getNamedTag();
830  }
831 
832  if(isset($tag->display) and $tag->display instanceof CompoundTag){
833  $tag->display->Name = new StringTag("Name", $name);
834  }else{
835  $tag->display = new CompoundTag("display", [
836  "Name" => new StringTag("Name", $name)
837  ]);
838  }
839 
840  if(!$hadCompoundTag){
841  $this->setCompoundTag($tag);
842  }
843 
844  return $this;
845  }

◆ setDamage()

setDamage ( int  $meta)
Parameters
int$meta
1038  {
1039  $this->meta = $meta !== -1 ? $meta & 0xFFFF : -1;
1040  }

◆ setLore()

setLore ( array  $lines)
Parameters
array$lines
Returns
$this
888  {
889  $tag = $this->getNamedTag() ?? new CompoundTag("", []);
890  if(!isset($tag->display)){
891  $tag->display = new CompoundTag("display", []);
892  }
893  $tag->display->Lore = new ListTag("Lore");
894  $tag->display->Lore->setTagType(NBT::TAG_String);
895  $count = 0;
896  foreach($lines as $line){
897  $tag->display->Lore[$count++] = new StringTag("", $line);
898  }
899  $this->setNamedTag($tag);
900  return $this;
901  }

◆ setNamedTag()

setNamedTag ( CompoundTag  $tag)
Parameters
CompoundTag$tag
Returns
$this|Item
935  {
936  if($tag->getCount() === 0){
937  return $this->clearNamedTag();
938  }
939 
940  $this->cachedNBT = $tag;
941  $this->tags = self::writeCompoundTag($tag);
942 
943  return $this;
944  }

◆ setRepairCost()

setRepairCost ( int  $cost)
Parameters
int$cost
Returns
$this
740  {
741  if($cost === 1){
742  $this->clearRepairCost();
743  }
744 
745  if(!($hadCompoundTag = $this->hasCompoundTag())){
746  $tag = new CompoundTag("", []);
747  }else{
748  $tag = $this->getNamedTag();
749  }
750 
751  $tag->RepairCost = new IntTag("RepairCost", $cost);
752 
753  if(!$hadCompoundTag){
754  $this->setCompoundTag($tag);
755  }
756 
757  return $this;
758  }

◆ useOn()

useOn (   $object)
Parameters
Entity | Block$object
Returns
bool
1075  {
1076  return false;
1077  }

Field Documentation

◆ $block

$block
protected

◆ $count

$count

◆ $durability

$durability = 0
protected

◆ $id

$id
protected

◆ $list

$list = null
static

◆ $meta

$meta
protected

◆ $name

$name
protected

The documentation for this class was generated from the following file: