Improved Item::get()

This commit is contained in:
Shoghi Cervantes 2014-08-27 12:43:54 +02:00
parent 8e9da9c84e
commit 8f66d03d99

View File

@ -393,63 +393,63 @@ class Item{
public static function init(){ public static function init(){
if(count(self::$list) === 0){ if(count(self::$list) === 0){
self::$list = array( self::$list = array(
self::SUGARCANE => new Sugarcane(), self::SUGARCANE => Sugarcane::class,
self::WHEAT_SEEDS => new WheatSeeds(), self::WHEAT_SEEDS => WheatSeeds::class,
self::PUMPKIN_SEEDS => new PumpkinSeeds(), self::PUMPKIN_SEEDS => PumpkinSeeds::class,
self::MELON_SEEDS => new MelonSeeds(), self::MELON_SEEDS => MelonSeeds::class,
self::MUSHROOM_STEW => new MushroomStew(), self::MUSHROOM_STEW => MushroomStew::class,
self::BEETROOT_SOUP => new BeetrootSoup(), self::BEETROOT_SOUP => BeetrootSoup::class,
self::CARROT => new Carrot(), self::CARROT => Carrot::class,
self::POTATO => new Potato(), self::POTATO => Potato::class,
self::BEETROOT_SEEDS => new BeetrootSeeds(), self::BEETROOT_SEEDS => BeetrootSeeds::class,
self::SIGN => new Sign(), self::SIGN => Sign::class,
self::WOODEN_DOOR => new WoodenDoor(), self::WOODEN_DOOR => WoodenDoor::class,
self::BUCKET => new Bucket(), self::BUCKET => Bucket::class,
self::IRON_DOOR => new IronDoor(), self::IRON_DOOR => IronDoor::class,
self::CAKE => new Cake(), self::CAKE => Cake::class,
self::BED => new Bed(), self::BED => Bed::class,
self::PAINTING => new Painting(), self::PAINTING => Painting::class,
self::COAL => new Coal(), self::COAL => Coal::class,
self::APPLE => new Apple(), self::APPLE => Apple::class,
self::SPAWN_EGG => new SpawnEgg(), self::SPAWN_EGG => SpawnEgg::class,
self::DIAMOND => new Diamond(), self::DIAMOND => Diamond::class,
self::STICK => new Stick(), self::STICK => Stick::class,
self::BOWL => new Bowl(), self::BOWL => Bowl::class,
self::FEATHER => new Feather(), self::FEATHER => Feather::class,
self::BRICK => new Brick(), self::BRICK => Brick::class,
self::IRON_SWORD => new IronSword(), self::IRON_SWORD => IronSword::class,
self::IRON_INGOT => new IronIngot(), self::IRON_INGOT => IronIngot::class,
self::GOLD_INGOT => new GoldIngot(), self::GOLD_INGOT => GoldIngot::class,
self::IRON_SHOVEL => new IronShovel(), self::IRON_SHOVEL => IronShovel::class,
self::IRON_PICKAXE => new IronPickaxe(), self::IRON_PICKAXE => IronPickaxe::class,
self::IRON_AXE => new IronAxe(), self::IRON_AXE => IronAxe::class,
self::IRON_HOE => new IronHoe(), self::IRON_HOE => IronHoe::class,
self::DIAMOND_SWORD => new DiamondSword(), self::DIAMOND_SWORD => DiamondSword::class,
self::DIAMOND_SHOVEL => new DiamondShovel(), self::DIAMOND_SHOVEL => DiamondShovel::class,
self::DIAMOND_PICKAXE => new DiamondPickaxe(), self::DIAMOND_PICKAXE => DiamondPickaxe::class,
self::DIAMOND_AXE => new DiamondAxe(), self::DIAMOND_AXE => DiamondAxe::class,
self::DIAMOND_HOE => new DiamondHoe(), self::DIAMOND_HOE => DiamondHoe::class,
self::GOLD_SWORD => new GoldSword(), self::GOLD_SWORD => GoldSword::class,
self::GOLD_SHOVEL => new GoldShovel(), self::GOLD_SHOVEL => GoldShovel::class,
self::GOLD_PICKAXE => new GoldPickaxe(), self::GOLD_PICKAXE => GoldPickaxe::class,
self::GOLD_AXE => new GoldAxe(), self::GOLD_AXE => GoldAxe::class,
self::GOLD_HOE => new GoldHoe(), self::GOLD_HOE => GoldHoe::class,
self::STONE_SWORD => new StoneSword(), self::STONE_SWORD => StoneSword::class,
self::STONE_SHOVEL => new StoneShovel(), self::STONE_SHOVEL => StoneShovel::class,
self::STONE_PICKAXE => new StonePickaxe(), self::STONE_PICKAXE => StonePickaxe::class,
self::STONE_AXE => new StoneAxe(), self::STONE_AXE => StoneAxe::class,
self::STONE_HOE => new StoneHoe(), self::STONE_HOE => StoneHoe::class,
self::WOODEN_SWORD => new WoodenSword(), self::WOODEN_SWORD => WoodenSword::class,
self::WOODEN_SHOVEL => new WoodenShovel(), self::WOODEN_SHOVEL => WoodenShovel::class,
self::WOODEN_PICKAXE => new WoodenPickaxe(), self::WOODEN_PICKAXE => WoodenPickaxe::class,
self::WOODEN_AXE => new WoodenAxe(), self::WOODEN_AXE => WoodenAxe::class,
self::WOODEN_HOE => new WoodenHoe(), self::WOODEN_HOE => WoodenHoe::class,
self::FLINT_STEEL => new FlintSteel(), self::FLINT_STEEL => FlintSteel::class,
self::SHEARS => new Shears(), self::SHEARS => Shears::class,
self::BOW => new Bow(), self::BOW => Bow::class,
); );
foreach(Block::$list as $id => $class){ foreach(Block::$list as $id => $class){
self::$list[$id] = new ItemBlock(new $class); self::$list[$id] = $class;
} }
} }
@ -457,9 +457,12 @@ class Item{
public static function get($id, $meta = 0, $count = 1){ public static function get($id, $meta = 0, $count = 1){
if(isset(self::$list[$id])){ if(isset(self::$list[$id])){
$item = clone self::$list[$id]; $class = self::$list[$id];
$item->setDamage($meta); if($id < 256){
$item->setCount($count); $item = new ItemBlock(new $class($meta), $meta, $count);
}else{
$item = new $class($meta, $count);
}
}else{ }else{
$item = new Item($id, $meta, $count); $item = new Item($id, $meta, $count);
} }