#pragma once using namespace std; #include "Container.h" #include "UseAnim.h" #include "Rarity.h" class MapItem; class Mob; class Player; class Random; class Level; class ShearsItem; class PotionItem; class HitResult; class IconRegister; class Icon; class ArmorItem; class BowItem; class FishingRodItem; class EnchantedBookItem; class EmptyMapItem; #define ITEM_ICON_COLUMNS 16 class Item : public enable_shared_from_this { protected: //static const UUID BASE_ATTACK_DAMAGE_UUID; public: static const int ITEM_NUM_COUNT = 32000; static void staticCtor(); static void staticInit(); // 4J-PB - added for new crafting menu enum { eMaterial_undefined=0, eMaterial_wood, eMaterial_stone, eMaterial_iron, eMaterial_gold, eMaterial_diamond, eMaterial_cloth, eMaterial_chain, // 4J Stu - It's available in creative in 1.8 eMaterial_detector, eMaterial_lapis, eMaterial_music, eMaterial_dye, eMaterial_sand, eMaterial_brick, eMaterial_clay, eMaterial_snow, eMaterial_bow, eMaterial_arrow, eMaterial_compass, eMaterial_clock, eMaterial_map, eMaterial_pumpkin, eMaterial_glowstone, eMaterial_water, eMaterial_trap, eMaterial_flintandsteel, eMaterial_shears, eMaterial_piston, eMaterial_stickypiston, eMaterial_gate, eMaterial_stoneSmooth, eMaterial_netherbrick, eMaterial_ender, eMaterial_glass, eMaterial_blaze, eMaterial_magic, eMaterial_melon, eMaterial_setfire, eMaterial_sprucewood, eMaterial_birchwood, eMaterial_junglewood, eMaterial_emerald, eMaterial_quartz, eMaterial_apple, eMaterial_carrot, eMaterial_redstone, eMaterial_coal, eMaterial_paper, eMaterial_book, eMaterial_bookshelf, eMaterial_wheat, eMaterial_acaciawood, eMaterial_darkwood } eMaterial; enum { eBaseItemType_undefined=0, eBaseItemType_sword, eBaseItemType_shovel, eBaseItemType_pickaxe, eBaseItemType_hatchet, eBaseItemType_hoe, eBaseItemType_door, eBaseItemType_helmet, eBaseItemType_chestplate, eBaseItemType_leggings, eBaseItemType_boots, eBaseItemType_ingot, eBaseItemType_rail, eBaseItemType_block, eBaseItemType_pressureplate, eBaseItemType_stairs, eBaseItemType_cloth, eBaseItemType_dyepowder, eBaseItemType_structwoodstuff, eBaseItemType_structblock, eBaseItemType_slab, eBaseItemType_halfslab, eBaseItemType_torch, eBaseItemType_bow, eBaseItemType_pockettool, eBaseItemType_utensil, eBaseItemType_piston, eBaseItemType_devicetool, eBaseItemType_fence, eBaseItemType_device, eBaseItemType_treasure, eBaseItemType_seed, eBaseItemType_HangingItem, eBaseItemType_button, eBaseItemType_chest, eBaseItemType_rod, eBaseItemType_giltFruit, eBaseItemType_carpet, eBaseItemType_clay, eBaseItemType_glass, eBaseItemType_redstoneContainer, eBaseItemType_fireworks, eBaseItemType_lever, eBaseItemType_paper, eBaseItemType_MAXTYPES, eBaseItemType_stick, eBaseItemType_fenceGate, eBaseItemType_decoration, eBaseItemType_bowl } eBaseItemType; protected: static const int ICON_COLUMNS = ITEM_ICON_COLUMNS; static wstring ICON_DESCRIPTION_PREFIX; // 4J Stu - Was const but we have to static initialise it outside of this class public: class Tier { public: static const Tier *WOOD; // static const Tier *STONE; // static const Tier *IRON; // static const Tier *DIAMOND; // static const Tier *GOLD; private: const int level; const int uses; const float speed; const float damage; const int enchantmentValue; // 4J Stu - Had to make this public but was protected // We shouldn't be creating these except the static initialisation public: Tier(int level, int uses, float speed, float damage, int enchantmentValue); public: int getUses() const; float getSpeed() const; float getAttackDamageBonus() const; int getLevel() const; int getEnchantmentValue() const; int getTierItemId() const; }; protected: static Random *random; private: static const int MAX_STACK_SIZE = Container::LARGE_MAX_STACK_SIZE; public: static ItemArray items; static Item *iron_shovel; static Item *iron_pickaxe; static Item *iron_axe; static Item *flint_and_steel; static Item *apple; static BowItem *bow; static Item *arrow; static Item *coal; static Item *diamond; static Item *iron_ingot; static Item *gold_ingot; static Item *iron_sword; static Item *wooden_sword; static Item *wooden_shovel; static Item *wooden_pickaxe; static Item *wooden_axe; static Item *stone_sword; static Item *stone_shovel; static Item *stone_pickaxe; static Item *stone_axe; static Item *diamond_sword; static Item *diamond_shovel; static Item *diamond_pickaxe; static Item *diamond_axe; static Item *stick; static Item *bowl; static Item *mushroom_stew; static Item *rabbit_stew; static Item *golden_sword; static Item *golden_shovel; static Item *golden_pickaxe; static Item *golden_axe; static Item *string; static Item *feather; static Item *gunpowder; static Item *wooden_hoe; static Item *stone_hoe; static Item *iron_hoe; static Item *diamond_hoe; static Item *golden_hoe; static Item *wheat_seeds; static Item *wheat; static Item *bread; static ArmorItem *leather_helmet; static ArmorItem *leather_chestplate; static ArmorItem *leather_leggings; static ArmorItem *leather_boots; static ArmorItem *chainmail_helmet; static ArmorItem *chainmail_chestplate; static ArmorItem *chainmail_leggings; static ArmorItem *chainmail_boots; static ArmorItem *iron_helmet; static ArmorItem *iron_chestplate; static ArmorItem *iron_leggings; static ArmorItem *iron_boots; static ArmorItem *diamond_helmet; static ArmorItem *diamond_chestplate; static ArmorItem *diamond_leggings; static ArmorItem *diamond_boots; static ArmorItem *golden_helmet; static ArmorItem *golden_chestplate; static ArmorItem *golden_leggings; static ArmorItem *golden_boots; static Item *flint; static Item *raw_porkchop; static Item *cooked_porkchop; static Item *painting; static Item *golden_apple; static Item *sign; static Item *wooden_door; static Item *bucket; static Item *water_bucket; static Item *lava_bucket; static Item *minecart; static Item *saddle; static Item *iron_door; static Item *redstone; static Item *snowball; static Item *boat; static Item *leather; static Item *milk_bucket; static Item *brick; static Item *clay; static Item *reeds; static Item *paper; static Item *book; static Item *slime_ball; static Item *chest_minecart; static Item *furnace_minecart; static Item *egg; static Item *compass; static FishingRodItem *fishing_rod; static Item *clock; static Item *glowstone_dust; static Item *raw_fish; static Item *cooked_fish; static Item *dye; static Item *bone; static Item *sugar; static Item *cake; static Item *bed; static Item *repeater; static Item *cookie; static MapItem *map; static ShearsItem *shears; static Item *melon; static Item *seeds_pumpkin; static Item *seeds_melon; static Item *raw_beef; static Item *cooked_beef; static Item *raw_chicken; static Item *cooked_chicken; static Item *rotten_flesh; static Item *ender_pearl; static Item *blaze_rod; static Item *ghast_tear; static Item *gold_nugget; static Item *netherwart_seeds; static PotionItem *potion; static Item *glassBottle; static Item *spider_eye; static Item *fermented_spider_eye; static Item *blaze_powder; static Item *magma_cream; static Item *brewing_stand; static Item *cauldron; static Item *eye_of_ender; static Item *speckled_melon; static Item *spawn_egg; static Item *experience_bottle; static Item *skull; static Item *record_01; static Item *record_02; static Item *record_03; static Item *record_04; static Item *record_05; static Item *record_06; static Item *record_07; static Item *record_08; static Item *record_09; static Item *record_10; static Item *record_11; static Item *record_12; // TU9 static Item *fireball; static Item *frame; // TU14 static Item *writable_book; static Item *written_book; static Item *emerald; static Item *flower_pot; static Item *carrots; static Item *potato; static Item *baked_potato; static Item *poisonous_potato; static EmptyMapItem *empty_map; static Item *golden_carrot; static Item *carrot_on_a_stick; static Item *nether_star; static Item *pumpkin_pie; static Item *fireworks; static Item *firework_charge; static Item *nether_quartz; static Item *comparator; static Item *netherbrick; static EnchantedBookItem *enchanted_book; static Item *tnt_minecart; static Item *hopper_minecart; static Item *iron_horse_armor; static Item *golden_horse_armor; static Item *diamond_horse_armor; static Item *lead; static Item *name_tag; // TU25 static Item* spruce_door; static Item* birch_door; static Item* jungle_door; static Item* acacia_door; static Item* dark_oak_door; //TU31 static Item* raw_mutton; static Item* cooked_mutton; static Item* raw_rabbit; static Item* cooked_rabbit; static Item* rabbit_hide; static Item* rabbit_foot; static Item* armor_stand; static Item* prismarine_crystal; static Item* prismarine_shard; static Item* elytra; static const int iron_shovel_Id = 256; static const int iron_pickaxe_Id = 257; static const int iron_axe_Id = 258; static const int flint_and_steel_Id = 259; static const int apple_Id = 260; static const int bow_Id = 261; static const int arrow_Id = 262; static const int coal_Id = 263; static const int diamond_Id = 264; static const int iron_ingot_Id = 265; static const int gold_ingot_Id = 266; static const int iron_sword_Id = 267; static const int wooden_sword_Id = 268; static const int wooden_shovel_Id = 269; static const int wooden_pickaxe_Id = 270; static const int wooden_axe_Id = 271; static const int stone_sword_Id = 272; static const int stone_shovel_Id = 273; static const int stone_pickaxe_Id = 274; static const int stone_axe_Id = 275; static const int diamond_sword_Id = 276; static const int diamond_shovel_Id = 277; static const int diamond_pickaxe_Id = 278; static const int diamond_axe_Id = 279; static const int stick_Id = 280; static const int bowl_Id = 281; static const int mushroom_stew_Id = 282; static const int golden_sword_Id = 283; static const int golden_shovel_Id = 284; static const int golden_pickaxe_Id = 285; static const int golden_axe_Id = 286; static const int string_Id = 287; static const int feather_Id = 288; static const int gunpowder_Id = 289; static const int wooden_hoe_Id = 290; static const int stone_hoe_Id = 291; static const int iron_hoe_Id = 292; static const int diamond_hoe_Id = 293; static const int golden_hoe_Id = 294; static const int wheat_seeds_Id = 295; static const int wheat_Id = 296; static const int bread_Id = 297; static const int leather_helmet_Id = 298; static const int leather_chestplate_Id = 299; static const int leather_leggings_Id = 300; static const int leather_boots_Id = 301; static const int chainmail_helmet_Id = 302; static const int chainmail_chestplate_Id = 303; static const int chainmail_leggings_Id = 304; static const int chainmail_boots_Id = 305; static const int iron_helmet_Id = 306; static const int iron_chestplate_Id = 307; static const int iron_leggings_Id = 308; static const int iron_boots_Id = 309; static const int diamond_helmet_Id = 310; static const int diamond_chestplate_Id = 311; static const int diamond_leggings_Id = 312; static const int diamond_boots_Id = 313; static const int golden_helmet_Id = 314; static const int golden_chestplate_Id = 315; static const int golden_leggings_Id = 316; static const int golden_boots_Id = 317; static const int flint_Id = 318; static const int porkchop_Id = 319; static const int cooked_porkchop_Id = 320; static const int painting_Id = 321; static const int golden_apple_Id = 322; static const int standing_sign_Id = 323; static const int wooden_door_Id = 324; static const int bucket_Id = 325; static const int water_bucket_Id = 326; static const int lava_bucket_Id = 327; static const int minecart_Id = 328; static const int saddle_Id = 329; static const int iron_door_Id = 330; static const int redstone_Id = 331; static const int snowball_Id = 332; static const int boat_Id = 333; static const int leather_Id = 334; static const int milk_bucket_Id = 335; static const int brick_Id = 336; static const int clay_Id = 337; static const int reeds_Id = 338; static const int paper_Id = 339; static const int book_Id = 340; static const int slime_ball_Id = 341; static const int chest_minecart_Id = 342; static const int furnace_minecart_Id = 343; static const int egg_Id = 344; static const int compass_Id = 345; static const int fishing_rod_Id = 346; static const int clock_Id = 347; static const int glowstone_dust_Id = 348; static const int fish_Id = 349; static const int cooked_fish_Id = 350; static const int dye_Id = 351; static const int bone_Id = 352; static const int sugar_Id = 353; static const int cake_Id = 354; static const int bed_Id = 355; static const int repeater_Id = 356; static const int cookie_Id = 357; static const int filled_map_Id = 358; // 1.7.3 static const int shears_Id = 359; // 1.8.2 static const int melon_block_Id = 360; static const int pumpkin_seeds_Id = 361; static const int melon_seeds_Id = 362; static const int beef_Id = 363; static const int cooked_beef_Id = 364; static const int chicken_Id = 365; static const int cooked_chicken_Id = 366; static const int rotten_flesh_Id = 367; static const int ender_pearl_Id = 368; // 1.0.1 static const int blaze_rod_Id = 369; static const int ghast_tear_Id = 370; static const int gold_nugget_Id = 371; static const int netherwart_seeds_Id = 372; static const int potion_Id = 373; static const int glass_bottle_Id = 374; static const int spider_eye_Id = 375; static const int fermented_spider_eye_Id = 376; static const int blaze_powder_Id = 377; static const int magma_cream_Id = 378; static const int brewing_stand_Id = 379; static const int cauldron_Id = 380; static const int eye_of_ender_Id = 381; static const int speckled_melon_block_Id = 382; // 1.1 static const int spawn_egg_Id = 383; static const int experience_bottle_Id = 384; // TU 12 static const int skull_Id = 397; static const int record_13_Id = 2256; static const int record_cat_Id = 2257; static const int record_blocks_Id = 2258; static const int record_chirp_Id = 2259; static const int record_far_Id = 2260; static const int record_mall_Id = 2261; static const int record_mellohi_Id = 2262; // 4J-PB - this one isn't playable in the PC game, but is fine in ours static const int record_stal_Id = 2263; static const int record_strad_Id = 2264; static const int record_ward_Id = 2265; static const int record_11_Id = 2266; static const int record_wait_Id = 2267; // TU9 static const int fire_charge_Id = 385; static const int item_frame_Id = 389; // TU14 static const int writable_book_Id = 386; static const int written_book_Id = 387; static const int emerald_Id = 388; static const int flower_pot_Id = 390; static const int carrot_Id = 391; static const int potato_Id = 392; static const int baked_potato_Id = 393; static const int poisonous_potato_Id = 394; static const int map_Id = 395; static const int golden_carrot_Id = 396; static const int carrot_on_a_stick_Id = 398; static const int nether_star_Id = 399; static const int pumpkin_pie_Id = 400; static const int fireworks_Id = 401; static const int firework_charge_Id = 402; static const int enchanted_book_Id = 403; static const int comparator_Id = 404; static const int nether_brick_Id = 405; static const int quartz_Id = 406; static const int tnt_minecart_Id = 407; static const int hopper_minecart_Id = 408; static const int iron_horse_armor_Id = 417; static const int golden_horse_armor_Id = 418; static const int diamond_horse_armor_Id = 419; static const int lead_Id = 420; static const int name_tag_Id = 421; // TU25 //422 command_block_minecart static const int prismarine_shard_Id = 409; static const int prismarine_crystals_Id = 410; static const int rabbit_Id = 411; static const int cooked_rabbit_Id = 412; static const int rabbit_stew_Id = 413; static const int rabbit_foot_Id = 414; static const int rabbit_hide_Id = 415; static const int armor_stand_Id = 416; static const int mutton_Id = 423; static const int cooked_mutton_Id = 424; //425 banner //426 end_crystal static const int spruce_door_Id = 427; static const int birch_door_Id = 428; static const int jungle_door_Id = 429; static const int acacia_door_Id = 430; static const int dark_oak_door_Id = 431; static const int elytra_Id = 443; //TU31 public: const int id; protected: int maxStackSize; private: int maxDamage; protected: Icon *icon; // 4J-PB - added for new crafting menu int m_iBaseItemType; int m_iMaterial; bool m_handEquipped; bool m_isStackedByData; private: Item *craftingRemainingItem; wstring potionBrewingFormula; // 4J Stu - A value from strings.h, that is the name of the item unsigned int descriptionId; // 4J Stu - A value from strings.h that says what this does unsigned int useDescriptionId; wstring m_textureName; protected: Item(int id); public: // 4J Using per-item textures now Item *setIconName(const wstring &name); wstring getIconName(); Item *setMaxStackSize(int max); Item *setBaseItemTypeAndMaterial(int iType,int iMaterial); int getBaseItemType(); int getMaterial(); virtual int getIconType(); virtual Icon *getIcon(int auxValue); Icon *getIcon(shared_ptr itemInstance); virtual bool useOn(shared_ptr itemInstance, shared_ptr player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly=false); virtual float getDestroySpeed(shared_ptr itemInstance, Tile *tile); virtual bool TestUse(shared_ptr itemInstance, Level *level, shared_ptr player); virtual shared_ptr use(shared_ptr itemInstance, Level *level, shared_ptr player); virtual shared_ptr useTimeDepleted(shared_ptr itemInstance, Level *level, shared_ptr player); virtual int getMaxStackSize() const; virtual int getLevelDataForAuxValue(int auxValue); bool isStackedByData(); protected: Item *setStackedByData(bool isStackedByData); public: int getMaxDamage(); protected: Item *setMaxDamage(int maxDamage); public: bool canBeDepleted(); /** * Returns true when the item was used to deal more than default damage * * @param itemInstance * @param mob * @param attacker * @return */ virtual bool hurtEnemy(shared_ptr itemInstance, shared_ptr mob, shared_ptr attacker); /** * Returns true when the item was used to mine more efficiently * * @param itemInstance * @param tile * @param x * @param yf * @param z * @param owner * @return */ virtual bool mineBlock(shared_ptr itemInstance, Level *level, int tile, int x, int y, int z, shared_ptr owner); virtual int getAttackDamage(shared_ptr entity); virtual bool canDestroySpecial(Tile *tile); virtual bool interactEnemy(shared_ptr itemInstance, shared_ptr player, shared_ptr mob); Item *handEquipped(); virtual bool isHandEquipped(); virtual bool isMirroredArt(); Item *setDescriptionId(unsigned int id); LPCWSTR getDescription(); LPCWSTR getDescription(shared_ptr instance); virtual unsigned int getDescriptionId(int iData = -1); virtual unsigned int getDescriptionId(shared_ptr instance); Item *setUseDescriptionId(unsigned int id); virtual unsigned int getUseDescriptionId(); virtual unsigned int getUseDescriptionId(shared_ptr instance); Item *setCraftingRemainingItem(Item *craftingRemainingItem); virtual bool shouldMoveCraftingResultToInventory(shared_ptr instance); virtual bool shouldOverrideMultiplayerNBT(); Item *getCraftingRemainingItem(); bool hasCraftingRemainingItem(); std::wstring getName(); virtual int getColor(shared_ptr item, int spriteLayer); virtual void inventoryTick(shared_ptr itemInstance, Level *level, shared_ptr owner, int slot, bool selected); virtual void onCraftedBy(shared_ptr itemInstance, Level *level, shared_ptr player); virtual bool isComplex(); virtual UseAnim getUseAnimation(shared_ptr itemInstance); virtual int getUseDuration(shared_ptr itemInstance); virtual void releaseUsing(shared_ptr itemInstance, Level *level, shared_ptr player, int durationLeft); protected: virtual Item *setPotionBrewingFormula(const wstring &potionBrewingFormula); public: virtual wstring getPotionBrewingFormula(); virtual bool hasPotionBrewingFormula(); virtual void appendHoverText(shared_ptr itemInstance, shared_ptr player, vector *lines, bool advanced); virtual wstring getHoverName(shared_ptr itemInstance); virtual bool isFoil(shared_ptr itemInstance); virtual const Rarity *getRarity(shared_ptr itemInstance); virtual bool isEnchantable(shared_ptr itemInstance); protected: HitResult *getPlayerPOVHitResult(Level *level, shared_ptr player, bool alsoPickLiquid); public: virtual int getEnchantmentValue(); virtual bool hasMultipleSpriteLayers(); virtual Icon *getLayerIcon(int auxValue, int spriteLayer); virtual bool mayBePlacedInAdventureMode(); virtual bool isValidRepairItem(shared_ptr source, shared_ptr repairItem); virtual void registerIcons(IconRegister *iconRegister); virtual attrAttrModMap *getDefaultAttributeModifiers(); };