Assign auto-generated runtime type IDs to all items

This commit is contained in:
Dylan K. Taylor 2022-06-29 13:50:58 +01:00
parent 56428e8a4e
commit dd63681f94
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
10 changed files with 584 additions and 293 deletions

View File

@ -91,11 +91,19 @@ class Block{
public function asItem() : Item{
return ItemFactory::getInstance()->get(
$this->idInfo->getLegacyItemId(),
$this->idInfo->getLegacyVariant() | $this->writeStateToItemMeta()
$this->getLegacyItemId(),
$this->getLegacyItemMeta()
);
}
public function getLegacyItemId() : int{
return $this->idInfo->getLegacyItemId();
}
public function getLegacyItemMeta() : int{
return $this->idInfo->getLegacyVariant() | $this->writeStateToItemMeta();
}
protected function writeStateToItemMeta() : int{
return 0;
}

View File

@ -27,7 +27,6 @@ use pocketmine\block\utils\BlockDataReader;
use pocketmine\block\utils\BlockDataWriter;
use pocketmine\data\bedrock\CoralTypeIdMap;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\ItemIds;
use pocketmine\math\Axis;
use pocketmine\math\Facing;
@ -40,12 +39,8 @@ use function rad2deg;
final class FloorCoralFan extends BaseCoral{
private int $axis = Axis::X;
public function asItem() : Item{
//TODO: HACK! workaround dead flag being lost when broken / blockpicked (original impl only uses first ID)
return ItemFactory::getInstance()->get(
$this->dead ? ItemIds::CORAL_FAN_DEAD : ItemIds::CORAL_FAN,
$this->writeStateToItemMeta()
);
public function getLegacyItemId() : int{
return $this->dead ? ItemIds::CORAL_FAN_DEAD : ItemIds::CORAL_FAN;
}
protected function writeStateToItemMeta() : int{
@ -105,5 +100,4 @@ final class FloorCoralFan extends BaseCoral{
private function canBeSupportedBy(Block $block) : bool{
return $block->getSupportType(Facing::UP)->hasCenterSupport();
}
}

View File

@ -28,7 +28,6 @@ use pocketmine\block\utils\BlockDataWriter;
use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\data\bedrock\CoralTypeIdMap;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\ItemIds;
use pocketmine\math\Axis;
use pocketmine\math\Facing;
@ -39,6 +38,10 @@ use pocketmine\world\BlockTransaction;
final class WallCoralFan extends BaseCoral{
use HorizontalFacingTrait;
public function getLegacyItemId() : int{
return $this->dead ? ItemIds::CORAL_FAN_DEAD : ItemIds::CORAL_FAN;
}
protected function writeStateToItemMeta() : int{
return CoralTypeIdMap::getInstance()->toId($this->coralType);
}
@ -55,13 +58,6 @@ final class WallCoralFan extends BaseCoral{
$w->writeHorizontalFacing($this->facing);
}
public function asItem() : Item{
return ItemFactory::getInstance()->get(
$this->dead ? ItemIds::CORAL_FAN_DEAD : ItemIds::CORAL_FAN,
$this->writeStateToItemMeta()
);
}
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
$axis = Facing::axis($face);
if(($axis !== Axis::X && $axis !== Axis::Z) || !$this->canBeSupportedBy($blockClicked, $face)){

View File

@ -38,7 +38,7 @@ final class CoralFan extends Item{
}
public function getId() : int{
return $this->dead ? $this->identifierFlattened->getAdditionalIds()[0] : $this->identifierFlattened->getId();
return $this->dead ? $this->identifierFlattened->getAdditionalLegacyIds()[0] : $this->identifierFlattened->getLegacyId();
}
public function getMeta() : int{

View File

@ -428,16 +428,15 @@ class Item implements \JsonSerializable{
}
final public function getTypeId() : int{
//don't use Item::getMeta(), since it might be overridden for non-type information (e.g. durability)
return ($this->identifier->getId() << 16) | $this->identifier->getMeta();
return $this->identifier->getTypeId();
}
public function getId() : int{
return $this->identifier->getId();
return $this->identifier->getLegacyId();
}
public function getMeta() : int{
return $this->identifier->getMeta();
return $this->identifier->getLegacyMeta();
}
/**

View File

@ -35,8 +35,8 @@ use pocketmine\block\BlockFactory;
final class ItemBlock extends Item{
private int $blockFullId;
public function __construct(ItemIdentifier $identifier, Block $block){
parent::__construct($identifier, $block->getName());
public function __construct(Block $block){
parent::__construct(ItemIdentifier::fromBlock($block), $block->getName());
$this->blockFullId = $block->getStateId();
}

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\block\utils\CoralType;
use pocketmine\block\utils\DyeColor;
@ -42,10 +41,12 @@ use pocketmine\entity\Villager;
use pocketmine\entity\Zombie;
use pocketmine\inventory\ArmorInventory;
use pocketmine\item\ItemIdentifier as IID;
use pocketmine\item\ItemIds as Ids;
use pocketmine\item\ItemIds as LegacyIds;
use pocketmine\item\ItemTypeIds as Ids;
use pocketmine\math\Vector3;
use pocketmine\nbt\NbtException;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\utils\AssumptionFailedError;
use pocketmine\utils\SingletonTrait;
use pocketmine\world\format\io\GlobalBlockStateHandlers;
use pocketmine\world\World;
@ -66,229 +67,239 @@ class ItemFactory{
$this->registerSpawnEggs();
$this->registerTierToolItems();
$this->register(new Apple(new IID(Ids::APPLE, 0), "Apple"));
$this->register(new Arrow(new IID(Ids::ARROW, 0), "Arrow"));
$this->register(new Apple(new IID(Ids::APPLE, LegacyIds::APPLE, 0), "Apple"));
$this->register(new Arrow(new IID(Ids::ARROW, LegacyIds::ARROW, 0), "Arrow"));
$this->register(new BakedPotato(new IID(Ids::BAKED_POTATO, 0), "Baked Potato"));
$this->register(new Bamboo(new IID(Ids::BAMBOO, 0), "Bamboo"), true);
$this->register(new Beetroot(new IID(Ids::BEETROOT, 0), "Beetroot"));
$this->register(new BeetrootSeeds(new IID(Ids::BEETROOT_SEEDS, 0), "Beetroot Seeds"));
$this->register(new BeetrootSoup(new IID(Ids::BEETROOT_SOUP, 0), "Beetroot Soup"));
$this->register(new BlazeRod(new IID(Ids::BLAZE_ROD, 0), "Blaze Rod"));
$this->register(new Book(new IID(Ids::BOOK, 0), "Book"));
$this->register(new Bow(new IID(Ids::BOW, 0), "Bow"));
$this->register(new Bowl(new IID(Ids::BOWL, 0), "Bowl"));
$this->register(new Bread(new IID(Ids::BREAD, 0), "Bread"));
$this->register(new Bucket(new IID(Ids::BUCKET, 0), "Bucket"));
$this->register(new Carrot(new IID(Ids::CARROT, 0), "Carrot"));
$this->register(new ChorusFruit(new IID(Ids::CHORUS_FRUIT, 0), "Chorus Fruit"));
$this->register(new Clock(new IID(Ids::CLOCK, 0), "Clock"));
$this->register(new Clownfish(new IID(Ids::CLOWNFISH, 0), "Clownfish"));
$this->register(new Coal(new IID(Ids::COAL, 0), "Coal"));
$this->register(new BakedPotato(new IID(Ids::BAKED_POTATO, LegacyIds::BAKED_POTATO, 0), "Baked Potato"));
$this->register(new Bamboo(new IID(Ids::BAMBOO, LegacyIds::BAMBOO, 0), "Bamboo"), true);
$this->register(new Beetroot(new IID(Ids::BEETROOT, LegacyIds::BEETROOT, 0), "Beetroot"));
$this->register(new BeetrootSeeds(new IID(Ids::BEETROOT_SEEDS, LegacyIds::BEETROOT_SEEDS, 0), "Beetroot Seeds"));
$this->register(new BeetrootSoup(new IID(Ids::BEETROOT_SOUP, LegacyIds::BEETROOT_SOUP, 0), "Beetroot Soup"));
$this->register(new BlazeRod(new IID(Ids::BLAZE_ROD, LegacyIds::BLAZE_ROD, 0), "Blaze Rod"));
$this->register(new Book(new IID(Ids::BOOK, LegacyIds::BOOK, 0), "Book"));
$this->register(new Bow(new IID(Ids::BOW, LegacyIds::BOW, 0), "Bow"));
$this->register(new Bowl(new IID(Ids::BOWL, LegacyIds::BOWL, 0), "Bowl"));
$this->register(new Bread(new IID(Ids::BREAD, LegacyIds::BREAD, 0), "Bread"));
$this->register(new Bucket(new IID(Ids::BUCKET, LegacyIds::BUCKET, 0), "Bucket"));
$this->register(new Carrot(new IID(Ids::CARROT, LegacyIds::CARROT, 0), "Carrot"));
$this->register(new ChorusFruit(new IID(Ids::CHORUS_FRUIT, LegacyIds::CHORUS_FRUIT, 0), "Chorus Fruit"));
$this->register(new Clock(new IID(Ids::CLOCK, LegacyIds::CLOCK, 0), "Clock"));
$this->register(new Clownfish(new IID(Ids::CLOWNFISH, LegacyIds::CLOWNFISH, 0), "Clownfish"));
$this->register(new Coal(new IID(Ids::COAL, LegacyIds::COAL, 0), "Coal"));
$identifier = new ItemIdentifierFlattened(Ids::CORAL_FAN, 0, [Ids::CORAL_FAN_DEAD]);
$identifier = new ItemIdentifierFlattened(Ids::CORAL_FAN, LegacyIds::CORAL_FAN, 0, [LegacyIds::CORAL_FAN_DEAD]);
foreach(CoralType::getAll() as $coralType){
$this->register((new CoralFan($identifier))->setCoralType($coralType)->setDead(false), true);
$this->register((new CoralFan($identifier))->setCoralType($coralType)->setDead(true), true);
}
$this->register(new Coal(new IID(Ids::COAL, 1), "Charcoal"));
$this->register(new CocoaBeans(new IID(Ids::DYE, 3), "Cocoa Beans"));
$this->register(new Compass(new IID(Ids::COMPASS, 0), "Compass"));
$this->register(new CookedChicken(new IID(Ids::COOKED_CHICKEN, 0), "Cooked Chicken"));
$this->register(new CookedFish(new IID(Ids::COOKED_FISH, 0), "Cooked Fish"));
$this->register(new CookedMutton(new IID(Ids::COOKED_MUTTON, 0), "Cooked Mutton"));
$this->register(new CookedPorkchop(new IID(Ids::COOKED_PORKCHOP, 0), "Cooked Porkchop"));
$this->register(new CookedRabbit(new IID(Ids::COOKED_RABBIT, 0), "Cooked Rabbit"));
$this->register(new CookedSalmon(new IID(Ids::COOKED_SALMON, 0), "Cooked Salmon"));
$this->register(new Cookie(new IID(Ids::COOKIE, 0), "Cookie"));
$this->register(new DriedKelp(new IID(Ids::DRIED_KELP, 0), "Dried Kelp"));
$this->register(new Egg(new IID(Ids::EGG, 0), "Egg"));
$this->register(new EnderPearl(new IID(Ids::ENDER_PEARL, 0), "Ender Pearl"));
$this->register(new ExperienceBottle(new IID(Ids::EXPERIENCE_BOTTLE, 0), "Bottle o' Enchanting"));
$this->register(new Fertilizer(new IID(Ids::DYE, 15), "Bone Meal"));
$this->register(new FishingRod(new IID(Ids::FISHING_ROD, 0), "Fishing Rod"));
$this->register(new FlintSteel(new IID(Ids::FLINT_STEEL, 0), "Flint and Steel"));
$this->register(new GlassBottle(new IID(Ids::GLASS_BOTTLE, 0), "Glass Bottle"));
$this->register(new GoldenApple(new IID(Ids::GOLDEN_APPLE, 0), "Golden Apple"));
$this->register(new GoldenAppleEnchanted(new IID(Ids::ENCHANTED_GOLDEN_APPLE, 0), "Enchanted Golden Apple"));
$this->register(new GoldenCarrot(new IID(Ids::GOLDEN_CARROT, 0), "Golden Carrot"));
$this->register(new Item(new IID(Ids::BLAZE_POWDER, 0), "Blaze Powder"));
$this->register(new Item(new IID(Ids::BLEACH, 0), "Bleach")); //EDU
$this->register(new Item(new IID(Ids::BONE, 0), "Bone"));
$this->register(new Item(new IID(Ids::BRICK, 0), "Brick"));
$this->register(new Item(new IID(Ids::CHORUS_FRUIT_POPPED, 0), "Popped Chorus Fruit"));
$this->register(new Item(new IID(Ids::CLAY_BALL, 0), "Clay"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::SALT), "Salt"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::SODIUM_OXIDE), "Sodium Oxide"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::SODIUM_HYDROXIDE), "Sodium Hydroxide"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::MAGNESIUM_NITRATE), "Magnesium Nitrate"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::IRON_SULPHIDE), "Iron Sulphide"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::LITHIUM_HYDRIDE), "Lithium Hydride"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::SODIUM_HYDRIDE), "Sodium Hydride"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::CALCIUM_BROMIDE), "Calcium Bromide"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::MAGNESIUM_OXIDE), "Magnesium Oxide"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::SODIUM_ACETATE), "Sodium Acetate"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::LUMINOL), "Luminol"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::CHARCOAL), "Charcoal")); //??? maybe bug
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::SUGAR), "Sugar")); //??? maybe bug
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::ALUMINIUM_OXIDE), "Aluminium Oxide"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::BORON_TRIOXIDE), "Boron Trioxide"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::SOAP), "Soap"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::POLYETHYLENE), "Polyethylene"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::RUBBISH), "Rubbish"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::MAGNESIUM_SALTS), "Magnesium Salts"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::SULPHATE), "Sulphate"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::BARIUM_SULPHATE), "Barium Sulphate"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::POTASSIUM_CHLORIDE), "Potassium Chloride"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::MERCURIC_CHLORIDE), "Mercuric Chloride"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::CERIUM_CHLORIDE), "Cerium Chloride"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::TUNGSTEN_CHLORIDE), "Tungsten Chloride"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::CALCIUM_CHLORIDE), "Calcium Chloride"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::WATER), "Water")); //???
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::GLUE), "Glue"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::HYPOCHLORITE), "Hypochlorite"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::CRUDE_OIL), "Crude Oil"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::LATEX), "Latex"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::POTASSIUM_IODIDE), "Potassium Iodide"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::SODIUM_FLUORIDE), "Sodium Fluoride"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::BENZENE), "Benzene"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::INK), "Ink"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::HYDROGEN_PEROXIDE), "Hydrogen Peroxide"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::AMMONIA), "Ammonia"));
$this->register(new Item(new IID(Ids::COMPOUND, CompoundTypeIds::SODIUM_HYPOCHLORITE), "Sodium Hypochlorite"));
$this->register(new Item(new IID(Ids::DIAMOND, 0), "Diamond"));
$this->register(new Item(new IID(Ids::DRAGON_BREATH, 0), "Dragon's Breath"));
$this->register(new Item(new IID(Ids::DYE, 0), "Ink Sac"));
$this->register(new Item(new IID(Ids::DYE, 4), "Lapis Lazuli"));
$this->register(new Item(new IID(Ids::EMERALD, 0), "Emerald"));
$this->register(new Item(new IID(Ids::FEATHER, 0), "Feather"));
$this->register(new Item(new IID(Ids::FERMENTED_SPIDER_EYE, 0), "Fermented Spider Eye"));
$this->register(new Item(new IID(Ids::FLINT, 0), "Flint"));
$this->register(new Item(new IID(Ids::GHAST_TEAR, 0), "Ghast Tear"));
$this->register(new Item(new IID(Ids::GLISTERING_MELON, 0), "Glistering Melon"));
$this->register(new Item(new IID(Ids::GLOWSTONE_DUST, 0), "Glowstone Dust"));
$this->register(new Item(new IID(Ids::GOLD_INGOT, 0), "Gold Ingot"));
$this->register(new Item(new IID(Ids::GOLD_NUGGET, 0), "Gold Nugget"));
$this->register(new Item(new IID(Ids::GUNPOWDER, 0), "Gunpowder"));
$this->register(new Item(new IID(Ids::HEART_OF_THE_SEA, 0), "Heart of the Sea"));
$this->register(new Item(new IID(Ids::IRON_INGOT, 0), "Iron Ingot"));
$this->register(new Item(new IID(Ids::IRON_NUGGET, 0), "Iron Nugget"));
$this->register(new Item(new IID(Ids::LEATHER, 0), "Leather"));
$this->register(new Item(new IID(Ids::MAGMA_CREAM, 0), "Magma Cream"));
$this->register(new Item(new IID(Ids::NAUTILUS_SHELL, 0), "Nautilus Shell"));
$this->register(new Item(new IID(Ids::NETHER_BRICK, 0), "Nether Brick"));
$this->register(new Item(new IID(Ids::NETHER_QUARTZ, 0), "Nether Quartz"));
$this->register(new Item(new IID(Ids::NETHER_STAR, 0), "Nether Star"));
$this->register(new Item(new IID(Ids::PAPER, 0), "Paper"));
$this->register(new Item(new IID(Ids::PRISMARINE_CRYSTALS, 0), "Prismarine Crystals"));
$this->register(new Item(new IID(Ids::PRISMARINE_SHARD, 0), "Prismarine Shard"));
$this->register(new Item(new IID(Ids::RABBIT_FOOT, 0), "Rabbit's Foot"));
$this->register(new Item(new IID(Ids::RABBIT_HIDE, 0), "Rabbit Hide"));
$this->register(new Item(new IID(Ids::SHULKER_SHELL, 0), "Shulker Shell"));
$this->register(new Item(new IID(Ids::SLIME_BALL, 0), "Slimeball"));
$this->register(new Item(new IID(Ids::SUGAR, 0), "Sugar"));
$this->register(new Item(new IID(Ids::TURTLE_SHELL_PIECE, 0), "Scute"));
$this->register(new Item(new IID(Ids::WHEAT, 0), "Wheat"));
$this->register(new ItemBlock(new IID(Ids::ACACIA_DOOR, 0), Blocks::ACACIA_DOOR()));
$this->register(new ItemBlock(new IID(Ids::BIRCH_DOOR, 0), Blocks::BIRCH_DOOR()));
$this->register(new ItemBlock(new IID(Ids::BREWING_STAND, 0), Blocks::BREWING_STAND()));
$this->register(new ItemBlock(new IID(Ids::CAKE, 0), Blocks::CAKE()));
$this->register(new ItemBlock(new IID(Ids::COMPARATOR, 0), Blocks::REDSTONE_COMPARATOR()));
$this->register(new ItemBlock(new IID(Ids::DARK_OAK_DOOR, 0), Blocks::DARK_OAK_DOOR()));
$this->register(new ItemBlock(new IID(Ids::FLOWER_POT, 0), Blocks::FLOWER_POT()));
$this->register(new ItemBlock(new IID(Ids::HOPPER, 0), Blocks::HOPPER()));
$this->register(new ItemBlock(new IID(Ids::IRON_DOOR, 0), Blocks::IRON_DOOR()));
$this->register(new ItemBlock(new IID(Ids::ITEM_FRAME, 0), Blocks::ITEM_FRAME()));
$this->register(new ItemBlock(new IID(Ids::JUNGLE_DOOR, 0), Blocks::JUNGLE_DOOR()));
$this->register(new ItemBlock(new IID(Ids::NETHER_WART, 0), Blocks::NETHER_WART()));
$this->register(new ItemBlock(new IID(Ids::OAK_DOOR, 0), Blocks::OAK_DOOR()));
$this->register(new ItemBlock(new IID(Ids::REPEATER, 0), Blocks::REDSTONE_REPEATER()));
$this->register(new ItemBlock(new IID(Ids::SPRUCE_DOOR, 0), Blocks::SPRUCE_DOOR()));
$this->register(new ItemBlock(new IID(Ids::SUGARCANE, 0), Blocks::SUGARCANE()));
$this->register(new Coal(new IID(Ids::CHARCOAL, LegacyIds::COAL, 1), "Charcoal"));
$this->register(new CocoaBeans(new IID(Ids::COCOA_BEANS, LegacyIds::DYE, 3), "Cocoa Beans"));
$this->register(new Compass(new IID(Ids::COMPASS, LegacyIds::COMPASS, 0), "Compass"));
$this->register(new CookedChicken(new IID(Ids::COOKED_CHICKEN, LegacyIds::COOKED_CHICKEN, 0), "Cooked Chicken"));
$this->register(new CookedFish(new IID(Ids::COOKED_FISH, LegacyIds::COOKED_FISH, 0), "Cooked Fish"));
$this->register(new CookedMutton(new IID(Ids::COOKED_MUTTON, LegacyIds::COOKED_MUTTON, 0), "Cooked Mutton"));
$this->register(new CookedPorkchop(new IID(Ids::COOKED_PORKCHOP, LegacyIds::COOKED_PORKCHOP, 0), "Cooked Porkchop"));
$this->register(new CookedRabbit(new IID(Ids::COOKED_RABBIT, LegacyIds::COOKED_RABBIT, 0), "Cooked Rabbit"));
$this->register(new CookedSalmon(new IID(Ids::COOKED_SALMON, LegacyIds::COOKED_SALMON, 0), "Cooked Salmon"));
$this->register(new Cookie(new IID(Ids::COOKIE, LegacyIds::COOKIE, 0), "Cookie"));
$this->register(new DriedKelp(new IID(Ids::DRIED_KELP, LegacyIds::DRIED_KELP, 0), "Dried Kelp"));
$this->register(new Egg(new IID(Ids::EGG, LegacyIds::EGG, 0), "Egg"));
$this->register(new EnderPearl(new IID(Ids::ENDER_PEARL, LegacyIds::ENDER_PEARL, 0), "Ender Pearl"));
$this->register(new ExperienceBottle(new IID(Ids::EXPERIENCE_BOTTLE, LegacyIds::EXPERIENCE_BOTTLE, 0), "Bottle o' Enchanting"));
$this->register(new Fertilizer(new IID(Ids::BONE_MEAL, LegacyIds::DYE, 15), "Bone Meal"));
$this->register(new FishingRod(new IID(Ids::FISHING_ROD, LegacyIds::FISHING_ROD, 0), "Fishing Rod"));
$this->register(new FlintSteel(new IID(Ids::FLINT_AND_STEEL, LegacyIds::FLINT_STEEL, 0), "Flint and Steel"));
$this->register(new GlassBottle(new IID(Ids::GLASS_BOTTLE, LegacyIds::GLASS_BOTTLE, 0), "Glass Bottle"));
$this->register(new GoldenApple(new IID(Ids::GOLDEN_APPLE, LegacyIds::GOLDEN_APPLE, 0), "Golden Apple"));
$this->register(new GoldenAppleEnchanted(new IID(Ids::ENCHANTED_GOLDEN_APPLE, LegacyIds::ENCHANTED_GOLDEN_APPLE, 0), "Enchanted Golden Apple"));
$this->register(new GoldenCarrot(new IID(Ids::GOLDEN_CARROT, LegacyIds::GOLDEN_CARROT, 0), "Golden Carrot"));
$this->register(new Item(new IID(Ids::BLAZE_POWDER, LegacyIds::BLAZE_POWDER, 0), "Blaze Powder"));
$this->register(new Item(new IID(Ids::BLEACH, LegacyIds::BLEACH, 0), "Bleach")); //EDU
$this->register(new Item(new IID(Ids::BONE, LegacyIds::BONE, 0), "Bone"));
$this->register(new Item(new IID(Ids::BRICK, LegacyIds::BRICK, 0), "Brick"));
$this->register(new Item(new IID(Ids::POPPED_CHORUS_FRUIT, LegacyIds::CHORUS_FRUIT_POPPED, 0), "Popped Chorus Fruit"));
$this->register(new Item(new IID(Ids::CLAY, LegacyIds::CLAY_BALL, 0), "Clay"));
$this->register(new Item(new IID(Ids::CHEMICAL_SALT, LegacyIds::COMPOUND, CompoundTypeIds::SALT), "Salt"));
$this->register(new Item(new IID(Ids::CHEMICAL_SODIUM_OXIDE, LegacyIds::COMPOUND, CompoundTypeIds::SODIUM_OXIDE), "Sodium Oxide"));
$this->register(new Item(new IID(Ids::CHEMICAL_SODIUM_HYDROXIDE, LegacyIds::COMPOUND, CompoundTypeIds::SODIUM_HYDROXIDE), "Sodium Hydroxide"));
$this->register(new Item(new IID(Ids::CHEMICAL_MAGNESIUM_NITRATE, LegacyIds::COMPOUND, CompoundTypeIds::MAGNESIUM_NITRATE), "Magnesium Nitrate"));
$this->register(new Item(new IID(Ids::CHEMICAL_IRON_SULPHIDE, LegacyIds::COMPOUND, CompoundTypeIds::IRON_SULPHIDE), "Iron Sulphide"));
$this->register(new Item(new IID(Ids::CHEMICAL_LITHIUM_HYDRIDE, LegacyIds::COMPOUND, CompoundTypeIds::LITHIUM_HYDRIDE), "Lithium Hydride"));
$this->register(new Item(new IID(Ids::CHEMICAL_SODIUM_HYDRIDE, LegacyIds::COMPOUND, CompoundTypeIds::SODIUM_HYDRIDE), "Sodium Hydride"));
$this->register(new Item(new IID(Ids::CHEMICAL_CALCIUM_BROMIDE, LegacyIds::COMPOUND, CompoundTypeIds::CALCIUM_BROMIDE), "Calcium Bromide"));
$this->register(new Item(new IID(Ids::CHEMICAL_MAGNESIUM_OXIDE, LegacyIds::COMPOUND, CompoundTypeIds::MAGNESIUM_OXIDE), "Magnesium Oxide"));
$this->register(new Item(new IID(Ids::CHEMICAL_SODIUM_ACETATE, LegacyIds::COMPOUND, CompoundTypeIds::SODIUM_ACETATE), "Sodium Acetate"));
$this->register(new Item(new IID(Ids::CHEMICAL_LUMINOL, LegacyIds::COMPOUND, CompoundTypeIds::LUMINOL), "Luminol"));
$this->register(new Item(new IID(Ids::CHEMICAL_CHARCOAL, LegacyIds::COMPOUND, CompoundTypeIds::CHARCOAL), "Charcoal")); //??? maybe bug
$this->register(new Item(new IID(Ids::CHEMICAL_SUGAR, LegacyIds::COMPOUND, CompoundTypeIds::SUGAR), "Sugar")); //??? maybe bug
$this->register(new Item(new IID(Ids::CHEMICAL_ALUMINIUM_OXIDE, LegacyIds::COMPOUND, CompoundTypeIds::ALUMINIUM_OXIDE), "Aluminium Oxide"));
$this->register(new Item(new IID(Ids::CHEMICAL_BORON_TRIOXIDE, LegacyIds::COMPOUND, CompoundTypeIds::BORON_TRIOXIDE), "Boron Trioxide"));
$this->register(new Item(new IID(Ids::CHEMICAL_SOAP, LegacyIds::COMPOUND, CompoundTypeIds::SOAP), "Soap"));
$this->register(new Item(new IID(Ids::CHEMICAL_POLYETHYLENE, LegacyIds::COMPOUND, CompoundTypeIds::POLYETHYLENE), "Polyethylene"));
$this->register(new Item(new IID(Ids::CHEMICAL_RUBBISH, LegacyIds::COMPOUND, CompoundTypeIds::RUBBISH), "Rubbish"));
$this->register(new Item(new IID(Ids::CHEMICAL_MAGNESIUM_SALTS, LegacyIds::COMPOUND, CompoundTypeIds::MAGNESIUM_SALTS), "Magnesium Salts"));
$this->register(new Item(new IID(Ids::CHEMICAL_SULPHATE, LegacyIds::COMPOUND, CompoundTypeIds::SULPHATE), "Sulphate"));
$this->register(new Item(new IID(Ids::CHEMICAL_BARIUM_SULPHATE, LegacyIds::COMPOUND, CompoundTypeIds::BARIUM_SULPHATE), "Barium Sulphate"));
$this->register(new Item(new IID(Ids::CHEMICAL_POTASSIUM_CHLORIDE, LegacyIds::COMPOUND, CompoundTypeIds::POTASSIUM_CHLORIDE), "Potassium Chloride"));
$this->register(new Item(new IID(Ids::CHEMICAL_MERCURIC_CHLORIDE, LegacyIds::COMPOUND, CompoundTypeIds::MERCURIC_CHLORIDE), "Mercuric Chloride"));
$this->register(new Item(new IID(Ids::CHEMICAL_CERIUM_CHLORIDE, LegacyIds::COMPOUND, CompoundTypeIds::CERIUM_CHLORIDE), "Cerium Chloride"));
$this->register(new Item(new IID(Ids::CHEMICAL_TUNGSTEN_CHLORIDE, LegacyIds::COMPOUND, CompoundTypeIds::TUNGSTEN_CHLORIDE), "Tungsten Chloride"));
$this->register(new Item(new IID(Ids::CHEMICAL_CALCIUM_CHLORIDE, LegacyIds::COMPOUND, CompoundTypeIds::CALCIUM_CHLORIDE), "Calcium Chloride"));
$this->register(new Item(new IID(Ids::CHEMICAL_WATER, LegacyIds::COMPOUND, CompoundTypeIds::WATER), "Water")); //???
$this->register(new Item(new IID(Ids::CHEMICAL_GLUE, LegacyIds::COMPOUND, CompoundTypeIds::GLUE), "Glue"));
$this->register(new Item(new IID(Ids::CHEMICAL_HYPOCHLORITE, LegacyIds::COMPOUND, CompoundTypeIds::HYPOCHLORITE), "Hypochlorite"));
$this->register(new Item(new IID(Ids::CHEMICAL_CRUDE_OIL, LegacyIds::COMPOUND, CompoundTypeIds::CRUDE_OIL), "Crude Oil"));
$this->register(new Item(new IID(Ids::CHEMICAL_LATEX, LegacyIds::COMPOUND, CompoundTypeIds::LATEX), "Latex"));
$this->register(new Item(new IID(Ids::CHEMICAL_POTASSIUM_IODIDE, LegacyIds::COMPOUND, CompoundTypeIds::POTASSIUM_IODIDE), "Potassium Iodide"));
$this->register(new Item(new IID(Ids::CHEMICAL_SODIUM_FLUORIDE, LegacyIds::COMPOUND, CompoundTypeIds::SODIUM_FLUORIDE), "Sodium Fluoride"));
$this->register(new Item(new IID(Ids::CHEMICAL_BENZENE, LegacyIds::COMPOUND, CompoundTypeIds::BENZENE), "Benzene"));
$this->register(new Item(new IID(Ids::CHEMICAL_INK, LegacyIds::COMPOUND, CompoundTypeIds::INK), "Ink"));
$this->register(new Item(new IID(Ids::CHEMICAL_HYDROGEN_PEROXIDE, LegacyIds::COMPOUND, CompoundTypeIds::HYDROGEN_PEROXIDE), "Hydrogen Peroxide"));
$this->register(new Item(new IID(Ids::CHEMICAL_AMMONIA, LegacyIds::COMPOUND, CompoundTypeIds::AMMONIA), "Ammonia"));
$this->register(new Item(new IID(Ids::CHEMICAL_SODIUM_HYPOCHLORITE, LegacyIds::COMPOUND, CompoundTypeIds::SODIUM_HYPOCHLORITE), "Sodium Hypochlorite"));
$this->register(new Item(new IID(Ids::DIAMOND, LegacyIds::DIAMOND, 0), "Diamond"));
$this->register(new Item(new IID(Ids::DRAGON_BREATH, LegacyIds::DRAGON_BREATH, 0), "Dragon's Breath"));
$this->register(new Item(new IID(Ids::INK_SAC, LegacyIds::DYE, 0), "Ink Sac"));
$this->register(new Item(new IID(Ids::LAPIS_LAZULI, LegacyIds::DYE, 4), "Lapis Lazuli"));
$this->register(new Item(new IID(Ids::EMERALD, LegacyIds::EMERALD, 0), "Emerald"));
$this->register(new Item(new IID(Ids::FEATHER, LegacyIds::FEATHER, 0), "Feather"));
$this->register(new Item(new IID(Ids::FERMENTED_SPIDER_EYE, LegacyIds::FERMENTED_SPIDER_EYE, 0), "Fermented Spider Eye"));
$this->register(new Item(new IID(Ids::FLINT, LegacyIds::FLINT, 0), "Flint"));
$this->register(new Item(new IID(Ids::GHAST_TEAR, LegacyIds::GHAST_TEAR, 0), "Ghast Tear"));
$this->register(new Item(new IID(Ids::GLISTERING_MELON, LegacyIds::GLISTERING_MELON, 0), "Glistering Melon"));
$this->register(new Item(new IID(Ids::GLOWSTONE_DUST, LegacyIds::GLOWSTONE_DUST, 0), "Glowstone Dust"));
$this->register(new Item(new IID(Ids::GOLD_INGOT, LegacyIds::GOLD_INGOT, 0), "Gold Ingot"));
$this->register(new Item(new IID(Ids::GOLD_NUGGET, LegacyIds::GOLD_NUGGET, 0), "Gold Nugget"));
$this->register(new Item(new IID(Ids::GUNPOWDER, LegacyIds::GUNPOWDER, 0), "Gunpowder"));
$this->register(new Item(new IID(Ids::HEART_OF_THE_SEA, LegacyIds::HEART_OF_THE_SEA, 0), "Heart of the Sea"));
$this->register(new Item(new IID(Ids::IRON_INGOT, LegacyIds::IRON_INGOT, 0), "Iron Ingot"));
$this->register(new Item(new IID(Ids::IRON_NUGGET, LegacyIds::IRON_NUGGET, 0), "Iron Nugget"));
$this->register(new Item(new IID(Ids::LEATHER, LegacyIds::LEATHER, 0), "Leather"));
$this->register(new Item(new IID(Ids::MAGMA_CREAM, LegacyIds::MAGMA_CREAM, 0), "Magma Cream"));
$this->register(new Item(new IID(Ids::NAUTILUS_SHELL, LegacyIds::NAUTILUS_SHELL, 0), "Nautilus Shell"));
$this->register(new Item(new IID(Ids::NETHER_BRICK, LegacyIds::NETHER_BRICK, 0), "Nether Brick"));
$this->register(new Item(new IID(Ids::NETHER_QUARTZ, LegacyIds::NETHER_QUARTZ, 0), "Nether Quartz"));
$this->register(new Item(new IID(Ids::NETHER_STAR, LegacyIds::NETHER_STAR, 0), "Nether Star"));
$this->register(new Item(new IID(Ids::PAPER, LegacyIds::PAPER, 0), "Paper"));
$this->register(new Item(new IID(Ids::PRISMARINE_CRYSTALS, LegacyIds::PRISMARINE_CRYSTALS, 0), "Prismarine Crystals"));
$this->register(new Item(new IID(Ids::PRISMARINE_SHARD, LegacyIds::PRISMARINE_SHARD, 0), "Prismarine Shard"));
$this->register(new Item(new IID(Ids::RABBIT_FOOT, LegacyIds::RABBIT_FOOT, 0), "Rabbit's Foot"));
$this->register(new Item(new IID(Ids::RABBIT_HIDE, LegacyIds::RABBIT_HIDE, 0), "Rabbit Hide"));
$this->register(new Item(new IID(Ids::SHULKER_SHELL, LegacyIds::SHULKER_SHELL, 0), "Shulker Shell"));
$this->register(new Item(new IID(Ids::SLIMEBALL, LegacyIds::SLIME_BALL, 0), "Slimeball"));
$this->register(new Item(new IID(Ids::SUGAR, LegacyIds::SUGAR, 0), "Sugar"));
$this->register(new Item(new IID(Ids::SCUTE, LegacyIds::TURTLE_SHELL_PIECE, 0), "Scute"));
$this->register(new Item(new IID(Ids::WHEAT, LegacyIds::WHEAT, 0), "Wheat"));
//these blocks have special legacy item IDs, so they need to be registered explicitly
$this->register(new ItemBlock(Blocks::ACACIA_DOOR()));
$this->register(new ItemBlock(Blocks::BIRCH_DOOR()));
$this->register(new ItemBlock(Blocks::BREWING_STAND()));
$this->register(new ItemBlock(Blocks::CAKE()));
$this->register(new ItemBlock(Blocks::REDSTONE_COMPARATOR()));
$this->register(new ItemBlock(Blocks::DARK_OAK_DOOR()));
$this->register(new ItemBlock(Blocks::FLOWER_POT()));
$this->register(new ItemBlock(Blocks::HOPPER()));
$this->register(new ItemBlock(Blocks::IRON_DOOR()));
$this->register(new ItemBlock(Blocks::ITEM_FRAME()));
$this->register(new ItemBlock(Blocks::JUNGLE_DOOR()));
$this->register(new ItemBlock(Blocks::NETHER_WART()));
$this->register(new ItemBlock(Blocks::OAK_DOOR()));
$this->register(new ItemBlock(Blocks::REDSTONE_REPEATER()));
$this->register(new ItemBlock(Blocks::SPRUCE_DOOR()));
$this->register(new ItemBlock(Blocks::SUGARCANE()));
//the meta values for buckets are intentionally hardcoded because block IDs will change in the future
$waterBucket = new LiquidBucket(new IID(Ids::BUCKET, 8), "Water Bucket", Blocks::WATER());
$waterBucket = new LiquidBucket(new IID(Ids::WATER_BUCKET, LegacyIds::BUCKET, 8), "Water Bucket", Blocks::WATER());
$this->register($waterBucket);
$this->remap(new IID(Ids::BUCKET, 9), $waterBucket);
$lavaBucket = new LiquidBucket(new IID(Ids::BUCKET, 10), "Lava Bucket", Blocks::LAVA());
$this->remap(LegacyIds::BUCKET, 9, $waterBucket);
$lavaBucket = new LiquidBucket(new IID(Ids::LAVA_BUCKET, LegacyIds::BUCKET, 10), "Lava Bucket", Blocks::LAVA());
$this->register($lavaBucket);
$this->remap(new IID(Ids::BUCKET, 11), $lavaBucket);
$this->register(new Melon(new IID(Ids::MELON, 0), "Melon"));
$this->register(new MelonSeeds(new IID(Ids::MELON_SEEDS, 0), "Melon Seeds"));
$this->register(new MilkBucket(new IID(Ids::BUCKET, 1), "Milk Bucket"));
$this->register(new Minecart(new IID(Ids::MINECART, 0), "Minecart"));
$this->register(new MushroomStew(new IID(Ids::MUSHROOM_STEW, 0), "Mushroom Stew"));
$this->register(new PaintingItem(new IID(Ids::PAINTING, 0), "Painting"));
$this->register(new PoisonousPotato(new IID(Ids::POISONOUS_POTATO, 0), "Poisonous Potato"));
$this->register(new Potato(new IID(Ids::POTATO, 0), "Potato"));
$this->register(new Pufferfish(new IID(Ids::PUFFERFISH, 0), "Pufferfish"));
$this->register(new PumpkinPie(new IID(Ids::PUMPKIN_PIE, 0), "Pumpkin Pie"));
$this->register(new PumpkinSeeds(new IID(Ids::PUMPKIN_SEEDS, 0), "Pumpkin Seeds"));
$this->register(new RabbitStew(new IID(Ids::RABBIT_STEW, 0), "Rabbit Stew"));
$this->register(new RawBeef(new IID(Ids::RAW_BEEF, 0), "Raw Beef"));
$this->register(new RawChicken(new IID(Ids::RAW_CHICKEN, 0), "Raw Chicken"));
$this->register(new RawFish(new IID(Ids::RAW_FISH, 0), "Raw Fish"));
$this->register(new RawMutton(new IID(Ids::RAW_MUTTON, 0), "Raw Mutton"));
$this->register(new RawPorkchop(new IID(Ids::RAW_PORKCHOP, 0), "Raw Porkchop"));
$this->register(new RawRabbit(new IID(Ids::RAW_RABBIT, 0), "Raw Rabbit"));
$this->register(new RawSalmon(new IID(Ids::RAW_SALMON, 0), "Raw Salmon"));
$this->register(new Record(new IID(Ids::RECORD_13, 0), RecordType::DISK_13(), "Record 13"));
$this->register(new Record(new IID(Ids::RECORD_CAT, 0), RecordType::DISK_CAT(), "Record Cat"));
$this->register(new Record(new IID(Ids::RECORD_BLOCKS, 0), RecordType::DISK_BLOCKS(), "Record Blocks"));
$this->register(new Record(new IID(Ids::RECORD_CHIRP, 0), RecordType::DISK_CHIRP(), "Record Chirp"));
$this->register(new Record(new IID(Ids::RECORD_FAR, 0), RecordType::DISK_FAR(), "Record Far"));
$this->register(new Record(new IID(Ids::RECORD_MALL, 0), RecordType::DISK_MALL(), "Record Mall"));
$this->register(new Record(new IID(Ids::RECORD_MELLOHI, 0), RecordType::DISK_MELLOHI(), "Record Mellohi"));
$this->register(new Record(new IID(Ids::RECORD_STAL, 0), RecordType::DISK_STAL(), "Record Stal"));
$this->register(new Record(new IID(Ids::RECORD_STRAD, 0), RecordType::DISK_STRAD(), "Record Strad"));
$this->register(new Record(new IID(Ids::RECORD_WARD, 0), RecordType::DISK_WARD(), "Record Ward"));
$this->register(new Record(new IID(Ids::RECORD_11, 0), RecordType::DISK_11(), "Record 11"));
$this->register(new Record(new IID(Ids::RECORD_WAIT, 0), RecordType::DISK_WAIT(), "Record Wait"));
$this->register(new Redstone(new IID(Ids::REDSTONE, 0), "Redstone"));
$this->register(new RottenFlesh(new IID(Ids::ROTTEN_FLESH, 0), "Rotten Flesh"));
$this->register(new Shears(new IID(Ids::SHEARS, 0), "Shears"));
$this->register(new ItemBlockWallOrFloor(new IID(Ids::SIGN, 0), Blocks::OAK_SIGN(), Blocks::OAK_WALL_SIGN()));
$this->register(new ItemBlockWallOrFloor(new IID(Ids::SPRUCE_SIGN, 0), Blocks::SPRUCE_SIGN(), Blocks::SPRUCE_WALL_SIGN()));
$this->register(new ItemBlockWallOrFloor(new IID(Ids::BIRCH_SIGN, 0), Blocks::BIRCH_SIGN(), Blocks::BIRCH_WALL_SIGN()));
$this->register(new ItemBlockWallOrFloor(new IID(Ids::JUNGLE_SIGN, 0), Blocks::JUNGLE_SIGN(), Blocks::JUNGLE_WALL_SIGN()));
$this->register(new ItemBlockWallOrFloor(new IID(Ids::ACACIA_SIGN, 0), Blocks::ACACIA_SIGN(), Blocks::ACACIA_WALL_SIGN()));
$this->register(new ItemBlockWallOrFloor(new IID(Ids::DARKOAK_SIGN, 0), Blocks::DARK_OAK_SIGN(), Blocks::DARK_OAK_WALL_SIGN()));
$this->register(new Snowball(new IID(Ids::SNOWBALL, 0), "Snowball"));
$this->register(new SpiderEye(new IID(Ids::SPIDER_EYE, 0), "Spider Eye"));
$this->register(new Steak(new IID(Ids::STEAK, 0), "Steak"));
$this->register(new Stick(new IID(Ids::STICK, 0), "Stick"));
$this->register(new StringItem(new IID(Ids::STRING, 0), "String"));
$this->register(new SweetBerries(new IID(Ids::SWEET_BERRIES, 0), "Sweet Berries"));
$this->register(new Totem(new IID(Ids::TOTEM, 0), "Totem of Undying"));
$this->register(new WheatSeeds(new IID(Ids::WHEAT_SEEDS, 0), "Wheat Seeds"));
$this->register(new WritableBook(new IID(Ids::WRITABLE_BOOK, 0), "Book & Quill"));
$this->register(new WrittenBook(new IID(Ids::WRITTEN_BOOK, 0), "Written Book"));
$this->remap(LegacyIds::BUCKET, 11, $lavaBucket);
$this->register(new Melon(new IID(Ids::MELON, LegacyIds::MELON, 0), "Melon"));
$this->register(new MelonSeeds(new IID(Ids::MELON_SEEDS, LegacyIds::MELON_SEEDS, 0), "Melon Seeds"));
$this->register(new MilkBucket(new IID(Ids::MILK_BUCKET, LegacyIds::BUCKET, 1), "Milk Bucket"));
$this->register(new Minecart(new IID(Ids::MINECART, LegacyIds::MINECART, 0), "Minecart"));
$this->register(new MushroomStew(new IID(Ids::MUSHROOM_STEW, LegacyIds::MUSHROOM_STEW, 0), "Mushroom Stew"));
$this->register(new PaintingItem(new IID(Ids::PAINTING, LegacyIds::PAINTING, 0), "Painting"));
$this->register(new PoisonousPotato(new IID(Ids::POISONOUS_POTATO, LegacyIds::POISONOUS_POTATO, 0), "Poisonous Potato"));
$this->register(new Potato(new IID(Ids::POTATO, LegacyIds::POTATO, 0), "Potato"));
$this->register(new Pufferfish(new IID(Ids::PUFFERFISH, LegacyIds::PUFFERFISH, 0), "Pufferfish"));
$this->register(new PumpkinPie(new IID(Ids::PUMPKIN_PIE, LegacyIds::PUMPKIN_PIE, 0), "Pumpkin Pie"));
$this->register(new PumpkinSeeds(new IID(Ids::PUMPKIN_SEEDS, LegacyIds::PUMPKIN_SEEDS, 0), "Pumpkin Seeds"));
$this->register(new RabbitStew(new IID(Ids::RABBIT_STEW, LegacyIds::RABBIT_STEW, 0), "Rabbit Stew"));
$this->register(new RawBeef(new IID(Ids::RAW_BEEF, LegacyIds::RAW_BEEF, 0), "Raw Beef"));
$this->register(new RawChicken(new IID(Ids::RAW_CHICKEN, LegacyIds::RAW_CHICKEN, 0), "Raw Chicken"));
$this->register(new RawFish(new IID(Ids::RAW_FISH, LegacyIds::RAW_FISH, 0), "Raw Fish"));
$this->register(new RawMutton(new IID(Ids::RAW_MUTTON, LegacyIds::RAW_MUTTON, 0), "Raw Mutton"));
$this->register(new RawPorkchop(new IID(Ids::RAW_PORKCHOP, LegacyIds::RAW_PORKCHOP, 0), "Raw Porkchop"));
$this->register(new RawRabbit(new IID(Ids::RAW_RABBIT, LegacyIds::RAW_RABBIT, 0), "Raw Rabbit"));
$this->register(new RawSalmon(new IID(Ids::RAW_SALMON, LegacyIds::RAW_SALMON, 0), "Raw Salmon"));
$this->register(new Record(new IID(Ids::RECORD_13, LegacyIds::RECORD_13, 0), RecordType::DISK_13(), "Record 13"));
$this->register(new Record(new IID(Ids::RECORD_CAT, LegacyIds::RECORD_CAT, 0), RecordType::DISK_CAT(), "Record Cat"));
$this->register(new Record(new IID(Ids::RECORD_BLOCKS, LegacyIds::RECORD_BLOCKS, 0), RecordType::DISK_BLOCKS(), "Record Blocks"));
$this->register(new Record(new IID(Ids::RECORD_CHIRP, LegacyIds::RECORD_CHIRP, 0), RecordType::DISK_CHIRP(), "Record Chirp"));
$this->register(new Record(new IID(Ids::RECORD_FAR, LegacyIds::RECORD_FAR, 0), RecordType::DISK_FAR(), "Record Far"));
$this->register(new Record(new IID(Ids::RECORD_MALL, LegacyIds::RECORD_MALL, 0), RecordType::DISK_MALL(), "Record Mall"));
$this->register(new Record(new IID(Ids::RECORD_MELLOHI, LegacyIds::RECORD_MELLOHI, 0), RecordType::DISK_MELLOHI(), "Record Mellohi"));
$this->register(new Record(new IID(Ids::RECORD_STAL, LegacyIds::RECORD_STAL, 0), RecordType::DISK_STAL(), "Record Stal"));
$this->register(new Record(new IID(Ids::RECORD_STRAD, LegacyIds::RECORD_STRAD, 0), RecordType::DISK_STRAD(), "Record Strad"));
$this->register(new Record(new IID(Ids::RECORD_WARD, LegacyIds::RECORD_WARD, 0), RecordType::DISK_WARD(), "Record Ward"));
$this->register(new Record(new IID(Ids::RECORD_11, LegacyIds::RECORD_11, 0), RecordType::DISK_11(), "Record 11"));
$this->register(new Record(new IID(Ids::RECORD_WAIT, LegacyIds::RECORD_WAIT, 0), RecordType::DISK_WAIT(), "Record Wait"));
$this->register(new Redstone(new IID(Ids::REDSTONE_DUST, LegacyIds::REDSTONE, 0), "Redstone"));
$this->register(new RottenFlesh(new IID(Ids::ROTTEN_FLESH, LegacyIds::ROTTEN_FLESH, 0), "Rotten Flesh"));
$this->register(new Shears(new IID(Ids::SHEARS, LegacyIds::SHEARS, 0), "Shears"));
$this->register(new ItemBlockWallOrFloor(new IID(Ids::OAK_SIGN, LegacyIds::SIGN, 0), Blocks::OAK_SIGN(), Blocks::OAK_WALL_SIGN()));
$this->register(new ItemBlockWallOrFloor(new IID(Ids::SPRUCE_SIGN, LegacyIds::SPRUCE_SIGN, 0), Blocks::SPRUCE_SIGN(), Blocks::SPRUCE_WALL_SIGN()));
$this->register(new ItemBlockWallOrFloor(new IID(Ids::BIRCH_SIGN, LegacyIds::BIRCH_SIGN, 0), Blocks::BIRCH_SIGN(), Blocks::BIRCH_WALL_SIGN()));
$this->register(new ItemBlockWallOrFloor(new IID(Ids::JUNGLE_SIGN, LegacyIds::JUNGLE_SIGN, 0), Blocks::JUNGLE_SIGN(), Blocks::JUNGLE_WALL_SIGN()));
$this->register(new ItemBlockWallOrFloor(new IID(Ids::ACACIA_SIGN, LegacyIds::ACACIA_SIGN, 0), Blocks::ACACIA_SIGN(), Blocks::ACACIA_WALL_SIGN()));
$this->register(new ItemBlockWallOrFloor(new IID(Ids::DARK_OAK_SIGN, LegacyIds::DARKOAK_SIGN, 0), Blocks::DARK_OAK_SIGN(), Blocks::DARK_OAK_WALL_SIGN()));
$this->register(new Snowball(new IID(Ids::SNOWBALL, LegacyIds::SNOWBALL, 0), "Snowball"));
$this->register(new SpiderEye(new IID(Ids::SPIDER_EYE, LegacyIds::SPIDER_EYE, 0), "Spider Eye"));
$this->register(new Steak(new IID(Ids::STEAK, LegacyIds::STEAK, 0), "Steak"));
$this->register(new Stick(new IID(Ids::STICK, LegacyIds::STICK, 0), "Stick"));
$this->register(new StringItem(new IID(Ids::STRING, LegacyIds::STRING, 0), "String"));
$this->register(new SweetBerries(new IID(Ids::SWEET_BERRIES, LegacyIds::SWEET_BERRIES, 0), "Sweet Berries"));
$this->register(new Totem(new IID(Ids::TOTEM, LegacyIds::TOTEM, 0), "Totem of Undying"));
$this->register(new WheatSeeds(new IID(Ids::WHEAT_SEEDS, LegacyIds::WHEAT_SEEDS, 0), "Wheat Seeds"));
$this->register(new WritableBook(new IID(Ids::WRITABLE_BOOK, LegacyIds::WRITABLE_BOOK, 0), "Book & Quill"));
$this->register(new WrittenBook(new IID(Ids::WRITTEN_BOOK, LegacyIds::WRITTEN_BOOK, 0), "Written Book"));
foreach(SkullType::getAll() as $skullType){
$this->register((new Skull(new IID(Ids::SKULL, 0), "Mob Head"))->setSkullType($skullType));
$this->register((new Skull(new IID(Ids::MOB_HEAD, LegacyIds::SKULL, 0), "Mob Head"))->setSkullType($skullType));
}
foreach(DyeColor::getAll() as $color){
//TODO: use colour object directly
//TODO: add interface to dye-colour objects
//1000 isn't the real variant for dye, but it needs to not conflict with INK_SAC
$this->register((new Dye(new IID(Ids::DYE, 1000), "Dye"))->setColor($color));
$this->register((new Bed(new IID(Ids::BED, 0), "Bed"))->setColor($color));
$this->register((new Dye(new IID(Ids::DYE, LegacyIds::DYE, 0), "Dye"))->setColor($color));
$this->register((new Bed(new IID(Ids::BED, LegacyIds::BED, 0), "Bed"))->setColor($color));
$this->register((new Banner(
new IID(Ids::BANNER, 0),
new IID(Ids::BANNER, LegacyIds::BANNER, 0),
Blocks::BANNER(),
Blocks::WALL_BANNER()
))->setColor($color));
}
foreach(PotionType::getAll() as $type){
$this->register((new Potion(new IID(Ids::POTION, 0), "Potion"))->setType($type));
$this->register((new SplashPotion(new IID(Ids::SPLASH_POTION, 0), "Splash Potion"))->setType($type));
$this->register((new Potion(new IID(Ids::POTION, LegacyIds::POTION, 0), "Potion"))->setType($type));
$this->register((new SplashPotion(new IID(Ids::SPLASH_POTION, LegacyIds::SPLASH_POTION, 0), "Splash Potion"))->setType($type));
}
foreach(TreeType::getAll() as $type){
$this->register(new Boat(new IID(Ids::BOAT, $type->getMagicNumber()), $type->getDisplayName() . " Boat", $type));
//TODO: tree type should be dynamic in the future, but we're staying static for now for the sake of consistency
$this->register(new Boat(new IID(match($type){
TreeType::OAK() => Ids::OAK_BOAT,
TreeType::SPRUCE() => Ids::SPRUCE_BOAT,
TreeType::BIRCH() => Ids::BIRCH_BOAT,
TreeType::JUNGLE() => Ids::JUNGLE_BOAT,
TreeType::ACACIA() => Ids::ACACIA_BOAT,
TreeType::DARK_OAK() => Ids::DARK_OAK_BOAT,
default => throw new AssumptionFailedError("Unhandled tree type " . $type->name())
}, LegacyIds::BOAT, $type->getMagicNumber()), $type->getDisplayName() . " Boat", $type));
}
//region --- auto-generated TODOs ---
@ -336,17 +347,17 @@ class ItemFactory{
private function registerSpawnEggs() : void{
//TODO: the meta values should probably be hardcoded; they won't change, but the EntityLegacyIds might
$this->register(new class(new IID(Ids::SPAWN_EGG, EntityLegacyIds::ZOMBIE), "Zombie Spawn Egg") extends SpawnEgg{
$this->register(new class(new IID(Ids::ZOMBIE_SPAWN_EGG, LegacyIds::SPAWN_EGG, EntityLegacyIds::ZOMBIE), "Zombie Spawn Egg") extends SpawnEgg{
protected function createEntity(World $world, Vector3 $pos, float $yaw, float $pitch) : Entity{
return new Zombie(Location::fromObject($pos, $world, $yaw, $pitch));
}
});
$this->register(new class(new IID(Ids::SPAWN_EGG, EntityLegacyIds::SQUID), "Squid Spawn Egg") extends SpawnEgg{
$this->register(new class(new IID(Ids::SQUID_SPAWN_EGG, LegacyIds::SPAWN_EGG, EntityLegacyIds::SQUID), "Squid Spawn Egg") extends SpawnEgg{
public function createEntity(World $world, Vector3 $pos, float $yaw, float $pitch) : Entity{
return new Squid(Location::fromObject($pos, $world, $yaw, $pitch));
}
});
$this->register(new class(new IID(Ids::SPAWN_EGG, EntityLegacyIds::VILLAGER), "Villager Spawn Egg") extends SpawnEgg{
$this->register(new class(new IID(Ids::VILLAGER_SPAWN_EGG, LegacyIds::SPAWN_EGG, EntityLegacyIds::VILLAGER), "Villager Spawn Egg") extends SpawnEgg{
public function createEntity(World $world, Vector3 $pos, float $yaw, float $pitch) : Entity{
return new Villager(Location::fromObject($pos, $world, $yaw, $pitch));
}
@ -354,54 +365,54 @@ class ItemFactory{
}
private function registerTierToolItems() : void{
$this->register(new Axe(new IID(Ids::DIAMOND_AXE, 0), "Diamond Axe", ToolTier::DIAMOND()));
$this->register(new Axe(new IID(Ids::GOLDEN_AXE, 0), "Golden Axe", ToolTier::GOLD()));
$this->register(new Axe(new IID(Ids::IRON_AXE, 0), "Iron Axe", ToolTier::IRON()));
$this->register(new Axe(new IID(Ids::STONE_AXE, 0), "Stone Axe", ToolTier::STONE()));
$this->register(new Axe(new IID(Ids::WOODEN_AXE, 0), "Wooden Axe", ToolTier::WOOD()));
$this->register(new Hoe(new IID(Ids::DIAMOND_HOE, 0), "Diamond Hoe", ToolTier::DIAMOND()));
$this->register(new Hoe(new IID(Ids::GOLDEN_HOE, 0), "Golden Hoe", ToolTier::GOLD()));
$this->register(new Hoe(new IID(Ids::IRON_HOE, 0), "Iron Hoe", ToolTier::IRON()));
$this->register(new Hoe(new IID(Ids::STONE_HOE, 0), "Stone Hoe", ToolTier::STONE()));
$this->register(new Hoe(new IID(Ids::WOODEN_HOE, 0), "Wooden Hoe", ToolTier::WOOD()));
$this->register(new Pickaxe(new IID(Ids::DIAMOND_PICKAXE, 0), "Diamond Pickaxe", ToolTier::DIAMOND()));
$this->register(new Pickaxe(new IID(Ids::GOLDEN_PICKAXE, 0), "Golden Pickaxe", ToolTier::GOLD()));
$this->register(new Pickaxe(new IID(Ids::IRON_PICKAXE, 0), "Iron Pickaxe", ToolTier::IRON()));
$this->register(new Pickaxe(new IID(Ids::STONE_PICKAXE, 0), "Stone Pickaxe", ToolTier::STONE()));
$this->register(new Pickaxe(new IID(Ids::WOODEN_PICKAXE, 0), "Wooden Pickaxe", ToolTier::WOOD()));
$this->register(new Shovel(new IID(Ids::DIAMOND_SHOVEL, 0), "Diamond Shovel", ToolTier::DIAMOND()));
$this->register(new Shovel(new IID(Ids::GOLDEN_SHOVEL, 0), "Golden Shovel", ToolTier::GOLD()));
$this->register(new Shovel(new IID(Ids::IRON_SHOVEL, 0), "Iron Shovel", ToolTier::IRON()));
$this->register(new Shovel(new IID(Ids::STONE_SHOVEL, 0), "Stone Shovel", ToolTier::STONE()));
$this->register(new Shovel(new IID(Ids::WOODEN_SHOVEL, 0), "Wooden Shovel", ToolTier::WOOD()));
$this->register(new Sword(new IID(Ids::DIAMOND_SWORD, 0), "Diamond Sword", ToolTier::DIAMOND()));
$this->register(new Sword(new IID(Ids::GOLDEN_SWORD, 0), "Golden Sword", ToolTier::GOLD()));
$this->register(new Sword(new IID(Ids::IRON_SWORD, 0), "Iron Sword", ToolTier::IRON()));
$this->register(new Sword(new IID(Ids::STONE_SWORD, 0), "Stone Sword", ToolTier::STONE()));
$this->register(new Sword(new IID(Ids::WOODEN_SWORD, 0), "Wooden Sword", ToolTier::WOOD()));
$this->register(new Axe(new IID(Ids::DIAMOND_AXE, LegacyIds::DIAMOND_AXE, 0), "Diamond Axe", ToolTier::DIAMOND()));
$this->register(new Axe(new IID(Ids::GOLDEN_AXE, LegacyIds::GOLDEN_AXE, 0), "Golden Axe", ToolTier::GOLD()));
$this->register(new Axe(new IID(Ids::IRON_AXE, LegacyIds::IRON_AXE, 0), "Iron Axe", ToolTier::IRON()));
$this->register(new Axe(new IID(Ids::STONE_AXE, LegacyIds::STONE_AXE, 0), "Stone Axe", ToolTier::STONE()));
$this->register(new Axe(new IID(Ids::WOODEN_AXE, LegacyIds::WOODEN_AXE, 0), "Wooden Axe", ToolTier::WOOD()));
$this->register(new Hoe(new IID(Ids::DIAMOND_HOE, LegacyIds::DIAMOND_HOE, 0), "Diamond Hoe", ToolTier::DIAMOND()));
$this->register(new Hoe(new IID(Ids::GOLDEN_HOE, LegacyIds::GOLDEN_HOE, 0), "Golden Hoe", ToolTier::GOLD()));
$this->register(new Hoe(new IID(Ids::IRON_HOE, LegacyIds::IRON_HOE, 0), "Iron Hoe", ToolTier::IRON()));
$this->register(new Hoe(new IID(Ids::STONE_HOE, LegacyIds::STONE_HOE, 0), "Stone Hoe", ToolTier::STONE()));
$this->register(new Hoe(new IID(Ids::WOODEN_HOE, LegacyIds::WOODEN_HOE, 0), "Wooden Hoe", ToolTier::WOOD()));
$this->register(new Pickaxe(new IID(Ids::DIAMOND_PICKAXE, LegacyIds::DIAMOND_PICKAXE, 0), "Diamond Pickaxe", ToolTier::DIAMOND()));
$this->register(new Pickaxe(new IID(Ids::GOLDEN_PICKAXE, LegacyIds::GOLDEN_PICKAXE, 0), "Golden Pickaxe", ToolTier::GOLD()));
$this->register(new Pickaxe(new IID(Ids::IRON_PICKAXE, LegacyIds::IRON_PICKAXE, 0), "Iron Pickaxe", ToolTier::IRON()));
$this->register(new Pickaxe(new IID(Ids::STONE_PICKAXE, LegacyIds::STONE_PICKAXE, 0), "Stone Pickaxe", ToolTier::STONE()));
$this->register(new Pickaxe(new IID(Ids::WOODEN_PICKAXE, LegacyIds::WOODEN_PICKAXE, 0), "Wooden Pickaxe", ToolTier::WOOD()));
$this->register(new Shovel(new IID(Ids::DIAMOND_SHOVEL, LegacyIds::DIAMOND_SHOVEL, 0), "Diamond Shovel", ToolTier::DIAMOND()));
$this->register(new Shovel(new IID(Ids::GOLDEN_SHOVEL, LegacyIds::GOLDEN_SHOVEL, 0), "Golden Shovel", ToolTier::GOLD()));
$this->register(new Shovel(new IID(Ids::IRON_SHOVEL, LegacyIds::IRON_SHOVEL, 0), "Iron Shovel", ToolTier::IRON()));
$this->register(new Shovel(new IID(Ids::STONE_SHOVEL, LegacyIds::STONE_SHOVEL, 0), "Stone Shovel", ToolTier::STONE()));
$this->register(new Shovel(new IID(Ids::WOODEN_SHOVEL, LegacyIds::WOODEN_SHOVEL, 0), "Wooden Shovel", ToolTier::WOOD()));
$this->register(new Sword(new IID(Ids::DIAMOND_SWORD, LegacyIds::DIAMOND_SWORD, 0), "Diamond Sword", ToolTier::DIAMOND()));
$this->register(new Sword(new IID(Ids::GOLDEN_SWORD, LegacyIds::GOLDEN_SWORD, 0), "Golden Sword", ToolTier::GOLD()));
$this->register(new Sword(new IID(Ids::IRON_SWORD, LegacyIds::IRON_SWORD, 0), "Iron Sword", ToolTier::IRON()));
$this->register(new Sword(new IID(Ids::STONE_SWORD, LegacyIds::STONE_SWORD, 0), "Stone Sword", ToolTier::STONE()));
$this->register(new Sword(new IID(Ids::WOODEN_SWORD, LegacyIds::WOODEN_SWORD, 0), "Wooden Sword", ToolTier::WOOD()));
}
private function registerArmorItems() : void{
$this->register(new Armor(new IID(Ids::CHAIN_BOOTS, 0), "Chainmail Boots", new ArmorTypeInfo(1, 196, ArmorInventory::SLOT_FEET)));
$this->register(new Armor(new IID(Ids::DIAMOND_BOOTS, 0), "Diamond Boots", new ArmorTypeInfo(3, 430, ArmorInventory::SLOT_FEET)));
$this->register(new Armor(new IID(Ids::GOLDEN_BOOTS, 0), "Golden Boots", new ArmorTypeInfo(1, 92, ArmorInventory::SLOT_FEET)));
$this->register(new Armor(new IID(Ids::IRON_BOOTS, 0), "Iron Boots", new ArmorTypeInfo(2, 196, ArmorInventory::SLOT_FEET)));
$this->register(new Armor(new IID(Ids::LEATHER_BOOTS, 0), "Leather Boots", new ArmorTypeInfo(1, 66, ArmorInventory::SLOT_FEET)));
$this->register(new Armor(new IID(Ids::CHAIN_CHESTPLATE, 0), "Chainmail Chestplate", new ArmorTypeInfo(5, 241, ArmorInventory::SLOT_CHEST)));
$this->register(new Armor(new IID(Ids::DIAMOND_CHESTPLATE, 0), "Diamond Chestplate", new ArmorTypeInfo(8, 529, ArmorInventory::SLOT_CHEST)));
$this->register(new Armor(new IID(Ids::GOLDEN_CHESTPLATE, 0), "Golden Chestplate", new ArmorTypeInfo(5, 113, ArmorInventory::SLOT_CHEST)));
$this->register(new Armor(new IID(Ids::IRON_CHESTPLATE, 0), "Iron Chestplate", new ArmorTypeInfo(6, 241, ArmorInventory::SLOT_CHEST)));
$this->register(new Armor(new IID(Ids::LEATHER_CHESTPLATE, 0), "Leather Tunic", new ArmorTypeInfo(3, 81, ArmorInventory::SLOT_CHEST)));
$this->register(new Armor(new IID(Ids::CHAIN_HELMET, 0), "Chainmail Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD)));
$this->register(new Armor(new IID(Ids::DIAMOND_HELMET, 0), "Diamond Helmet", new ArmorTypeInfo(3, 364, ArmorInventory::SLOT_HEAD)));
$this->register(new Armor(new IID(Ids::GOLDEN_HELMET, 0), "Golden Helmet", new ArmorTypeInfo(2, 78, ArmorInventory::SLOT_HEAD)));
$this->register(new Armor(new IID(Ids::IRON_HELMET, 0), "Iron Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD)));
$this->register(new Armor(new IID(Ids::LEATHER_HELMET, 0), "Leather Cap", new ArmorTypeInfo(1, 56, ArmorInventory::SLOT_HEAD)));
$this->register(new Armor(new IID(Ids::CHAIN_LEGGINGS, 0), "Chainmail Leggings", new ArmorTypeInfo(4, 226, ArmorInventory::SLOT_LEGS)));
$this->register(new Armor(new IID(Ids::DIAMOND_LEGGINGS, 0), "Diamond Leggings", new ArmorTypeInfo(6, 496, ArmorInventory::SLOT_LEGS)));
$this->register(new Armor(new IID(Ids::GOLDEN_LEGGINGS, 0), "Golden Leggings", new ArmorTypeInfo(3, 106, ArmorInventory::SLOT_LEGS)));
$this->register(new Armor(new IID(Ids::IRON_LEGGINGS, 0), "Iron Leggings", new ArmorTypeInfo(5, 226, ArmorInventory::SLOT_LEGS)));
$this->register(new Armor(new IID(Ids::LEATHER_LEGGINGS, 0), "Leather Pants", new ArmorTypeInfo(2, 76, ArmorInventory::SLOT_LEGS)));
$this->register(new Armor(new IID(Ids::CHAINMAIL_BOOTS, LegacyIds::CHAIN_BOOTS, 0), "Chainmail Boots", new ArmorTypeInfo(1, 196, ArmorInventory::SLOT_FEET)));
$this->register(new Armor(new IID(Ids::DIAMOND_BOOTS, LegacyIds::DIAMOND_BOOTS, 0), "Diamond Boots", new ArmorTypeInfo(3, 430, ArmorInventory::SLOT_FEET)));
$this->register(new Armor(new IID(Ids::GOLDEN_BOOTS, LegacyIds::GOLDEN_BOOTS, 0), "Golden Boots", new ArmorTypeInfo(1, 92, ArmorInventory::SLOT_FEET)));
$this->register(new Armor(new IID(Ids::IRON_BOOTS, LegacyIds::IRON_BOOTS, 0), "Iron Boots", new ArmorTypeInfo(2, 196, ArmorInventory::SLOT_FEET)));
$this->register(new Armor(new IID(Ids::LEATHER_BOOTS, LegacyIds::LEATHER_BOOTS, 0), "Leather Boots", new ArmorTypeInfo(1, 66, ArmorInventory::SLOT_FEET)));
$this->register(new Armor(new IID(Ids::CHAINMAIL_CHESTPLATE, LegacyIds::CHAIN_CHESTPLATE, 0), "Chainmail Chestplate", new ArmorTypeInfo(5, 241, ArmorInventory::SLOT_CHEST)));
$this->register(new Armor(new IID(Ids::DIAMOND_CHESTPLATE, LegacyIds::DIAMOND_CHESTPLATE, 0), "Diamond Chestplate", new ArmorTypeInfo(8, 529, ArmorInventory::SLOT_CHEST)));
$this->register(new Armor(new IID(Ids::GOLDEN_CHESTPLATE, LegacyIds::GOLDEN_CHESTPLATE, 0), "Golden Chestplate", new ArmorTypeInfo(5, 113, ArmorInventory::SLOT_CHEST)));
$this->register(new Armor(new IID(Ids::IRON_CHESTPLATE, LegacyIds::IRON_CHESTPLATE, 0), "Iron Chestplate", new ArmorTypeInfo(6, 241, ArmorInventory::SLOT_CHEST)));
$this->register(new Armor(new IID(Ids::LEATHER_TUNIC, LegacyIds::LEATHER_CHESTPLATE, 0), "Leather Tunic", new ArmorTypeInfo(3, 81, ArmorInventory::SLOT_CHEST)));
$this->register(new Armor(new IID(Ids::CHAINMAIL_HELMET, LegacyIds::CHAIN_HELMET, 0), "Chainmail Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD)));
$this->register(new Armor(new IID(Ids::DIAMOND_HELMET, LegacyIds::DIAMOND_HELMET, 0), "Diamond Helmet", new ArmorTypeInfo(3, 364, ArmorInventory::SLOT_HEAD)));
$this->register(new Armor(new IID(Ids::GOLDEN_HELMET, LegacyIds::GOLDEN_HELMET, 0), "Golden Helmet", new ArmorTypeInfo(2, 78, ArmorInventory::SLOT_HEAD)));
$this->register(new Armor(new IID(Ids::IRON_HELMET, LegacyIds::IRON_HELMET, 0), "Iron Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD)));
$this->register(new Armor(new IID(Ids::LEATHER_CAP, LegacyIds::LEATHER_HELMET, 0), "Leather Cap", new ArmorTypeInfo(1, 56, ArmorInventory::SLOT_HEAD)));
$this->register(new Armor(new IID(Ids::CHAINMAIL_LEGGINGS, LegacyIds::CHAIN_LEGGINGS, 0), "Chainmail Leggings", new ArmorTypeInfo(4, 226, ArmorInventory::SLOT_LEGS)));
$this->register(new Armor(new IID(Ids::DIAMOND_LEGGINGS, LegacyIds::DIAMOND_LEGGINGS, 0), "Diamond Leggings", new ArmorTypeInfo(6, 496, ArmorInventory::SLOT_LEGS)));
$this->register(new Armor(new IID(Ids::GOLDEN_LEGGINGS, LegacyIds::GOLDEN_LEGGINGS, 0), "Golden Leggings", new ArmorTypeInfo(3, 106, ArmorInventory::SLOT_LEGS)));
$this->register(new Armor(new IID(Ids::IRON_LEGGINGS, LegacyIds::IRON_LEGGINGS, 0), "Iron Leggings", new ArmorTypeInfo(5, 226, ArmorInventory::SLOT_LEGS)));
$this->register(new Armor(new IID(Ids::LEATHER_PANTS, LegacyIds::LEATHER_LEGGINGS, 0), "Leather Pants", new ArmorTypeInfo(2, 76, ArmorInventory::SLOT_LEGS)));
}
/**
@ -425,12 +436,12 @@ class ItemFactory{
$this->list[self::getListOffset($id, $variant)] = clone $item;
}
public function remap(ItemIdentifier $identifier, Item $item, bool $override = false) : void{
if(!$override && $this->isRegistered($identifier->getId(), $identifier->getMeta())){
public function remap(int $legacyId, int $legacyMeta, Item $item, bool $override = false) : void{
if(!$override && $this->isRegistered($legacyId, $legacyMeta)){
throw new \RuntimeException("Trying to overwrite an already registered item");
}
$this->list[self::getListOffset($identifier->getId(), $identifier->getMeta())] = clone $item;
$this->list[self::getListOffset($legacyId, $legacyMeta)] = clone $item;
}
private static function itemToBlockId(int $id) : int{
@ -468,7 +479,7 @@ class ItemFactory{
if($blockStateData !== null){
try{
$blockStateId = GlobalBlockStateHandlers::getDeserializer()->deserialize($blockStateData);
$item = new ItemBlock(new IID($id, $meta), BlockFactory::getInstance()->fromFullBlock($blockStateId));
$item = new ItemBlock(BlockFactory::getInstance()->fromFullBlock($blockStateId));
}catch(BlockStateDeserializeException $e){
throw new SavedDataLoadingException("Failed to deserialize itemblock: " . $e->getMessage(), 0, $e);
}

View File

@ -23,26 +23,40 @@ declare(strict_types=1);
namespace pocketmine\item;
class ItemIdentifier{
private int $id;
private int $meta;
use pocketmine\block\Block;
public function __construct(int $id, int $meta){
if($id < -0x8000 || $id > 0x7fff){ //signed short range
class ItemIdentifier{
private int $legacyId;
private int $legacyMeta;
public function __construct(
private int $typeId,
int $legacyId,
int $legacyMeta
){
if($legacyId < -0x8000 || $legacyId > 0x7fff){ //signed short range
throw new \InvalidArgumentException("ID must be in range " . -0x8000 . " - " . 0x7fff);
}
if($meta < 0 || $meta > 0x7ffe){
if($legacyMeta < 0 || $legacyMeta > 0x7ffe){
throw new \InvalidArgumentException("Meta must be in range 0 - " . 0x7ffe);
}
$this->id = $id;
$this->meta = $meta;
$this->legacyId = $legacyId;
$this->legacyMeta = $legacyMeta;
}
public function getId() : int{
return $this->id;
public static function fromBlock(Block $block) : self{
//negative item type IDs are treated as block IDs
//TODO: maybe an ItemBlockIdentifier is in order?
return new self(-$block->getTypeId(), $block->getLegacyItemId(), $block->getLegacyItemMeta());
}
public function getMeta() : int{
return $this->meta;
public function getTypeId() : int{ return $this->typeId; }
public function getLegacyId() : int{
return $this->legacyId;
}
public function getLegacyMeta() : int{
return $this->legacyMeta;
}
}

View File

@ -24,19 +24,18 @@ declare(strict_types=1);
namespace pocketmine\item;
final class ItemIdentifierFlattened extends ItemIdentifier{
/**
* @param int[] $additionalIds
* @param int[] $additionalLegacyIds
*/
public function __construct(int $id, int $meta, private array $additionalIds){
parent::__construct($id, $meta);
public function __construct(int $typeId, int $legacyId, int $legacyMeta, private array $additionalLegacyIds){
parent::__construct($typeId, $legacyId, $legacyMeta);
}
/** @return int[] */
public function getAdditionalIds() : array{ return $this->additionalIds; }
public function getAdditionalLegacyIds() : array{ return $this->additionalLegacyIds; }
/** @return int[] */
public function getAllIds() : array{
return [$this->getId(), ...$this->additionalIds];
public function getAllLegacyIds() : array{
return [$this->getLegacyId(), ...$this->additionalLegacyIds];
}
}

270
src/item/ItemTypeIds.php Normal file
View File

@ -0,0 +1,270 @@
<?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/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
/**
* Enum of all the item runtime IDs used by PocketMine-MP. These IDs are specific to PocketMine-MP and have no
* relevance to any Minecraft vanilla things.
*
* WARNING: DO NOT STORE THESE IDS. They can and will change without warning.
* They should ONLY be used to IDENTIFY items at runtime.
*/
final class ItemTypeIds{
private function __construct(){
//NOOP
}
public const ACACIA_BOAT = 20000;
public const ACACIA_SIGN = 20001;
public const APPLE = 20002;
public const ARROW = 20003;
public const BAKED_POTATO = 20004;
public const BAMBOO = 20005;
public const BANNER = 20006;
public const BED = 20007;
public const BEETROOT = 20008;
public const BEETROOT_SEEDS = 20009;
public const BEETROOT_SOUP = 20010;
public const BIRCH_BOAT = 20011;
public const BIRCH_SIGN = 20012;
public const BLAZE_POWDER = 20013;
public const BLAZE_ROD = 20014;
public const BLEACH = 20015;
public const BONE = 20016;
public const BONE_MEAL = 20017;
public const BOOK = 20018;
public const BOW = 20019;
public const BOWL = 20020;
public const BREAD = 20021;
public const BRICK = 20022;
public const BUCKET = 20023;
public const CARROT = 20024;
public const CHAINMAIL_BOOTS = 20025;
public const CHAINMAIL_CHESTPLATE = 20026;
public const CHAINMAIL_HELMET = 20027;
public const CHAINMAIL_LEGGINGS = 20028;
public const CHARCOAL = 20029;
public const CHEMICAL_ALUMINIUM_OXIDE = 20030;
public const CHEMICAL_AMMONIA = 20031;
public const CHEMICAL_BARIUM_SULPHATE = 20032;
public const CHEMICAL_BENZENE = 20033;
public const CHEMICAL_BORON_TRIOXIDE = 20034;
public const CHEMICAL_CALCIUM_BROMIDE = 20035;
public const CHEMICAL_CALCIUM_CHLORIDE = 20036;
public const CHEMICAL_CERIUM_CHLORIDE = 20037;
public const CHEMICAL_CHARCOAL = 20038;
public const CHEMICAL_CRUDE_OIL = 20039;
public const CHEMICAL_GLUE = 20040;
public const CHEMICAL_HYDROGEN_PEROXIDE = 20041;
public const CHEMICAL_HYPOCHLORITE = 20042;
public const CHEMICAL_INK = 20043;
public const CHEMICAL_IRON_SULPHIDE = 20044;
public const CHEMICAL_LATEX = 20045;
public const CHEMICAL_LITHIUM_HYDRIDE = 20046;
public const CHEMICAL_LUMINOL = 20047;
public const CHEMICAL_MAGNESIUM_NITRATE = 20048;
public const CHEMICAL_MAGNESIUM_OXIDE = 20049;
public const CHEMICAL_MAGNESIUM_SALTS = 20050;
public const CHEMICAL_MERCURIC_CHLORIDE = 20051;
public const CHEMICAL_POLYETHYLENE = 20052;
public const CHEMICAL_POTASSIUM_CHLORIDE = 20053;
public const CHEMICAL_POTASSIUM_IODIDE = 20054;
public const CHEMICAL_RUBBISH = 20055;
public const CHEMICAL_SALT = 20056;
public const CHEMICAL_SOAP = 20057;
public const CHEMICAL_SODIUM_ACETATE = 20058;
public const CHEMICAL_SODIUM_FLUORIDE = 20059;
public const CHEMICAL_SODIUM_HYDRIDE = 20060;
public const CHEMICAL_SODIUM_HYDROXIDE = 20061;
public const CHEMICAL_SODIUM_HYPOCHLORITE = 20062;
public const CHEMICAL_SODIUM_OXIDE = 20063;
public const CHEMICAL_SUGAR = 20064;
public const CHEMICAL_SULPHATE = 20065;
public const CHEMICAL_TUNGSTEN_CHLORIDE = 20066;
public const CHEMICAL_WATER = 20067;
public const CHORUS_FRUIT = 20068;
public const CLAY = 20069;
public const CLOCK = 20070;
public const CLOWNFISH = 20071;
public const COAL = 20072;
public const COCOA_BEANS = 20073;
public const COMPASS = 20074;
public const COOKED_CHICKEN = 20075;
public const COOKED_FISH = 20076;
public const COOKED_MUTTON = 20077;
public const COOKED_PORKCHOP = 20078;
public const COOKED_RABBIT = 20079;
public const COOKED_SALMON = 20080;
public const COOKIE = 20081;
public const CORAL_FAN = 20082;
public const DARK_OAK_BOAT = 20083;
public const DARK_OAK_SIGN = 20084;
public const DIAMOND = 20085;
public const DIAMOND_AXE = 20086;
public const DIAMOND_BOOTS = 20087;
public const DIAMOND_CHESTPLATE = 20088;
public const DIAMOND_HELMET = 20089;
public const DIAMOND_HOE = 20090;
public const DIAMOND_LEGGINGS = 20091;
public const DIAMOND_PICKAXE = 20092;
public const DIAMOND_SHOVEL = 20093;
public const DIAMOND_SWORD = 20094;
public const DRAGON_BREATH = 20095;
public const DRIED_KELP = 20096;
public const DYE = 20097;
public const EGG = 20098;
public const EMERALD = 20099;
public const ENCHANTED_GOLDEN_APPLE = 20100;
public const ENDER_PEARL = 20101;
public const EXPERIENCE_BOTTLE = 20102;
public const FEATHER = 20103;
public const FERMENTED_SPIDER_EYE = 20104;
public const FISHING_ROD = 20105;
public const FLINT = 20106;
public const FLINT_AND_STEEL = 20107;
public const GHAST_TEAR = 20108;
public const GLASS_BOTTLE = 20109;
public const GLISTERING_MELON = 20110;
public const GLOWSTONE_DUST = 20111;
public const GOLD_INGOT = 20112;
public const GOLD_NUGGET = 20113;
public const GOLDEN_APPLE = 20114;
public const GOLDEN_AXE = 20115;
public const GOLDEN_BOOTS = 20116;
public const GOLDEN_CARROT = 20117;
public const GOLDEN_CHESTPLATE = 20118;
public const GOLDEN_HELMET = 20119;
public const GOLDEN_HOE = 20120;
public const GOLDEN_LEGGINGS = 20121;
public const GOLDEN_PICKAXE = 20122;
public const GOLDEN_SHOVEL = 20123;
public const GOLDEN_SWORD = 20124;
public const GUNPOWDER = 20125;
public const HEART_OF_THE_SEA = 20126;
public const INK_SAC = 20127;
public const IRON_AXE = 20128;
public const IRON_BOOTS = 20129;
public const IRON_CHESTPLATE = 20130;
public const IRON_HELMET = 20131;
public const IRON_HOE = 20132;
public const IRON_INGOT = 20133;
public const IRON_LEGGINGS = 20134;
public const IRON_NUGGET = 20135;
public const IRON_PICKAXE = 20136;
public const IRON_SHOVEL = 20137;
public const IRON_SWORD = 20138;
public const JUNGLE_BOAT = 20139;
public const JUNGLE_SIGN = 20140;
public const LAPIS_LAZULI = 20141;
public const LAVA_BUCKET = 20142;
public const LEATHER = 20143;
public const LEATHER_BOOTS = 20144;
public const LEATHER_CAP = 20145;
public const LEATHER_PANTS = 20146;
public const LEATHER_TUNIC = 20147;
public const MAGMA_CREAM = 20148;
public const MELON = 20149;
public const MELON_SEEDS = 20150;
public const MILK_BUCKET = 20151;
public const MINECART = 20152;
public const MOB_HEAD = 20153;
public const MUSHROOM_STEW = 20154;
public const NAUTILUS_SHELL = 20155;
public const NETHER_BRICK = 20156;
public const NETHER_QUARTZ = 20157;
public const NETHER_STAR = 20158;
public const OAK_BOAT = 20159;
public const OAK_SIGN = 20160;
public const PAINTING = 20161;
public const PAPER = 20162;
public const POISONOUS_POTATO = 20163;
public const POPPED_CHORUS_FRUIT = 20164;
public const POTATO = 20165;
public const POTION = 20166;
public const PRISMARINE_CRYSTALS = 20167;
public const PRISMARINE_SHARD = 20168;
public const PUFFERFISH = 20169;
public const PUMPKIN_PIE = 20170;
public const PUMPKIN_SEEDS = 20171;
public const RABBIT_FOOT = 20172;
public const RABBIT_HIDE = 20173;
public const RABBIT_STEW = 20174;
public const RAW_BEEF = 20175;
public const RAW_CHICKEN = 20176;
public const RAW_FISH = 20177;
public const RAW_MUTTON = 20178;
public const RAW_PORKCHOP = 20179;
public const RAW_RABBIT = 20180;
public const RAW_SALMON = 20181;
public const RECORD_11 = 20182;
public const RECORD_13 = 20183;
public const RECORD_BLOCKS = 20184;
public const RECORD_CAT = 20185;
public const RECORD_CHIRP = 20186;
public const RECORD_FAR = 20187;
public const RECORD_MALL = 20188;
public const RECORD_MELLOHI = 20189;
public const RECORD_STAL = 20190;
public const RECORD_STRAD = 20191;
public const RECORD_WAIT = 20192;
public const RECORD_WARD = 20193;
public const REDSTONE_DUST = 20194;
public const ROTTEN_FLESH = 20195;
public const SCUTE = 20196;
public const SHEARS = 20197;
public const SHULKER_SHELL = 20198;
public const SLIMEBALL = 20199;
public const SNOWBALL = 20200;
public const SPIDER_EYE = 20201;
public const SPLASH_POTION = 20202;
public const SPRUCE_BOAT = 20203;
public const SPRUCE_SIGN = 20204;
public const SQUID_SPAWN_EGG = 20205;
public const STEAK = 20206;
public const STICK = 20207;
public const STONE_AXE = 20208;
public const STONE_HOE = 20209;
public const STONE_PICKAXE = 20210;
public const STONE_SHOVEL = 20211;
public const STONE_SWORD = 20212;
public const STRING = 20213;
public const SUGAR = 20214;
public const SWEET_BERRIES = 20215;
public const TOTEM = 20216;
public const VILLAGER_SPAWN_EGG = 20217;
public const WATER_BUCKET = 20218;
public const WHEAT = 20219;
public const WHEAT_SEEDS = 20220;
public const WOODEN_AXE = 20221;
public const WOODEN_HOE = 20222;
public const WOODEN_PICKAXE = 20223;
public const WOODEN_SHOVEL = 20224;
public const WOODEN_SWORD = 20225;
public const WRITABLE_BOOK = 20226;
public const WRITTEN_BOOK = 20227;
public const ZOMBIE_SPAWN_EGG = 20228;
public const FIRST_UNUSED_ITEM_ID = 20229;
}