From 01b8ed5295875262a91b60af878bf2a18c1b7aae Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 3 Apr 2020 08:57:01 +0200 Subject: Pulled the BlockID and BlockInfo headers from Globals.h. (#4591) The BlockID.h file was removed from Globals.h and renamed to BlockType.h (main change) The BlockInfo.h file was removed from Globals.h (main change) The ENUM_BLOCK_ID and ENUM_ITEM_ID enum names were replaced with ENUM_BLOCK_TYPE and ENUM_ITEM_TYPE (cosmetics) The various enums, such as eDimension, eDamageType and eExplosionSource were moved from BlockType.h to Defines.h, together with the helper functions for converting between them and strings (StringToDimension et al.) (minor) Many inline functions were moved from headers to their respective cpp files, so that BlockType.h could be included only into the cpp file, rather than the header. That broke our tests a bit, since they pick bits and pieces out of the main code and provide stubs for the rest; they had to be re-stubbed and re-verified. eMonsterType values are no longer tied to E_ITEM_SPAWN_EGG_META_* values --- src/Bindings/AllToLua.pkg | 2 +- src/Bindings/CMakeLists.txt | 2 +- src/Bindings/DeprecatedBindings.cpp | 1 + src/Bindings/PluginManager.h | 1 + src/BlockArea.cpp | 2 + src/BlockArea.h | 2 + src/BlockEntities/BeaconEntity.cpp | 1 + src/BlockEntities/BedEntity.h | 1 + src/BlockEntities/ChestEntity.cpp | 1 + src/BlockEntities/DispenserEntity.cpp | 6 +- src/BlockEntities/EnderChestEntity.cpp | 1 + src/BlockEntities/JukeboxEntity.h | 1 + src/BlockID.cpp | 491 ----------- src/BlockID.h | 1319 ------------------------------ src/BlockInfo.cpp | 433 +++++++++- src/BlockInfo.h | 63 +- src/BlockType.cpp | 309 +++++++ src/BlockType.h | 1188 +++++++++++++++++++++++++++ src/BlockTypeRegistry.h | 1 + src/Blocks/BlockBigFlower.h | 1 + src/Blocks/BlockButton.h | 1 + src/Blocks/BlockCactus.h | 1 + src/Blocks/BlockDoor.h | 1 + src/Blocks/BlockHandler.h | 2 +- src/Blocks/BlockPiston.cpp | 1 + src/Blocks/BlockSlab.h | 2 + src/Blocks/BlockStems.h | 2 +- src/Blocks/ChunkInterface.cpp | 1 + src/Blocks/ChunkInterface.h | 7 + src/CMakeLists.txt | 7 +- src/Chunk.cpp | 1 + src/ChunkData.cpp | 1 + src/ChunkMap.cpp | 1 + src/ClientHandle.cpp | 1 + src/CraftingRecipes.cpp | 4 +- src/CraftingRecipes.h | 6 +- src/Defines.cpp | 627 ++++++++++++++ src/Defines.h | 964 ++++------------------ src/Enchantments.cpp | 1 + src/Entities/Boat.cpp | 1 + src/Entities/Entity.cpp | 1 + src/Entities/FallingBlock.cpp | 1 + src/Entities/Floater.cpp | 1 + src/Entities/Minecart.cpp | 1 + src/Entities/Pawn.cpp | 1 + src/Entities/ProjectileEntity.cpp | 1 + src/Generating/Caves.cpp | 1 + src/Generating/ChunkGenerator.h | 1 + src/Generating/DungeonRoomsFinisher.cpp | 1 + src/Generating/FinishGen.cpp | 1 + src/Generating/Prefab.cpp | 1 + src/Generating/RoughRavines.cpp | 1 + src/Generating/StructGen.cpp | 1 + src/Generating/Trees.cpp | 1 + src/Generating/VillageGen.cpp | 1 + src/Globals.h | 6 - src/Item.cpp | 80 +- src/Item.h | 63 +- src/Items/ItemBigFlower.h | 1 + src/Items/ItemBottle.h | 1 + src/Items/ItemBucket.h | 3 +- src/Items/ItemChest.h | 1 + src/Items/ItemPickaxe.h | 2 +- src/Items/ItemShears.h | 4 +- src/Items/ItemSword.h | 6 +- src/LightingThread.cpp | 28 + src/LightingThread.h | 21 +- src/LineBlockTracer.cpp | 1 + src/Map.cpp | 2 +- src/Map.h | 2 + src/MobSpawner.cpp | 1 + src/Mobs/Monster.cpp | 1 + src/Mobs/MonsterTypes.h | 69 +- src/Mobs/Path.cpp | 1 + src/Mobs/PathFinder.cpp | 1 + src/Mobs/SnowGolem.cpp | 1 + src/NetherPortalScanner.cpp | 1 + src/Protocol/ChunkDataSerializer.h | 1 + src/Protocol/Protocol_1_8.cpp | 4 +- src/Protocol/Protocol_1_9.cpp | 4 +- src/Root.h | 1 + src/Simulator/FireSimulator.cpp | 1 + src/Simulator/FireSimulator.h | 1 + src/Simulator/FloodyFluidSimulator.cpp | 1 + src/Simulator/SandSimulator.cpp | 3 +- src/Simulator/SandSimulator.h | 1 + src/Simulator/VanillaFluidSimulator.cpp | 1 + src/Tracer.cpp | 1 + src/World.cpp | 1 + src/World.h | 2 +- src/WorldStorage/FireworksSerializer.cpp | 5 +- src/WorldStorage/FireworksSerializer.h | 10 +- src/WorldStorage/NBTChunkSerializer.cpp | 2 +- src/WorldStorage/WSSAnvil.cpp | 11 +- src/WorldStorage/WSSAnvil.h | 3 +- tests/Generating/BasicGeneratorTest.cpp | 28 +- tests/Generating/CMakeLists.txt | 10 +- tests/Generating/Stubs.cpp | 64 +- tests/LuaThreadStress/Stubs.cpp | 17 +- tests/SchematicFileSerializer/Stubs.cpp | 5 +- 100 files changed, 3094 insertions(+), 2852 deletions(-) delete mode 100644 src/BlockID.cpp delete mode 100644 src/BlockID.h create mode 100644 src/BlockType.cpp create mode 100644 src/BlockType.h create mode 100644 src/Defines.cpp diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg index 778cdf42c..1af7e8a21 100644 --- a/src/Bindings/AllToLua.pkg +++ b/src/Bindings/AllToLua.pkg @@ -42,7 +42,7 @@ $cfile "Plugin.h" $cfile "PluginLua.h" $cfile "LuaWindow.h" -$cfile "../BlockID.h" +$cfile "../BlockType.h" $cfile "../BlockInfo.h" $cfile "../StringUtils.h" $cfile "../Defines.h" diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index 17f2bdf39..ccd3f4dde 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -79,7 +79,7 @@ set(BINDING_DEPENDENCIES ../BlockEntities/SignEntity.h ../BlockEntities/MobHeadEntity.h ../BlockEntities/FlowerPotEntity.h - ../BlockID.h + ../BlockType.h ../BlockInfo.h ../BoundingBox.h ../ChatColor.h diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp index a297179f0..b9969ca65 100644 --- a/src/Bindings/DeprecatedBindings.cpp +++ b/src/Bindings/DeprecatedBindings.cpp @@ -10,6 +10,7 @@ #include "../Entities/Player.h" #include "LuaState.h" #include "../Tracer.h" +#include "../BlockInfo.h" diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 04dbed67d..79b7511ea 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -2,6 +2,7 @@ #pragma once +#include "../BlockType.h" #include "../Defines.h" #include "../FunctionRef.h" diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 4a07db39b..bf9c285c1 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -15,6 +15,8 @@ #include "ChunkData.h" #include "BlockEntities/BlockEntity.h" #include "Item.h" +#include "BlockInfo.h" + diff --git a/src/BlockArea.h b/src/BlockArea.h index b7bfded9a..9c0cb4ec9 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -14,6 +14,7 @@ #pragma once +#include "BlockType.h" #include "ForEachChunkProvider.h" #include "ChunkDataCallback.h" #include "Cuboid.h" @@ -24,6 +25,7 @@ // fwd: class cCuboid; +class cItem; class cItems; using cBlockEntityCallback = cFunctionRef; diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index 4c830fb61..00ef145fb 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "BeaconEntity.h" +#include "../BlockInfo.h" #include "../BlockArea.h" #include "../Entities/Player.h" #include "../UI/BeaconWindow.h" diff --git a/src/BlockEntities/BedEntity.h b/src/BlockEntities/BedEntity.h index 6878a6429..265ed43dd 100644 --- a/src/BlockEntities/BedEntity.h +++ b/src/BlockEntities/BedEntity.h @@ -4,6 +4,7 @@ #pragma once #include "BlockEntity.h" +#include "../BlockType.h" diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp index c73ff1985..902c9b17a 100644 --- a/src/BlockEntities/ChestEntity.cpp +++ b/src/BlockEntities/ChestEntity.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "ChestEntity.h" +#include "../BlockInfo.h" #include "../Item.h" #include "../Entities/Player.h" #include "../UI/ChestWindow.h" diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp index 268a108c2..95e3c46b9 100644 --- a/src/BlockEntities/DispenserEntity.cpp +++ b/src/BlockEntities/DispenserEntity.cpp @@ -2,13 +2,13 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "DispenserEntity.h" -#include "../Simulator/FluidSimulator.h" -#include "../Entities/Boat.h" #include "../Chunk.h" - +#include "../BlockInfo.h" #include "../Defines.h" #include "../World.h" +#include "../Entities/Boat.h" #include "../Entities/ProjectileEntity.h" +#include "../Simulator/FluidSimulator.h" diff --git a/src/BlockEntities/EnderChestEntity.cpp b/src/BlockEntities/EnderChestEntity.cpp index 5f9e2d969..c324f1cec 100644 --- a/src/BlockEntities/EnderChestEntity.cpp +++ b/src/BlockEntities/EnderChestEntity.cpp @@ -3,6 +3,7 @@ #include "EnderChestEntity.h" #include "json/json.h" +#include "../BlockInfo.h" #include "../Item.h" #include "../Entities/Player.h" #include "../UI/EnderChestWindow.h" diff --git a/src/BlockEntities/JukeboxEntity.h b/src/BlockEntities/JukeboxEntity.h index 2fbd916eb..532f8905a 100644 --- a/src/BlockEntities/JukeboxEntity.h +++ b/src/BlockEntities/JukeboxEntity.h @@ -2,6 +2,7 @@ #pragma once #include "BlockEntity.h" +#include "../BlockType.h" diff --git a/src/BlockID.cpp b/src/BlockID.cpp deleted file mode 100644 index 399f9c3f6..000000000 --- a/src/BlockID.cpp +++ /dev/null @@ -1,491 +0,0 @@ -// BlockID.cpp - -// Implements the helper functions for converting Block ID string to int etc. - -#include "Globals.h" -#include "IniFile.h" -#include "Item.h" -#include "Mobs/Monster.h" - - - - - -class cBlockIDMap -{ - // Making the map case-insensitive: - struct Comparator - { - bool operator ()(const AString & a_Item1, const AString & a_Item2) const - { - return (NoCaseCompare(a_Item1, a_Item2) > 0); - } - } ; - - typedef std::map, Comparator> ItemMap; - -public: - static bool m_bHasRunInit; - - cBlockIDMap(void) - { - // Dont load items.ini on construct, this will search the wrong path when running as a service. - } - - - void init() - { - m_bHasRunInit = true; - - cIniFile Ini; - if (!Ini.ReadFile("items.ini")) - { - return; - } - int KeyID = Ini.FindKey("Items"); - if (KeyID == cIniFile::noID) - { - return; - } - int NumValues = Ini.GetNumValues(KeyID); - for (int i = 0; i < NumValues; i++) - { - AString Name = Ini.GetValueName(KeyID, i); - if (Name.empty()) - { - continue; - } - AString Value = Ini.GetValue(KeyID, i); - AddToMap(Name, Value); - } // for i - Ini.Values[] - } - - - int Resolve(const AString & a_ItemName) - { - ItemMap::iterator itr = m_Map.find(a_ItemName); - if (itr == m_Map.end()) - { - return -1; - } - return itr->second.first; - } - - - bool ResolveItem(const AString & a_ItemName, cItem & a_Item) - { - // Split into parts divided by either ':' or '^' - AStringVector Split = StringSplitAndTrim(a_ItemName, ":^"); - if (Split.empty()) - { - return false; - } - - ItemMap::iterator itr = m_Map.find(Split[0]); - if (itr != m_Map.end()) - { - // Resolved as a string, assign the type and the default damage / count - a_Item.m_ItemType = itr->second.first; - a_Item.m_ItemDamage = itr->second.second; - if (a_Item.m_ItemDamage == -1) - { - a_Item.m_ItemDamage = 0; - } - } - else - { - // Not a resolvable string, try pure numbers: "45:6", "45^6" etc. - if (!StringToInteger(Split[0], a_Item.m_ItemType)) - { - // Parsing the number failed - return false; - } - } - - // Parse the damage, if present: - if (Split.size() < 2) - { - // Not present, set the item as valid and return success: - a_Item.m_ItemCount = 1; - return true; - } - - if (!StringToInteger(Split[1], a_Item.m_ItemDamage)) - { - // Parsing the number failed - return false; - } - a_Item.m_ItemCount = 1; - return true; - } - - - AString Desolve(short a_ItemType, short a_ItemDamage) - { - // First try an exact match, both ItemType and ItemDamage ("birchplanks=5:2"): - for (ItemMap::iterator itr = m_Map.begin(), end = m_Map.end(); itr != end; ++itr) - { - if ((itr->second.first == a_ItemType) && (itr->second.second == a_ItemDamage)) - { - return itr->first; - } - } // for itr - m_Map[] - - // There is no exact match, try matching ItemType only ("planks=5"): - if (a_ItemDamage == 0) - { - for (ItemMap::iterator itr = m_Map.begin(), end = m_Map.end(); itr != end; ++itr) - { - if ((itr->second.first == a_ItemType) && (itr->second.second == -1)) - { - return itr->first; - } - } // for itr - m_Map[] - } - - // No match at all, synthesize a string ("5:1"): - AString res; - if (a_ItemDamage == -1) - { - Printf(res, "%d", a_ItemType); - } - else - { - Printf(res, "%d:%d", a_ItemType, a_ItemDamage); - } - return res; - } - - -protected: - ItemMap m_Map; - - - void AddToMap(const AString & a_Name, const AString & a_Value) - { - AStringVector Split = StringSplit(a_Value, ":"); - if (Split.size() == 1) - { - Split = StringSplit(a_Value, "^"); - } - if (Split.empty()) - { - return; - } - short ItemType; - if (!StringToInteger(Split[0], ItemType)) - { - ASSERT(!"Invalid item type"); - } - short ItemDamage = -1; - if (Split.size() > 1 && !StringToInteger(Split[1], ItemDamage)) - { - ASSERT(!"Invalid item damage"); - } - m_Map[a_Name] = std::make_pair(ItemType, ItemDamage); - } -} ; - - - - -bool cBlockIDMap::m_bHasRunInit = false; -static cBlockIDMap gsBlockIDMap; - - - - - -/* -// Quick self-test: -class Tester -{ -public: - Tester(void) - { - cItem Item; - gsBlockIDMap.ResolveItem("charcoal", Item); - AString Charcoal = gsBlockIDMap.Desolve(Item.m_ItemType, Item.m_ItemDamage); - ASSERT(Charcoal == "charcoal"); - } -} test; -//*/ - - - - - -int BlockStringToType(const AString & a_BlockTypeString) -{ - int res = atoi(a_BlockTypeString.c_str()); - if ((res != 0) || (a_BlockTypeString.compare("0") == 0)) - { - // It was a valid number, return that - return res; - } - - if (!gsBlockIDMap.m_bHasRunInit) - { - gsBlockIDMap.init(); - } - return gsBlockIDMap.Resolve(TrimString(a_BlockTypeString)); -} - - - - - -bool StringToItem(const AString & a_ItemTypeString, cItem & a_Item) -{ - AString ItemName = TrimString(a_ItemTypeString); - if (ItemName.substr(0, 10) == "minecraft:") - { - ItemName = ItemName.substr(10); - } - - if (!gsBlockIDMap.m_bHasRunInit) - { - gsBlockIDMap.init(); - } - return gsBlockIDMap.ResolveItem(ItemName, a_Item); -} - - - - - -AString ItemToString(const cItem & a_Item) -{ - if (!gsBlockIDMap.m_bHasRunInit) - { - gsBlockIDMap.init(); - } - return gsBlockIDMap.Desolve(a_Item.m_ItemType, a_Item.m_ItemDamage); -} - - - - - -AString ItemTypeToString(short a_ItemType) -{ - if (!gsBlockIDMap.m_bHasRunInit) - { - gsBlockIDMap.init(); - } - return gsBlockIDMap.Desolve(a_ItemType, -1); -} - - - - - -AString ItemToFullString(const cItem & a_Item) -{ - AString res; - Printf(res, "%s:%d * %d", ItemToString(a_Item).c_str(), a_Item.m_ItemDamage, a_Item.m_ItemCount); - return res; -} - - - - - -eDimension StringToDimension(const AString & a_DimensionString) -{ - // First try decoding as a number - int res; - if (StringToInteger(a_DimensionString, res)) - { - // It was a valid number - return static_cast(res); - } - - // Decode using a built-in map: - static struct - { - eDimension m_Dimension; - const char * m_String; - } DimensionMap [] = - { - { dimOverworld, "Overworld"}, - { dimOverworld, "Normal"}, - { dimOverworld, "World"}, - { dimNether, "Nether"}, - { dimNether, "Hell"}, // Alternate name for Nether - { dimEnd, "End"}, - { dimEnd, "Sky"}, // Old name for End - } ; - for (size_t i = 0; i < ARRAYCOUNT(DimensionMap); i++) - { - if (NoCaseCompare(DimensionMap[i].m_String, a_DimensionString) == 0) - { - return DimensionMap[i].m_Dimension; - } - } // for i - DimensionMap[] - - // Not found - LOGWARNING("Unknown dimension: \"%s\". Setting to Overworld", a_DimensionString.c_str()); - return dimOverworld; -} - - - - - -AString DimensionToString(eDimension a_Dimension) -{ - // Decode using a built-in map: - static struct - { - eDimension m_Dimension; - const char * m_String; - } DimensionMap[] = - { - { dimOverworld, "Overworld" }, - { dimNether, "Nether" }, - { dimEnd, "End" }, - }; - - for (size_t i = 0; i < ARRAYCOUNT(DimensionMap); i++) - { - if (DimensionMap[i].m_Dimension == a_Dimension) - { - return DimensionMap[i].m_String; - } - } // for i - DimensionMap[] - - // Not found - LOGWARNING("Unknown dimension: \"%i\". Setting to Overworld", static_cast(a_Dimension)); - return "Overworld"; -} - - - - - -/** Translates damage type constant to a string representation (built-in) */ -AString DamageTypeToString(eDamageType a_DamageType) -{ - // Make sure to keep this alpha-sorted. - switch (a_DamageType) - { - case dtAdmin: return "dtAdmin"; - case dtAttack: return "dtAttack"; - case dtCactusContact: return "dtCactusContact"; - case dtDrowning: return "dtDrowning"; - case dtEnderPearl: return "dtEnderPearl"; - case dtFalling: return "dtFalling"; - case dtFireContact: return "dtFireContact"; - case dtInVoid: return "dtInVoid"; - case dtLavaContact: return "dtLavaContact"; - case dtLightning: return "dtLightning"; - case dtOnFire: return "dtOnFire"; - case dtPoisoning: return "dtPoisoning"; - case dtWithering: return "dtWithering"; - case dtPotionOfHarming: return "dtPotionOfHarming"; - case dtRangedAttack: return "dtRangedAttack"; - case dtStarving: return "dtStarving"; - case dtSuffocating: return "dtSuffocation"; - case dtExplosion: return "dtExplosion"; - } - UNREACHABLE("Unsupported damage type"); -} - - - - - -/** Translates a damage type string to damage type. Takes either a number or a damage type alias (built-in). -Returns -1 on failure. */ -eDamageType StringToDamageType(const AString & a_DamageTypeString) -{ - // First try decoding as a number: - int res; - if (!StringToInteger(a_DamageTypeString, res)) - { - // It was a valid number - return static_cast(res); - } - - // Decode using a built-in map: - static struct - { - eDamageType m_DamageType; - const char * m_String; - } DamageTypeMap [] = - { - // Cannonical names: - { dtAttack, "dtAttack"}, - { dtRangedAttack, "dtRangedAttack"}, - { dtLightning, "dtLightning"}, - { dtFalling, "dtFalling"}, - { dtDrowning, "dtDrowning"}, - { dtSuffocating, "dtSuffocation"}, - { dtStarving, "dtStarving"}, - { dtCactusContact, "dtCactusContact"}, - { dtLavaContact, "dtLavaContact"}, - { dtPoisoning, "dtPoisoning"}, - { dtWithering, "dtWithering"}, - { dtOnFire, "dtOnFire"}, - { dtFireContact, "dtFireContact"}, - { dtInVoid, "dtInVoid"}, - { dtPotionOfHarming, "dtPotionOfHarming"}, - { dtAdmin, "dtAdmin"}, - { dtExplosion, "dtExplosion"}, - - // Common synonyms: - { dtAttack, "dtPawnAttack"}, - { dtAttack, "dtEntityAttack"}, - { dtAttack, "dtMob"}, - { dtAttack, "dtMobAttack"}, - { dtRangedAttack, "dtArrowAttack"}, - { dtRangedAttack, "dtArrow"}, - { dtRangedAttack, "dtProjectile"}, - { dtFalling, "dtFall"}, - { dtDrowning, "dtDrown"}, - { dtSuffocating, "dtSuffocation"}, - { dtStarving, "dtStarvation"}, - { dtStarving, "dtHunger"}, - { dtCactusContact, "dtCactus"}, - { dtCactusContact, "dtCactuses"}, - { dtCactusContact, "dtCacti"}, - { dtLavaContact, "dtLava"}, - { dtPoisoning, "dtPoison"}, - { dtWithering, "dtWither"}, - { dtOnFire, "dtBurning"}, - { dtFireContact, "dtInFire"}, - { dtAdmin, "dtPlugin"}, - } ; - for (size_t i = 0; i < ARRAYCOUNT(DamageTypeMap); i++) - { - if (NoCaseCompare(DamageTypeMap[i].m_String, a_DamageTypeString) == 0) - { - return DamageTypeMap[i].m_DamageType; - } - } // for i - DamageTypeMap[] - - // Not found: - return static_cast(-1); -} - - - - - -cItem GetIniItemSet(cIniFile & a_IniFile, const char * a_Section, const char * a_Key, const char * a_Default) -{ - AString ItemStr = a_IniFile.GetValueSet(a_Section, a_Key, a_Default); - cItem res; - if (!StringToItem(ItemStr, res)) - { - res.Empty(); - } - return res; -} - - - - - - diff --git a/src/BlockID.h b/src/BlockID.h deleted file mode 100644 index 07ef043c0..000000000 --- a/src/BlockID.h +++ /dev/null @@ -1,1319 +0,0 @@ -#pragma once - - -// tolua_begin - - -enum ENUM_BLOCK_ID : BLOCKTYPE -{ - E_BLOCK_AIR = 0, - E_BLOCK_STONE = 1, - E_BLOCK_GRASS = 2, - E_BLOCK_DIRT = 3, - E_BLOCK_COBBLESTONE = 4, - E_BLOCK_PLANKS = 5, - E_BLOCK_SAPLING = 6, - E_BLOCK_BEDROCK = 7, - E_BLOCK_WATER = 8, - E_BLOCK_STATIONARY_WATER = 9, - E_BLOCK_LAVA = 10, - E_BLOCK_STATIONARY_LAVA = 11, - E_BLOCK_SAND = 12, - E_BLOCK_GRAVEL = 13, - E_BLOCK_GOLD_ORE = 14, - E_BLOCK_IRON_ORE = 15, - E_BLOCK_COAL_ORE = 16, - E_BLOCK_LOG = 17, - E_BLOCK_LEAVES = 18, - E_BLOCK_SPONGE = 19, - E_BLOCK_GLASS = 20, - E_BLOCK_LAPIS_ORE = 21, - E_BLOCK_LAPIS_BLOCK = 22, - E_BLOCK_DISPENSER = 23, - E_BLOCK_SANDSTONE = 24, - E_BLOCK_NOTE_BLOCK = 25, - E_BLOCK_BED = 26, - E_BLOCK_POWERED_RAIL = 27, - E_BLOCK_DETECTOR_RAIL = 28, - E_BLOCK_STICKY_PISTON = 29, - E_BLOCK_COBWEB = 30, - E_BLOCK_TALL_GRASS = 31, - E_BLOCK_DEAD_BUSH = 32, - E_BLOCK_PISTON = 33, - E_BLOCK_PISTON_EXTENSION = 34, - E_BLOCK_WOOL = 35, - E_BLOCK_PISTON_MOVED_BLOCK = 36, - E_BLOCK_DANDELION = 37, - E_BLOCK_FLOWER = 38, - E_BLOCK_BROWN_MUSHROOM = 39, - E_BLOCK_RED_MUSHROOM = 40, - E_BLOCK_GOLD_BLOCK = 41, - E_BLOCK_IRON_BLOCK = 42, - E_BLOCK_DOUBLE_STONE_SLAB = 43, - E_BLOCK_STONE_SLAB = 44, - E_BLOCK_BRICK = 45, - E_BLOCK_TNT = 46, - E_BLOCK_BOOKCASE = 47, - E_BLOCK_MOSSY_COBBLESTONE = 48, - E_BLOCK_OBSIDIAN = 49, - E_BLOCK_TORCH = 50, - E_BLOCK_FIRE = 51, - E_BLOCK_MOB_SPAWNER = 52, - E_BLOCK_OAK_WOOD_STAIRS = 53, - E_BLOCK_CHEST = 54, - E_BLOCK_REDSTONE_WIRE = 55, - E_BLOCK_DIAMOND_ORE = 56, - E_BLOCK_DIAMOND_BLOCK = 57, - E_BLOCK_CRAFTING_TABLE = 58, - E_BLOCK_WORKBENCH = 58, - E_BLOCK_WHEAT = 59, - E_BLOCK_CROPS = E_BLOCK_WHEAT, - E_BLOCK_FARMLAND = 60, - E_BLOCK_FURNACE = 61, - E_BLOCK_LIT_FURNACE = 62, - E_BLOCK_BURNING_FURNACE = 62, - E_BLOCK_SIGN_POST = 63, - E_BLOCK_OAK_DOOR = 64, - E_BLOCK_LADDER = 65, - E_BLOCK_RAIL = 66, - E_BLOCK_MINECART_TRACKS = 66, - E_BLOCK_COBBLESTONE_STAIRS = 67, - E_BLOCK_WALLSIGN = 68, - E_BLOCK_LEVER = 69, - E_BLOCK_STONE_PRESSURE_PLATE = 70, - E_BLOCK_IRON_DOOR = 71, - E_BLOCK_WOODEN_PRESSURE_PLATE = 72, - E_BLOCK_REDSTONE_ORE = 73, - E_BLOCK_REDSTONE_ORE_GLOWING = 74, - E_BLOCK_REDSTONE_TORCH_OFF = 75, - E_BLOCK_REDSTONE_TORCH_ON = 76, - E_BLOCK_STONE_BUTTON = 77, - E_BLOCK_SNOW = 78, - E_BLOCK_ICE = 79, - E_BLOCK_SNOW_BLOCK = 80, - E_BLOCK_CACTUS = 81, - E_BLOCK_CLAY = 82, - E_BLOCK_SUGARCANE = 83, - E_BLOCK_REEDS = 83, - E_BLOCK_JUKEBOX = 84, - E_BLOCK_FENCE = 85, - E_BLOCK_PUMPKIN = 86, - E_BLOCK_NETHERRACK = 87, - E_BLOCK_SOULSAND = 88, - E_BLOCK_GLOWSTONE = 89, - E_BLOCK_NETHER_PORTAL = 90, - E_BLOCK_JACK_O_LANTERN = 91, - E_BLOCK_CAKE = 92, - E_BLOCK_REDSTONE_REPEATER_OFF = 93, - E_BLOCK_REDSTONE_REPEATER_ON = 94, - E_BLOCK_STAINED_GLASS = 95, - E_BLOCK_TRAPDOOR = 96, - E_BLOCK_SILVERFISH_EGG = 97, - E_BLOCK_STONE_BRICKS = 98, - E_BLOCK_HUGE_BROWN_MUSHROOM = 99, - E_BLOCK_HUGE_RED_MUSHROOM = 100, - E_BLOCK_IRON_BARS = 101, - E_BLOCK_GLASS_PANE = 102, - E_BLOCK_MELON = 103, - E_BLOCK_PUMPKIN_STEM = 104, - E_BLOCK_MELON_STEM = 105, - E_BLOCK_VINES = 106, - E_BLOCK_OAK_FENCE_GATE = 107, - E_BLOCK_BRICK_STAIRS = 108, - E_BLOCK_STONE_BRICK_STAIRS = 109, - E_BLOCK_MYCELIUM = 110, - E_BLOCK_LILY_PAD = 111, - E_BLOCK_NETHER_BRICK = 112, - E_BLOCK_NETHER_BRICK_FENCE = 113, - E_BLOCK_NETHER_BRICK_STAIRS = 114, - E_BLOCK_NETHER_WART = 115, - E_BLOCK_ENCHANTMENT_TABLE = 116, - E_BLOCK_BREWING_STAND = 117, - E_BLOCK_CAULDRON = 118, - E_BLOCK_END_PORTAL = 119, - E_BLOCK_END_PORTAL_FRAME = 120, - E_BLOCK_END_STONE = 121, - E_BLOCK_DRAGON_EGG = 122, - E_BLOCK_REDSTONE_LAMP_OFF = 123, - E_BLOCK_REDSTONE_LAMP_ON = 124, - E_BLOCK_DOUBLE_WOODEN_SLAB = 125, - E_BLOCK_WOODEN_SLAB = 126, - E_BLOCK_COCOA_POD = 127, - E_BLOCK_SANDSTONE_STAIRS = 128, - E_BLOCK_EMERALD_ORE = 129, - E_BLOCK_ENDER_CHEST = 130, - E_BLOCK_TRIPWIRE_HOOK = 131, - E_BLOCK_TRIPWIRE = 132, - E_BLOCK_EMERALD_BLOCK = 133, - E_BLOCK_SPRUCE_WOOD_STAIRS = 134, - E_BLOCK_BIRCH_WOOD_STAIRS = 135, - E_BLOCK_JUNGLE_WOOD_STAIRS = 136, - E_BLOCK_COMMAND_BLOCK = 137, - E_BLOCK_BEACON = 138, - E_BLOCK_COBBLESTONE_WALL = 139, - E_BLOCK_FLOWER_POT = 140, - E_BLOCK_CARROTS = 141, - E_BLOCK_POTATOES = 142, - E_BLOCK_WOODEN_BUTTON = 143, - E_BLOCK_HEAD = 144, - E_BLOCK_ANVIL = 145, - E_BLOCK_TRAPPED_CHEST = 146, - E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE = 147, - E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE = 148, - - E_BLOCK_INACTIVE_COMPARATOR = 149, - E_BLOCK_ACTIVE_COMPARATOR = 150, - E_BLOCK_DAYLIGHT_SENSOR = 151, - E_BLOCK_BLOCK_OF_REDSTONE = 152, - - E_BLOCK_NETHER_QUARTZ_ORE = 153, - E_BLOCK_HOPPER = 154, - E_BLOCK_QUARTZ_BLOCK = 155, - E_BLOCK_QUARTZ_STAIRS = 156, - E_BLOCK_ACTIVATOR_RAIL = 157, - - E_BLOCK_DROPPER = 158, - E_BLOCK_STAINED_CLAY = 159, // Synonym to terracotta - E_BLOCK_TERRACOTTA = 159, // Synonym to stained clay - E_BLOCK_STAINED_GLASS_PANE = 160, - E_BLOCK_NEW_LEAVES = 161, // Acacia and Dark Oak IDs in Minecraft 1.7.x - E_BLOCK_NEW_LOG = 162, - E_BLOCK_ACACIA_WOOD_STAIRS = 163, - E_BLOCK_DARK_OAK_WOOD_STAIRS = 164, - E_BLOCK_SLIME_BLOCK = 165, - E_BLOCK_BARRIER = 166, - E_BLOCK_IRON_TRAPDOOR = 167, - E_BLOCK_PRISMARINE_BLOCK = 168, - E_BLOCK_SEA_LANTERN = 169, - E_BLOCK_HAY_BALE = 170, - E_BLOCK_CARPET = 171, - E_BLOCK_HARDENED_CLAY = 172, - E_BLOCK_BLOCK_OF_COAL = 173, - E_BLOCK_PACKED_ICE = 174, - E_BLOCK_BIG_FLOWER = 175, - E_BLOCK_STANDING_BANNER = 176, - E_BLOCK_WALL_BANNER = 177, - E_BLOCK_INVERTED_DAYLIGHT_SENSOR = 178, - E_BLOCK_RED_SANDSTONE = 179, - E_BLOCK_RED_SANDSTONE_STAIRS = 180, - E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB = 181, - E_BLOCK_RED_SANDSTONE_SLAB = 182, - E_BLOCK_SPRUCE_FENCE_GATE = 183, - E_BLOCK_BIRCH_FENCE_GATE = 184, - E_BLOCK_JUNGLE_FENCE_GATE = 185, - E_BLOCK_DARK_OAK_FENCE_GATE = 186, - E_BLOCK_ACACIA_FENCE_GATE = 187, - E_BLOCK_SPRUCE_FENCE = 188, - E_BLOCK_BIRCH_FENCE = 189, - E_BLOCK_JUNGLE_FENCE = 190, - E_BLOCK_DARK_OAK_FENCE = 191, - E_BLOCK_ACACIA_FENCE = 192, - E_BLOCK_SPRUCE_DOOR = 193, - E_BLOCK_BIRCH_DOOR = 194, - E_BLOCK_JUNGLE_DOOR = 195, - E_BLOCK_ACACIA_DOOR = 196, - E_BLOCK_DARK_OAK_DOOR = 197, - E_BLOCK_END_ROD = 198, - E_BLOCK_CHORUS_PLANT = 199, - E_BLOCK_CHORUS_FLOWER = 200, - E_BLOCK_PURPUR_BLOCK = 201, - E_BLOCK_PURPUR_PILLAR = 202, - E_BLOCK_PURPUR_STAIRS = 203, - E_BLOCK_PURPUR_DOUBLE_SLAB = 204, - E_BLOCK_PURPUR_SLAB = 205, - E_BLOCK_END_BRICKS = 206, - E_BLOCK_BEETROOTS = 207, - E_BLOCK_GRASS_PATH = 208, - E_BLOCK_END_GATEWAY = 209, - E_BLOCK_REPEATING_COMMAND_BLOCK = 210, - E_BLOCK_CHAIN_COMMAND_BLOCK = 211, - E_BLOCK_FROSTED_ICE = 212, - E_BLOCK_MAGMA = 213, - E_BLOCK_NETHER_WART_BLOCK = 214, - E_BLOCK_RED_NETHER_BRICK = 215, - E_BLOCK_BONE_BLOCK = 216, - E_BLOCK_STRUCTURE_VOID = 217, - E_BLOCK_OBSERVER = 218, - E_BLOCK_WHITE_SHULKER_BOX = 219, - E_BLOCK_ORANGE_SHULKER_BOX = 220, - E_BLOCK_MAGENTA_SHULKER_BOX = 221, - E_BLOCK_LIGHT_BLUE_SHULKER_BOX = 222, - E_BLOCK_YELLOW_SHULKER_BOX = 223, - E_BLOCK_LIME_SHULKER_BOX = 224, - E_BLOCK_PINK_SHULKER_BOX = 225, - E_BLOCK_GRAY_SHULKER_BOX = 226, - E_BLOCK_LIGHT_GRAY_SHULKER_BOX = 227, - E_BLOCK_CYAN_SHULKER_BOX = 228, - E_BLOCK_PURPLE_SHULKER_BOX = 229, - E_BLOCK_BLUE_SHULKER_BOX = 230, - E_BLOCK_BROWN_SHULKER_BOX = 231, - E_BLOCK_GREEN_SHULKER_BOX = 232, - E_BLOCK_RED_SHULKER_BOX = 233, - E_BLOCK_BLACK_SHULKER_BOX = 234, - E_BLOCK_WHITE_GLAZED_TERRACOTTA = 235, - E_BLOCK_ORANGE_GLAZED_TERRACOTTA = 236, - E_BLOCK_MAGENTA_GLAZED_TERRACOTTA = 237, - E_BLOCK_LIGHT_BLUE_GLAZED_TERRACOTTA = 238, - E_BLOCK_YELLOW_GLAZED_TERRACOTTA = 239, - E_BLOCK_LIME_GLAZED_TERRACOTTA = 240, - E_BLOCK_PINK_GLAZED_TERRACOTTA = 241, - E_BLOCK_GRAY_GLAZED_TERRACOTTA = 242, - E_BLOCK_LIGHT_GRAY_GLAZED_TERRACOTTA = 243, - E_BLOCK_CYAN_GLAZED_TERRACOTTA = 244, - E_BLOCK_PURPLE_GLAZED_TERRACOTTA = 245, - E_BLOCK_BLUE_GLAZED_TERRACOTTA = 246, - E_BLOCK_BROWN_GLAZED_TERRACOTTA = 247, - E_BLOCK_GREEN_GLAZED_TERRACOTTA = 248, - E_BLOCK_RED_GLAZED_TERRACOTTA = 249, - E_BLOCK_BLACK_GLAZED_TERRACOTTA = 250, - E_BLOCK_CONCRETE = 251, - E_BLOCK_CONCRETE_POWDER = 252, - // ... - E_BLOCK_STRUCTURE_BLOCK = 255, - - // Keep these two as the last values. Update the last block value to the last block with an id less than 255 when adding another block - // IsValidBlock() depends on this (255 gets checked additionally because there is a gap. See https://minecraft.gamepedia.com/Data_values#Block_IDs - E_BLOCK_NUMBER_OF_TYPES = E_BLOCK_CONCRETE_POWDER + 1, ///< Number of individual (different) blocktypes - E_BLOCK_MAX_TYPE_ID = E_BLOCK_NUMBER_OF_TYPES - 1, ///< Maximum BlockType number used - - E_BLOCK_UNFINISHED = 254, // Special type used as a placeholder, signifying that the block lacks implementation - - // Synonym or ID compatibility - E_BLOCK_YELLOW_FLOWER = E_BLOCK_DANDELION, - E_BLOCK_RED_ROSE = E_BLOCK_FLOWER, - E_BLOCK_WOODEN_DOOR = E_BLOCK_OAK_DOOR, - E_BLOCK_FENCE_GATE = E_BLOCK_OAK_FENCE_GATE, - E_BLOCK_WOODEN_STAIRS = E_BLOCK_OAK_WOOD_STAIRS, -}; - - - - - -enum ENUM_ITEM_ID : short -{ - E_ITEM_EMPTY = -1, - - E_ITEM_FIRST = 256, // First true item type - - E_ITEM_IRON_SHOVEL = 256, - E_ITEM_IRON_PICKAXE = 257, - E_ITEM_IRON_AXE = 258, - E_ITEM_FLINT_AND_STEEL = 259, - E_ITEM_RED_APPLE = 260, - E_ITEM_BOW = 261, - E_ITEM_ARROW = 262, - E_ITEM_COAL = 263, - E_ITEM_DIAMOND = 264, - E_ITEM_IRON = 265, - E_ITEM_GOLD = 266, - E_ITEM_IRON_SWORD = 267, - E_ITEM_WOODEN_SWORD = 268, - E_ITEM_WOODEN_SHOVEL = 269, - E_ITEM_WOODEN_PICKAXE = 270, - E_ITEM_WOODEN_AXE = 271, - E_ITEM_STONE_SWORD = 272, - E_ITEM_STONE_SHOVEL = 273, - E_ITEM_STONE_PICKAXE = 274, - E_ITEM_STONE_AXE = 275, - E_ITEM_DIAMOND_SWORD = 276, - E_ITEM_DIAMOND_SHOVEL = 277, - E_ITEM_DIAMOND_PICKAXE = 278, - E_ITEM_DIAMOND_AXE = 279, - E_ITEM_STICK = 280, - E_ITEM_BOWL = 281, - E_ITEM_MUSHROOM_SOUP = 282, - E_ITEM_GOLD_SWORD = 283, - E_ITEM_GOLD_SHOVEL = 284, - E_ITEM_GOLD_PICKAXE = 285, - E_ITEM_GOLD_AXE = 286, - E_ITEM_STRING = 287, - E_ITEM_FEATHER = 288, - E_ITEM_GUNPOWDER = 289, - E_ITEM_WOODEN_HOE = 290, - E_ITEM_STONE_HOE = 291, - E_ITEM_IRON_HOE = 292, - E_ITEM_DIAMOND_HOE = 293, - E_ITEM_GOLD_HOE = 294, - E_ITEM_SEEDS = 295, - E_ITEM_WHEAT = 296, - E_ITEM_BREAD = 297, - E_ITEM_LEATHER_CAP = 298, - E_ITEM_LEATHER_TUNIC = 299, - E_ITEM_LEATHER_PANTS = 300, - E_ITEM_LEATHER_BOOTS = 301, - E_ITEM_CHAIN_HELMET = 302, - E_ITEM_CHAIN_CHESTPLATE = 303, - E_ITEM_CHAIN_LEGGINGS = 304, - E_ITEM_CHAIN_BOOTS = 305, - E_ITEM_IRON_HELMET = 306, - E_ITEM_IRON_CHESTPLATE = 307, - E_ITEM_IRON_LEGGINGS = 308, - E_ITEM_IRON_BOOTS = 309, - E_ITEM_DIAMOND_HELMET = 310, - E_ITEM_DIAMOND_CHESTPLATE = 311, - E_ITEM_DIAMOND_LEGGINGS = 312, - E_ITEM_DIAMOND_BOOTS = 313, - E_ITEM_GOLD_HELMET = 314, - E_ITEM_GOLD_CHESTPLATE = 315, - E_ITEM_GOLD_LEGGINGS = 316, - E_ITEM_GOLD_BOOTS = 317, - E_ITEM_FLINT = 318, - E_ITEM_RAW_PORKCHOP = 319, - E_ITEM_COOKED_PORKCHOP = 320, - E_ITEM_PAINTING = 321, - E_ITEM_GOLDEN_APPLE = 322, - E_ITEM_SIGN = 323, - E_ITEM_WOODEN_DOOR = 324, - E_ITEM_BUCKET = 325, - E_ITEM_WATER_BUCKET = 326, - E_ITEM_LAVA_BUCKET = 327, - E_ITEM_MINECART = 328, - E_ITEM_SADDLE = 329, - E_ITEM_IRON_DOOR = 330, - E_ITEM_REDSTONE_DUST = 331, - E_ITEM_SNOWBALL = 332, - E_ITEM_BOAT = 333, - E_ITEM_LEATHER = 334, - E_ITEM_MILK = 335, - E_ITEM_CLAY_BRICK = 336, - E_ITEM_CLAY = 337, - E_ITEM_SUGARCANE = 338, - E_ITEM_SUGAR_CANE = 338, - E_ITEM_PAPER = 339, - E_ITEM_BOOK = 340, - E_ITEM_SLIMEBALL = 341, - E_ITEM_CHEST_MINECART = 342, - E_ITEM_FURNACE_MINECART = 343, - E_ITEM_EGG = 344, - E_ITEM_COMPASS = 345, - E_ITEM_FISHING_ROD = 346, - E_ITEM_CLOCK = 347, - E_ITEM_GLOWSTONE_DUST = 348, - E_ITEM_RAW_FISH = 349, - E_ITEM_COOKED_FISH = 350, - E_ITEM_DYE = 351, - E_ITEM_BONE = 352, - E_ITEM_SUGAR = 353, - E_ITEM_CAKE = 354, - E_ITEM_BED = 355, - E_ITEM_REDSTONE_REPEATER = 356, - E_ITEM_COOKIE = 357, - E_ITEM_MAP = 358, - E_ITEM_SHEARS = 359, - E_ITEM_MELON_SLICE = 360, - E_ITEM_PUMPKIN_SEEDS = 361, - E_ITEM_MELON_SEEDS = 362, - E_ITEM_RAW_BEEF = 363, - E_ITEM_STEAK = 364, - E_ITEM_RAW_CHICKEN = 365, - E_ITEM_COOKED_CHICKEN = 366, - E_ITEM_ROTTEN_FLESH = 367, - E_ITEM_ENDER_PEARL = 368, - E_ITEM_BLAZE_ROD = 369, - E_ITEM_GHAST_TEAR = 370, - E_ITEM_GOLD_NUGGET = 371, - E_ITEM_NETHER_WART = 372, - E_ITEM_POTION = 373, - E_ITEM_POTIONS = 373, // OBSOLETE, use E_ITEM_POTION instead - E_ITEM_GLASS_BOTTLE = 374, - E_ITEM_SPIDER_EYE = 375, - E_ITEM_FERMENTED_SPIDER_EYE = 376, - E_ITEM_BLAZE_POWDER = 377, - E_ITEM_MAGMA_CREAM = 378, - E_ITEM_BREWING_STAND = 379, - E_ITEM_CAULDRON = 380, - E_ITEM_EYE_OF_ENDER = 381, - E_ITEM_GLISTERING_MELON = 382, - E_ITEM_SPAWN_EGG = 383, - E_ITEM_BOTTLE_O_ENCHANTING = 384, - E_ITEM_FIRE_CHARGE = 385, - E_ITEM_BOOK_AND_QUILL = 386, - E_ITEM_WRITTEN_BOOK = 387, - E_ITEM_EMERALD = 388, - E_ITEM_ITEM_FRAME = 389, - E_ITEM_FLOWER_POT = 390, - E_ITEM_CARROT = 391, - E_ITEM_POTATO = 392, - E_ITEM_BAKED_POTATO = 393, - E_ITEM_POISONOUS_POTATO = 394, - E_ITEM_EMPTY_MAP = 395, - E_ITEM_GOLDEN_CARROT = 396, - E_ITEM_HEAD = 397, - E_ITEM_CARROT_ON_STICK = 398, - E_ITEM_NETHER_STAR = 399, - E_ITEM_PUMPKIN_PIE = 400, - E_ITEM_FIREWORK_ROCKET = 401, - E_ITEM_FIREWORK_STAR = 402, - E_ITEM_ENCHANTED_BOOK = 403, - E_ITEM_COMPARATOR = 404, - E_ITEM_NETHER_BRICK = 405, - E_ITEM_NETHER_QUARTZ = 406, - E_ITEM_MINECART_WITH_TNT = 407, - E_ITEM_MINECART_WITH_HOPPER = 408, - E_ITEM_PRISMARINE_SHARD = 409, - E_ITEM_PRISMARINE_CRYSTALS = 410, - E_ITEM_RAW_RABBIT = 411, - E_ITEM_COOKED_RABBIT = 412, - E_ITEM_RABBIT_STEW = 413, - E_ITEM_RABBITS_FOOT = 414, - E_ITEM_RABBIT_HIDE = 415, - E_ITEM_ARMOR_STAND = 416, - E_ITEM_IRON_HORSE_ARMOR = 417, - E_ITEM_GOLD_HORSE_ARMOR = 418, - E_ITEM_DIAMOND_HORSE_ARMOR = 419, - E_ITEM_LEAD = 420, - E_ITEM_LEASH = E_ITEM_LEAD, - E_ITEM_NAME_TAG = 421, - E_ITEM_MINECART_WITH_COMMAND_BLOCK = 422, - E_ITEM_RAW_MUTTON = 423, - E_ITEM_COOKED_MUTTON = 424, - E_ITEM_BANNER = 425, - E_ITEM_END_CRYSTAL = 426, - E_ITEM_SPRUCE_DOOR = 427, - E_ITEM_BIRCH_DOOR = 428, - E_ITEM_JUNGLE_DOOR = 429, - E_ITEM_ACACIA_DOOR = 430, - E_ITEM_DARK_OAK_DOOR = 431, - E_ITEM_CHORUS_FRUIT = 432, - E_ITEM_POPPED_CHORUS_FRUIT = 433, - E_ITEM_BEETROOT = 434, - E_ITEM_BEETROOT_SEEDS = 435, - E_ITEM_BEETROOT_SOUP = 436, - E_ITEM_DRAGON_BREATH = 437, - E_ITEM_SPLASH_POTION = 438, - E_ITEM_SPECTRAL_ARROW = 439, - E_ITEM_TIPPED_ARROW = 440, - E_ITEM_LINGERING_POTION = 441, - E_ITEM_SHIELD = 442, - E_ITEM_ELYTRA = 443, - E_ITEM_SPRUCE_BOAT = 444, - E_ITEM_BIRCH_BOAT = 445, - E_ITEM_JUNGLE_BOAT = 446, - E_ITEM_ACACIA_BOAT = 447, - E_ITEM_DARK_OAK_BOAT = 448, - E_ITEM_TOTEM_OF_UNDYING = 449, - E_ITEM_SHULKER_SHELL = 450, - E_ITEM_IRON_NUGGET = 452, - - // Keep these two as the last values of the consecutive list, without a number - they will get their correct number assigned automagically by C++ - // IsValidItem() depends on this! - E_ITEM_NUMBER_OF_CONSECUTIVE_TYPES, ///< Number of individual (different) consecutive itemtypes - E_ITEM_MAX_CONSECUTIVE_TYPE_ID = E_ITEM_NUMBER_OF_CONSECUTIVE_TYPES - 1, ///< Maximum consecutive ItemType number used - - E_ITEM_FIRST_DISC = 2256, - E_ITEM_13_DISC = 2256, - E_ITEM_CAT_DISC = 2257, - E_ITEM_BLOCKS_DISC = 2258, - E_ITEM_CHIRP_DISC = 2259, - E_ITEM_FAR_DISC = 2260, - E_ITEM_MALL_DISC = 2261, - E_ITEM_MELLOHI_DISC = 2262, - E_ITEM_STAL_DISC = 2263, - E_ITEM_STRAD_DISC = 2264, - E_ITEM_WARD_DISC = 2265, - E_ITEM_11_DISC = 2266, - E_ITEM_WAIT_DISC = 2267, - - // Keep these two as the last values of the disc list, without a number - they will get their correct number assigned automagically by C++ - // IsValidItem() depends on this! - E_ITEM_LAST_DISC_PLUS_ONE, ///< Useless, really, but needs to be present for the following value - E_ITEM_LAST_DISC = E_ITEM_LAST_DISC_PLUS_ONE - 1, ///< Maximum disc itemtype number used - - E_ITEM_LAST = E_ITEM_LAST_DISC, ///< Maximum valid ItemType -}; - - - - - -enum ENUM_BLOCK_META : NIBBLETYPE -{ - // Please keep this list alpha-sorted by the blocktype part - // then number-sorted for the same block - - //////////////////////////////////////////////////////////////////////////////// - // Block metas: - - // E_BLOCK_ANVIL metas - E_BLOCK_ANVIL_Z = 0, - E_BLOCK_ANVIL_X = 1, - E_BLOCK_ANVIL_NO_DAMAGE = 0, - E_BLOCK_ANVIL_LOW_DAMAGE = 4, - E_BLOCK_ANVIL_HIGH_DAMAGE = 8, - - // E_BLOCK_BED metas: - E_BLOCK_BED_ZP = 0, - E_BLOCK_BED_XM = 1, - E_BLOCK_BED_ZM = 2, - E_BLOCK_BED_XP = 3, - E_BLOCK_BED_OCCUPIED = 4, - E_BLOCK_BED_BED_HEAD = 8, - - // E_BLOCK_BIG_FLOWER metas: - E_META_BIG_FLOWER_SUNFLOWER = 0, - E_META_BIG_FLOWER_LILAC = 1, - E_META_BIG_FLOWER_DOUBLE_TALL_GRASS = 2, - E_META_BIG_FLOWER_LARGE_FERN = 3, - E_META_BIG_FLOWER_ROSE_BUSH = 4, - E_META_BIG_FLOWER_PEONY = 5, - // 0x8 is supposedly a bit flag but all vanilla plants have this value - E_META_BIG_FLOWER_TOP = 10, - - // E_BLOCK_BREWING_STAND metas - E_META_BREWING_STAND_FILLED_SLOT_XP = 1, - E_META_BREWING_STAND_FILLED_SLOT_XM_ZP = 2, - E_META_BREWING_STAND_FILLED_SLOT_XM_ZM = 4, - - // E_BLOCK_BUTTON metas - E_BLOCK_BUTTON_YM = 0, - E_BLOCK_BUTTON_XP = 1, - E_BLOCK_BUTTON_XM = 2, - E_BLOCK_BUTTON_ZP = 3, - E_BLOCK_BUTTON_ZM = 4, - E_BLOCK_BUTTON_YP = 5, - E_BLOCK_BUTTON_PRESSED = 8, - - // E_BLOCK_CARPET metas: - E_META_CARPET_WHITE = 0, - E_META_CARPET_ORANGE = 1, - E_META_CARPET_MAGENTA = 2, - E_META_CARPET_LIGHTBLUE = 3, - E_META_CARPET_YELLOW = 4, - E_META_CARPET_LIGHTGREEN = 5, - E_META_CARPET_PINK = 6, - E_META_CARPET_GRAY = 7, - E_META_CARPET_LIGHTGRAY = 8, - E_META_CARPET_CYAN = 9, - E_META_CARPET_PURPLE = 10, - E_META_CARPET_BLUE = 11, - E_META_CARPET_BROWN = 12, - E_META_CARPET_GREEN = 13, - E_META_CARPET_RED = 14, - E_META_CARPET_BLACK = 15, - - // E_BLOCK_CHEST metas: - E_META_CHEST_FACING_ZM = 2, - E_META_CHEST_FACING_ZP = 3, - E_META_CHEST_FACING_XM = 4, - E_META_CHEST_FACING_XP = 5, - - // E_BLOCK_CONCRETE metas: - E_META_CONCRETE_WHITE = 0, - E_META_CONCRETE_ORANGE = 1, - E_META_CONCRETE_MAGENTA = 2, - E_META_CONCRETE_LIGHTBLUE = 3, - E_META_CONCRETE_YELLOW = 4, - E_META_CONCRETE_LIGHTGREEN = 5, - E_META_CONCRETE_PINK = 6, - E_META_CONCRETE_GRAY = 7, - E_META_CONCRETE_LIGHTGRAY = 8, - E_META_CONCRETE_CYAN = 9, - E_META_CONCRETE_PURPLE = 10, - E_META_CONCRETE_BLUE = 11, - E_META_CONCRETE_BROWN = 12, - E_META_CONCRETE_GREEN = 13, - E_META_CONCRETE_RED = 14, - E_META_CONCRETE_BLACK = 15, - - // E_BLOCK_CONCRETE_POWDER metas: - E_META_CONCRETE_POWDER_WHITE = 0, - E_META_CONCRETE_POWDER_ORANGE = 1, - E_META_CONCRETE_POWDER_MAGENTA = 2, - E_META_CONCRETE_POWDER_LIGHTBLUE = 3, - E_META_CONCRETE_POWDER_YELLOW = 4, - E_META_CONCRETE_POWDER_LIGHTGREEN = 5, - E_META_CONCRETE_POWDER_PINK = 6, - E_META_CONCRETE_POWDER_GRAY = 7, - E_META_CONCRETE_POWDER_LIGHTGRAY = 8, - E_META_CONCRETE_POWDER_CYAN = 9, - E_META_CONCRETE_POWDER_PURPLE = 10, - E_META_CONCRETE_POWDER_BLUE = 11, - E_META_CONCRETE_POWDER_BROWN = 12, - E_META_CONCRETE_POWDER_GREEN = 13, - E_META_CONCRETE_POWDER_RED = 14, - E_META_CONCRETE_POWDER_BLACK = 15, - - // E_BLOCK_DIRT metas: - E_META_DIRT_NORMAL = 0, - E_META_DIRT_GRASSLESS = 1, - E_META_DIRT_COARSE = 1, - E_META_DIRT_PODZOL = 2, - - // E_BLOCK_DISPENSER / E_BLOCK_DROPPER metas: - E_META_DROPSPENSER_FACING_YM = 0, - E_META_DROPSPENSER_FACING_YP = 1, - E_META_DROPSPENSER_FACING_ZM = 2, - E_META_DROPSPENSER_FACING_ZP = 3, - E_META_DROPSPENSER_FACING_XM = 4, - E_META_DROPSPENSER_FACING_XP = 5, - E_META_DROPSPENSER_FACING_MASK = 7, - E_META_DROPSPENSER_ACTIVATED = 8, - - // E_BLOCK_DOUBLE_STONE_SLAB metas: - E_META_DOUBLE_STONE_SLAB_STONE = 0, - E_META_DOUBLE_STONE_SLAB_SANDSTON = 1, - E_META_DOUBLE_STONE_SLAB_WOODEN = 2, - E_META_DOUBLE_STONE_SLAB_COBBLESTONE = 3, - E_META_DOUBLE_STONE_SLAB_BRICK = 4, - E_META_DOUBLE_STONE_SLAB_STONE_BRICK = 5, - E_META_DOUBLE_STONE_SLAB_NETHER_BRICK = 6, - E_META_DOUBLE_STONE_SLAB_QUARTZ = 7, - E_META_DOUBLE_STONE_SLAB_SMOOTH_STONE = 8, - E_META_DOUBLE_STONE_SLAB_SMOOTH_SANDSTONE = 9, - E_META_DOUBLE_STONE_SLAB_TILE_QUARTZ = 10, - - // E_BLOCK_END_PORTAL_FRAME metas: - E_META_END_PORTAL_FRAME_ZP = 0, // Faces towards centre of portal - E_META_END_PORTAL_FRAME_XM = 1, - E_META_END_PORTAL_FRAME_ZM = 2, - E_META_END_PORTAL_FRAME_XP = 3, - E_META_END_PORTAL_FRAME_ZP_EYE = 4, // Frames with ender eye - E_META_END_PORTAL_FRAME_XM_EYE = 5, - E_META_END_PORTAL_FRAME_ZM_EYE = 6, - E_META_END_PORTAL_FRAME_XP_EYE = 7, - E_META_END_PORTAL_FRAME_NO_EYE = 0, // Just the eye bitflag - E_META_END_PORTAL_FRAME_EYE = 4, - - // E_BLOCK_FLOWER metas: - E_META_FLOWER_POPPY = 0, - E_META_FLOWER_BLUE_ORCHID = 1, - E_META_FLOWER_ALLIUM = 2, - E_META_FLOWER_RED_TULIP = 4, - E_META_FLOWER_ORANGE_TULIP = 5, - E_META_FLOWER_WHITE_TULIP = 6, - E_META_FLOWER_PINK_TULIP = 7, - E_META_FLOWER_OXEYE_DAISY = 8, - - // E_BLOCK_JUKEBOX metas: - E_META_JUKEBOX_OFF = 0, - E_META_JUKEBOX_ON = 1, - - // E_BLOCK_HOPPER metas: - E_META_HOPPER_FACING_YM = 0, - E_META_HOPPER_UNATTACHED = 1, // Hopper doesn't move items up, there's no YP - E_META_HOPPER_FACING_ZM = 2, - E_META_HOPPER_FACING_ZP = 3, - E_META_HOPPER_FACING_XM = 4, - E_META_HOPPER_FACING_XP = 5, - - // E_BLOCK_LEAVES metas: - E_META_LEAVES_APPLE = 0, - E_META_LEAVES_CONIFER = 1, - E_META_LEAVES_BIRCH = 2, - E_META_LEAVES_JUNGLE = 3, - E_META_LEAVES_APPLE_NO_DECAY = 4, - E_META_LEAVES_CONIFER_NO_DECAY = 5, - E_META_LEAVES_BIRCH_NO_DECAY = 6, - E_META_LEAVES_JUNGLE_NO_DECAY = 7, - E_META_LEAVES_APPLE_CHECK_DECAY = 8, - E_META_LEAVES_CONIFER_CHECK_DECAY = 9, - E_META_LEAVES_BIRCH_CHECK_DECAY = 10, - E_META_LEAVES_JUNGLE_CHECK_DECAY = 11, - - // E_BLOCK_LEAVES meta cont. (Block ID 161): - E_META_NEWLEAVES_ACACIA = 0, - E_META_NEWLEAVES_DARK_OAK = 1, - E_META_NEWLEAVES_ACACIA_NO_DECAY = 4, - E_META_NEWLEAVES_DARK_OAK_NO_DECAY = 5, - E_META_NEWLEAVES_ACACIA_CHECK_DECAY = 8, - E_META_NEWLEAVES_DARK_OAK_CHECK_DECAY = 9, - - // E_BLOCK_LOG metas: - E_META_LOG_APPLE = 0, - E_META_LOG_CONIFER = 1, - E_META_LOG_BIRCH = 2, - E_META_LOG_JUNGLE = 3, - - // E_BLOCK_NEW_LOG metas: - E_META_NEW_LOG_ACACIA_WOOD = 0, - E_META_NEW_LOG_DARK_OAK_WOOD = 1, - - // E_BLOCK_PISTON metas: - E_META_PISTON_DOWN = 0, - E_META_PISTON_U = 1, - E_META_PISTON_ZM = 2, - E_META_PISTON_ZP = 3, - E_META_PISTON_XM = 4, - E_META_PISTON_XP = 5, - E_META_PISTON_HEAD_STICKY = 8, - E_META_PISTON_EXTENDED = 8, - - // E_BLOCK_PLANKS metas: - E_META_PLANKS_OAK = 0, - E_META_PLANKS_SPRUCE = 1, - E_META_PLANKS_BIRCH = 2, - E_META_PLANKS_JUNGLE = 3, - E_META_PLANKS_ACACIA = 4, - E_META_PLANKS_DARK_OAK = 5, - - // E_BLOCK_(XXX_WEIGHTED)_PRESSURE_PLATE metas: - E_META_PRESSURE_PLATE_RAISED = 0, - E_META_PRESSURE_PLATE_DEPRESSED = 1, - - // E_BLOCK_PRISMARINE_BLOCK metas: - E_META_PRISMARINE_BLOCK_ROUGH = 0, - E_META_PRISMARINE_BLOCK_BRICKS = 1, - E_META_PRISMARINE_BLOCK_DARK = 2, - - // E_BLOCK_QUARTZ_BLOCK metas: - E_META_QUARTZ_NORMAL = 0, - E_META_QUARTZ_CHISELLED = 1, - E_META_QUARTZ_PILLAR = 2, - - // E_BLOCK_RAIL metas - E_META_RAIL_ZM_ZP = 0, - E_META_RAIL_XM_XP = 1, - E_META_RAIL_ASCEND_XP = 2, - E_META_RAIL_ASCEND_XM = 3, - E_META_RAIL_ASCEND_ZM = 4, - E_META_RAIL_ASCEND_ZP = 5, - E_META_RAIL_CURVED_ZP_XP = 6, - E_META_RAIL_CURVED_ZP_XM = 7, - E_META_RAIL_CURVED_ZM_XM = 8, - E_META_RAIL_CURVED_ZM_XP = 9, - - // E_BLOCK_RED_SANDSTONE metas: - E_META_RED_SANDSTONE_NORMAL = 0, - E_META_RED_SANDSTONE_ORNAMENT = 1, - E_META_RED_SANDSTONE_SMOOTH = 2, - - // E_BLOCK_SAND metas: - E_META_SAND_NORMAL = 0, - E_META_SAND_RED = 1, - - // E_BLOCK_SANDSTONE metas: - E_META_SANDSTONE_NORMAL = 0, - E_META_SANDSTONE_ORNAMENT = 1, - E_META_SANDSTONE_SMOOTH = 2, - - // E_BLOCK_SAPLING metas (lowest 3 bits): - E_META_SAPLING_APPLE = 0, - E_META_SAPLING_CONIFER = 1, - E_META_SAPLING_BIRCH = 2, - E_META_SAPLING_JUNGLE = 3, - E_META_SAPLING_ACACIA = 4, - E_META_SAPLING_DARK_OAK = 5, - - // E_BLOCK_SILVERFISH_EGG metas: - E_META_SILVERFISH_EGG_STONE = 0, - E_META_SILVERFISH_EGG_COBBLESTONE = 1, - E_META_SILVERFISH_EGG_STONE_BRICK = 2, - - // E_BLOCK_SNOW metas: - E_META_SNOW_LAYER_ONE = 0, - E_META_SNOW_LAYER_TWO = 1, - E_META_SNOW_LAYER_THREE = 2, - E_META_SNOW_LAYER_FOUR = 3, - E_META_SNOW_LAYER_FIVE = 4, - E_META_SNOW_LAYER_SIX = 5, - E_META_SNOW_LAYER_SEVEN = 6, - E_META_SNOW_LAYER_EIGHT = 7, - - // E_BLOCK_SPONGE metas: - E_META_SPONGE_DRY = 0, - E_META_SPONGE_WET = 1, - - // E_BLOCK_STAINED_CLAY metas: - E_META_STAINED_CLAY_WHITE = 0, - E_META_STAINED_CLAY_ORANGE = 1, - E_META_STAINED_CLAY_MAGENTA = 2, - E_META_STAINED_CLAY_LIGHTBLUE = 3, - E_META_STAINED_CLAY_YELLOW = 4, - E_META_STAINED_CLAY_LIGHTGREEN = 5, - E_META_STAINED_CLAY_PINK = 6, - E_META_STAINED_CLAY_GRAY = 7, - E_META_STAINED_CLAY_LIGHTGRAY = 8, - E_META_STAINED_CLAY_CYAN = 9, - E_META_STAINED_CLAY_PURPLE = 10, - E_META_STAINED_CLAY_BLUE = 11, - E_META_STAINED_CLAY_BROWN = 12, - E_META_STAINED_CLAY_GREEN = 13, - E_META_STAINED_CLAY_RED = 14, - E_META_STAINED_CLAY_BLACK = 15, - - // E_BLOCK_STAINED_GLASS metas: - E_META_STAINED_GLASS_WHITE = 0, - E_META_STAINED_GLASS_ORANGE = 1, - E_META_STAINED_GLASS_MAGENTA = 2, - E_META_STAINED_GLASS_LIGHTBLUE = 3, - E_META_STAINED_GLASS_YELLOW = 4, - E_META_STAINED_GLASS_LIGHTGREEN = 5, - E_META_STAINED_GLASS_PINK = 6, - E_META_STAINED_GLASS_GRAY = 7, - E_META_STAINED_GLASS_LIGHTGRAY = 8, - E_META_STAINED_GLASS_CYAN = 9, - E_META_STAINED_GLASS_PURPLE = 10, - E_META_STAINED_GLASS_BLUE = 11, - E_META_STAINED_GLASS_BROWN = 12, - E_META_STAINED_GLASS_GREEN = 13, - E_META_STAINED_GLASS_RED = 14, - E_META_STAINED_GLASS_BLACK = 15, - - // E_BLOCK_STAINED_GLASS_PANE metas: - E_META_STAINED_GLASS_PANE_WHITE = 0, - E_META_STAINED_GLASS_PANE_ORANGE = 1, - E_META_STAINED_GLASS_PANE_MAGENTA = 2, - E_META_STAINED_GLASS_PANE_LIGHTBLUE = 3, - E_META_STAINED_GLASS_PANE_YELLOW = 4, - E_META_STAINED_GLASS_PANE_LIGHTGREEN = 5, - E_META_STAINED_GLASS_PANE_PINK = 6, - E_META_STAINED_GLASS_PANE_GRAY = 7, - E_META_STAINED_GLASS_PANE_LIGHTGRAY = 8, - E_META_STAINED_GLASS_PANE_CYAN = 9, - E_META_STAINED_GLASS_PANE_PURPLE = 10, - E_META_STAINED_GLASS_PANE_BLUE = 11, - E_META_STAINED_GLASS_PANE_BROWN = 12, - E_META_STAINED_GLASS_PANE_GREEN = 13, - E_META_STAINED_GLASS_PANE_RED = 14, - E_META_STAINED_GLASS_PANE_BLACK = 15, - - // E_BLOCK_STAIRS metas: - E_BLOCK_STAIRS_XP = 0, - E_BLOCK_STAIRS_XM = 1, - E_BLOCK_STAIRS_ZP = 2, - E_BLOCK_STAIRS_ZM = 3, - E_BLOCK_STAIRS_UPSIDE_DOWN = 4, - - // E_BLOCK_STONE metas: - E_META_STONE_STONE = 0, - E_META_STONE_GRANITE = 1, - E_META_STONE_POLISHED_GRANITE = 2, - E_META_STONE_DIORITE = 3, - E_META_STONE_POLISHED_DIORITE = 4, - E_META_STONE_ANDESITE = 5, - E_META_STONE_POLISHED_ANDESITE = 6, - - // E_BLOCK_STONE_SLAB metas: - E_META_STONE_SLAB_STONE = 0, - E_META_STONE_SLAB_SANDSTONE = 1, - E_META_STONE_SLAB_PLANKS = 2, - E_META_STONE_SLAB_COBBLESTONE = 3, - E_META_STONE_SLAB_BRICK = 4, - E_META_STONE_SLAB_STONE_BRICK = 5, - E_META_STONE_SLAB_NETHER_BRICK = 6, - E_META_STONE_SLAB_QUARTZ = 7, - - // E_BLOCK_STONE_BRICKS metas: - E_META_STONE_BRICK_NORMAL = 0, - E_META_STONE_BRICK_MOSSY = 1, - E_META_STONE_BRICK_CRACKED = 2, - E_META_STONE_BRICK_ORNAMENT = 3, - - // E_BLOCK_TALL_GRASS metas: - E_META_TALL_GRASS_DEAD_SHRUB = 0, - E_META_TALL_GRASS_GRASS = 1, - E_META_TALL_GRASS_FERN = 2, - E_META_TALL_GRASS_BIOME = 3, - - // E_BLOCK_TORCH, E_BLOCK_REDSTONE_TORCH_OFF, E_BLOCK_REDSTONE_TORCH_ON metas: - E_META_TORCH_EAST = 1, // east face of the block, pointing east - E_META_TORCH_WEST = 2, - E_META_TORCH_SOUTH = 3, - E_META_TORCH_NORTH = 4, - E_META_TORCH_FLOOR = 5, - E_META_TORCH_XM = 1, // Torch attached to the XM side of its block - E_META_TORCH_XP = 2, // Torch attached to the XP side of its block - E_META_TORCH_ZM = 3, // Torch attached to the ZM side of its block - E_META_TORCH_ZP = 4, // Torch attached to the ZP side of its block - - // E_META_LOG metas: - E_META_LOG_OAK_UP_DOWN = 0, - E_META_LOG_SPRUCE_UP_DOWN = 1, - E_META_LOG_BIRCH_UP_DOWN = 2, - E_META_LOG_JUNGLE_UP_DOWN = 3, - E_META_LOG_OAK_X = 4, - E_META_LOG_SPRUCE_X = 5, - E_META_LOG_BIRCH_X = 6, - E_META_LOG_JUNGLE_X = 7, - E_META_LOG_OAK_Z = 8, - E_META_LOG_SPRUCE_Z = 9, - E_META_LOG_BIRCH_Z = 10, - E_META_LOG_JUNGLE_Z = 11, - E_META_LOG_OAK_BARK_ONLY = 12, - E_META_LOG_SPRUCE_BARK_ONLY = 13, - E_META_LOG_BIRCH_BARK_ONLY = 14, - E_META_LOG_JUNGLE_BARK_ONLY = 15, - - // E_META_LOG metas cont. (Block ID 162): - E_META_NEWLOG_ACACIA_UP_DOWN = 0, - E_META_NEWLOG_DARK_OAK_UP_DOWN = 1, - E_META_NEWLOG_ACACIA_X = 4, - E_META_NEWLOG_DARK_OAK_X = 5, - E_META_NEWLOG_ACACIA_Z = 8, - E_META_NEWLOG_DARK_OAK_Z = 9, - E_META_NEWLOG_ACACIA_BARK_ONLY = 12, - E_META_NEWLOG_DARK_OAK_BARK_ONLY = 13, - - // E_BLOCK_WOODEN_DOUBLE_SLAB metas: - E_META_WOODEN_DOUBLE_SLAB_OAK = 0, - E_META_WOODEN_DOUBLE_SLAB_SPRUCE = 1, - E_META_WOODEN_DOUBLE_SLAB_BIRCH = 2, - E_META_WOODEN_DOUBLE_SLAB_JUNGLE = 3, - E_META_WOODEN_DOUBLE_SLAB_ACACIA = 4, - E_META_WOODEN_DOUBLE_SLAB_DARK_OAK = 5, - - // E_BLOCK_WOODEN_SLAB metas: - E_META_WOODEN_SLAB_OAK = 0, - E_META_WOODEN_SLAB_SPRUCE = 1, - E_META_WOODEN_SLAB_BIRCH = 2, - E_META_WOODEN_SLAB_JUNGLE = 3, - E_META_WOODEN_SLAB_ACACIA = 4, - E_META_WOODEN_SLAB_DARK_OAK = 5, - E_META_WOODEN_SLAB_UPSIDE_DOWN = 8, - - // E_BLOCK_WOOL metas: - E_META_WOOL_WHITE = 0, - E_META_WOOL_ORANGE = 1, - E_META_WOOL_MAGENTA = 2, - E_META_WOOL_LIGHTBLUE = 3, - E_META_WOOL_YELLOW = 4, - E_META_WOOL_LIGHTGREEN = 5, - E_META_WOOL_PINK = 6, - E_META_WOOL_GRAY = 7, - E_META_WOOL_LIGHTGRAY = 8, - E_META_WOOL_CYAN = 9, - E_META_WOOL_PURPLE = 10, - E_META_WOOL_BLUE = 11, - E_META_WOOL_BROWN = 12, - E_META_WOOL_GREEN = 13, - E_META_WOOL_RED = 14, - E_META_WOOL_BLACK = 15, -}; - - - - - -enum ENUM_ITEM_META : short -{ - // Please keep this list alpha-sorted by the itemtype part - // then number-sorted for the same item - - //////////////////////////////////////////////////////////////////////////////// - // Item metas: - - // E_ITEM_BANNER metas: - E_META_BANNER_BLACK = 0, - E_META_BANNER_RED = 1, - E_META_BANNER_GREEN = 2, - E_META_BANNER_BROWN = 3, - E_META_BANNER_BLUE = 4, - E_META_BANNER_PURPLE = 5, - E_META_BANNER_CYAN = 6, - E_META_BANNER_LIGHTGRAY = 7, - E_META_BANNER_GRAY = 8, - E_META_BANNER_PINK = 9, - E_META_BANNER_LIGHTGREEN = 10, - E_META_BANNER_YELLOW = 11, - E_META_BANNER_LIGHTBLUE = 12, - E_META_BANNER_MAGENTA = 13, - E_META_BANNER_ORANGE = 14, - E_META_BANNER_WHITE = 15, - - // E_ITEM_COAL metas: - E_META_COAL_NORMAL = 0, - E_META_COAL_CHARCOAL = 1, - - // E_ITEM_DYE metas: - E_META_DYE_BLACK = 0, - E_META_DYE_RED = 1, - E_META_DYE_GREEN = 2, - E_META_DYE_BROWN = 3, - E_META_DYE_BLUE = 4, - E_META_DYE_PURPLE = 5, - E_META_DYE_CYAN = 6, - E_META_DYE_LIGHTGRAY = 7, - E_META_DYE_GRAY = 8, - E_META_DYE_PINK = 9, - E_META_DYE_LIGHTGREEN = 10, - E_META_DYE_YELLOW = 11, - E_META_DYE_LIGHTBLUE = 12, - E_META_DYE_MAGENTA = 13, - E_META_DYE_ORANGE = 14, - E_META_DYE_WHITE = 15, - - // E_ITEM_GOLDEN_APPLE metas: - E_META_GOLDEN_APPLE_NORMAL = 0, - E_META_GOLDEN_APPLE_ENCHANTED = 1, - - // E_ITEM_HEAD metas: - E_META_HEAD_SKELETON = 0, - E_META_HEAD_WITHER = 1, - E_META_HEAD_ZOMBIE = 2, - E_META_HEAD_PLAYER = 3, - E_META_HEAD_CREEPER = 4, - E_META_HEAD_DRAGON = 5, - - // E_ITEM_RAW_FISH metas: - E_META_RAW_FISH_FISH = 0, - E_META_RAW_FISH_SALMON = 1, - E_META_RAW_FISH_CLOWNFISH = 2, - E_META_RAW_FISH_PUFFERFISH = 3, - - // E_ITEM_COOKED_FISH metas: - E_META_COOKED_FISH_FISH = 0, - E_META_COOKED_FISH_SALMON = 1, - - // E_ITEM_MINECART_TRACKS metas: - E_META_TRACKS_X = 1, - E_META_TRACKS_Z = 0, - - // E_ITEM_SPAWN_EGG metas: - // See also cMonster::eType, since monster type and spawn egg meta are the same - E_META_SPAWN_EGG_PICKUP = 1, - E_META_SPAWN_EGG_EXPERIENCE_ORB = 2, - E_META_SPAWN_EGG_LEASH_KNOT = 8, - E_META_SPAWN_EGG_PAINTING = 9, - E_META_SPAWN_EGG_ARROW = 10, - E_META_SPAWN_EGG_SNOWBALL = 11, - E_META_SPAWN_EGG_FIREBALL = 12, - E_META_SPAWN_EGG_SMALL_FIREBALL = 13, - E_META_SPAWN_EGG_ENDER_PEARL = 14, - E_META_SPAWN_EGG_EYE_OF_ENDER = 15, - E_META_SPAWN_EGG_SPLASH_POTION = 16, - E_META_SPAWN_EGG_EXP_BOTTLE = 17, - E_META_SPAWN_EGG_ITEM_FRAME = 18, - E_META_SPAWN_EGG_WITHER_SKULL = 19, - E_META_SPAWN_EGG_PRIMED_TNT = 20, - E_META_SPAWN_EGG_FALLING_BLOCK = 21, - E_META_SPAWN_EGG_FIREWORK = 22, - E_META_SPAWN_EGG_BOAT = 41, - E_META_SPAWN_EGG_MINECART = 42, - E_META_SPAWN_EGG_MINECART_CHEST = 43, - E_META_SPAWN_EGG_MINECART_FURNACE = 44, - E_META_SPAWN_EGG_MINECART_TNT = 45, - E_META_SPAWN_EGG_MINECART_HOPPER = 46, - E_META_SPAWN_EGG_MINECART_SPAWNER = 47, - E_META_SPAWN_EGG_CREEPER = 50, - E_META_SPAWN_EGG_SKELETON = 51, - E_META_SPAWN_EGG_SPIDER = 52, - E_META_SPAWN_EGG_GIANT = 53, - E_META_SPAWN_EGG_ZOMBIE = 54, - E_META_SPAWN_EGG_SLIME = 55, - E_META_SPAWN_EGG_GHAST = 56, - E_META_SPAWN_EGG_ZOMBIE_PIGMAN = 57, - E_META_SPAWN_EGG_ENDERMAN = 58, - E_META_SPAWN_EGG_CAVE_SPIDER = 59, - E_META_SPAWN_EGG_SILVERFISH = 60, - E_META_SPAWN_EGG_BLAZE = 61, - E_META_SPAWN_EGG_MAGMA_CUBE = 62, - E_META_SPAWN_EGG_ENDER_DRAGON = 63, - E_META_SPAWN_EGG_WITHER = 64, - E_META_SPAWN_EGG_BAT = 65, - E_META_SPAWN_EGG_WITCH = 66, - E_META_SPAWN_EGG_GUARDIAN = 68, - E_META_SPAWN_EGG_PIG = 90, - E_META_SPAWN_EGG_SHEEP = 91, - E_META_SPAWN_EGG_COW = 92, - E_META_SPAWN_EGG_CHICKEN = 93, - E_META_SPAWN_EGG_SQUID = 94, - E_META_SPAWN_EGG_WOLF = 95, - E_META_SPAWN_EGG_MOOSHROOM = 96, - E_META_SPAWN_EGG_SNOW_GOLEM = 97, - E_META_SPAWN_EGG_OCELOT = 98, - E_META_SPAWN_EGG_IRON_GOLEM = 99, - E_META_SPAWN_EGG_HORSE = 100, - E_META_SPAWN_EGG_RABBIT = 101, - E_META_SPAWN_EGG_VILLAGER = 120, - E_META_SPAWN_EGG_ENDER_CRYSTAL = 200, -} ; - - - - - -/** Dimension of a world */ -enum eDimension -{ - dimNether = -1, - dimOverworld = 0, - dimEnd = 1, - dimNotSet = 255, // For things that need an "indeterminate" state, such as cProtocol's LastSentDimension -} ; - - - - - -/** Damage type, used in the TakeDamageInfo structure and related functions */ -enum eDamageType -{ - // Canonical names for the types (as documented in the plugin wiki): - dtAttack, // Being attacked by a mob - dtRangedAttack, // Being attacked by a projectile, possibly from a mob - dtLightning, // Hit by a lightning strike - dtFalling, // Falling down; dealt when hitting the ground - dtDrowning, // Drowning in water / lava - dtSuffocating, // Suffocating inside a block - dtStarving, // Hunger - dtCactusContact, // Contact with a cactus block - dtLavaContact, // Contact with a lava block - dtPoisoning, // Having the poison effect - dtWithering, // Having the wither effect - dtOnFire, // Being on fire - dtFireContact, // Standing inside a fire block - dtInVoid, // Falling into the Void (Y < 0) - dtPotionOfHarming, - dtEnderPearl, // Thrown an ender pearl, teleported by it - dtAdmin, // Damage applied by an admin command - dtExplosion, // Damage applied by an explosion - - // Some common synonyms: - dtPawnAttack = dtAttack, - dtEntityAttack = dtAttack, - dtMob = dtAttack, - dtMobAttack = dtAttack, - dtArrowAttack = dtRangedAttack, - dtArrow = dtRangedAttack, - dtProjectile = dtRangedAttack, - dtFall = dtFalling, - dtDrown = dtDrowning, - dtSuffocation = dtSuffocating, - dtStarvation = dtStarving, - dtHunger = dtStarving, - dtCactus = dtCactusContact, - dtCactuses = dtCactusContact, - dtCacti = dtCactusContact, - dtLava = dtLavaContact, - dtPoison = dtPoisoning, - dtWither = dtWithering, - dtBurning = dtOnFire, - dtInFire = dtFireContact, - dtPlugin = dtAdmin, -} ; - - - - - -/** The source of an explosion. -Also dictates the type of the additional data passed to the explosion handlers: -| esBed | Vector3i * | Bed exploding in the Nether or in the End -| esEnderCrystal | cEnderCrystal * | -| esGhastFireball | cGhastFireballEntity * | -| esMonster | cMonster * | -| esOther | nullptr | Any other explosion unaccounted for -| esPlugin | nullptr | Explosion primarily attributed to a plugin -| esPrimedTNT | cTNTEntity * | -| esWitherBirth | cMonster * | -| esWitherSkull | cProjectileEntity * | -*/ -enum eExplosionSource -{ - esBed, - esEnderCrystal, - esGhastFireball, - esMonster, - esOther, - esPlugin, - esPrimedTNT, - esWitherBirth, - esWitherSkull, - esMax, -} ; - - - - - -enum eShrapnelLevel -{ - slNone, - slGravityAffectedOnly, - slAll -} ; - - - - - -enum eSpreadSource -{ - ssFireSpread, - ssGrassSpread, - ssMushroomSpread, - ssMycelSpread, - ssVineSpread, -} ; - -// tolua_end - - - - -// fwd: -class cItem; -class cIniFile; - - - - - -// tolua_begin - -/** Translates a blocktype string into blocktype. Takes either a number or an items.ini alias as input. Returns -1 on failure. */ -extern int BlockStringToType(const AString & a_BlockTypeString); - -/** Translates an itemtype string into an item. Takes either a number, number^number, number:number or an items.ini alias as input. Returns true if successful. */ -extern bool StringToItem(const AString & a_ItemTypeString, cItem & a_Item); - -/** Translates a full item into a string. If the ItemType is not recognized, the ItemType number is output into the string. */ -extern AString ItemToString(const cItem & a_Item); - -/** Translates itemtype into a string. If the type is not recognized, the itemtype number is output into the string. */ -extern AString ItemTypeToString(short a_ItemType); - -/** Translates a full item into a fully-specified string (including meta and count). If the ItemType is not recognized, the ItemType number is output into the string. */ -extern AString ItemToFullString(const cItem & a_Item); - -/** Translates a dimension string to dimension enum. Takes either a number or a dimension alias (built-in). Returns dimOverworld on failure */ -extern eDimension StringToDimension(const AString & a_DimensionString); - -/** Translates a dimension enum to dimension string. -Takes an eDimension enum value and returns "Overworld" on failure. */ -extern AString DimensionToString(eDimension a_Dimension); - -/** Translates damage type constant to a string representation (built-in). */ -extern AString DamageTypeToString(eDamageType a_DamageType); - -/** Translates a damage type string to damage type. Takes either a number or a damage type alias (built-in). Returns -1 on failure */ -extern eDamageType StringToDamageType(const AString & a_DamageString); - -/** Returns a cItem representing the item described in an IniFile's value; if the value doesn't exist, creates it with the provided default. */ -extern cItem GetIniItemSet(cIniFile & a_IniFile, const char * a_Section, const char * a_Key, const char * a_Default); - -// tolua_end - - - - - -/** Base case for IsOneOf to handle empty template aguments. */ -template -bool IsOneOf(BLOCKTYPE a_BlockType) -{ - return false; -} - - -/** Returns true if a_BlockType is equal to any of the variadic template arguments. -Some example usage: -\code - IsOneOf<>(E_BLOCK_AIR) == false - IsOneOf(E_BLOCK_DIRT) == false - IsOneOf(E_BLOCK_DIRT) == true -\endcode -The implementation is ugly but it is equivalent to this C++17 fold expression: -\code - ((a_BlockType == Types) || ...) -\endcode -Just written to be valid without fold expressions or SFINAE. */ -template -bool IsOneOf(BLOCKTYPE a_BlockType) -{ - return ((a_BlockType == Head) || (IsOneOf(a_BlockType))); -} - - - diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 7d2ae64a9..86dd2bae6 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -1,10 +1,441 @@ - #include "Globals.h" +#include "BlockInfo.h" +#include "BlockType.h" #include "Blocks/BlockHandler.h" + + +bool IsBlockWater(BLOCKTYPE a_BlockType) +{ + return ((a_BlockType == E_BLOCK_WATER) || (a_BlockType == E_BLOCK_STATIONARY_WATER)); +} + + + + + +bool IsBlockIce(BLOCKTYPE a_BlockType) +{ + switch (a_BlockType) + { + case E_BLOCK_ICE: + case E_BLOCK_PACKED_ICE: + case E_BLOCK_FROSTED_ICE: + { + return true; + } + default: + { + return false; + } + } +} + + + + + +bool IsBlockWaterOrIce(BLOCKTYPE a_BlockType) +{ + return (IsBlockWater(a_BlockType) || IsBlockIce(a_BlockType)); +} + + + + + +bool IsBlockLava(BLOCKTYPE a_BlockType) +{ + return ((a_BlockType == E_BLOCK_LAVA) || (a_BlockType == E_BLOCK_STATIONARY_LAVA)); +} + + + + + +bool IsBlockLiquid(BLOCKTYPE a_BlockType) +{ + return IsBlockWater(a_BlockType) || IsBlockLava(a_BlockType); +} + + + + + +bool IsBlockRail(BLOCKTYPE a_BlockType) +{ + switch (a_BlockType) + { + case E_BLOCK_RAIL: + case E_BLOCK_ACTIVATOR_RAIL: + case E_BLOCK_DETECTOR_RAIL: + case E_BLOCK_POWERED_RAIL: + { + return true; + } + default: return false; + } +} + + + + + +bool IsBlockTypeOfDirt(BLOCKTYPE a_BlockType) +{ + switch (a_BlockType) + { + case E_BLOCK_DIRT: + case E_BLOCK_GRASS: + case E_BLOCK_FARMLAND: + case E_BLOCK_GRASS_PATH: + { + return true; + } + } + return false; +} + + + + + +bool IsBlockFence(BLOCKTYPE a_BlockType) +{ + switch (a_BlockType) + { + case E_BLOCK_ACACIA_FENCE: + case E_BLOCK_ACACIA_FENCE_GATE: + case E_BLOCK_BIRCH_FENCE: + case E_BLOCK_BIRCH_FENCE_GATE: + case E_BLOCK_COBBLESTONE_WALL: + case E_BLOCK_DARK_OAK_FENCE: + case E_BLOCK_DARK_OAK_FENCE_GATE: + case E_BLOCK_FENCE: + case E_BLOCK_JUNGLE_FENCE: + case E_BLOCK_JUNGLE_FENCE_GATE: + case E_BLOCK_NETHER_BRICK_FENCE: + case E_BLOCK_OAK_FENCE_GATE: + case E_BLOCK_SPRUCE_FENCE: + case E_BLOCK_SPRUCE_FENCE_GATE: + { + return true; + } + default: + { + return false; + } + } +} + + + + + +bool IsBlockMaterialWood(BLOCKTYPE a_BlockType) +{ + switch (a_BlockType) + { + case E_BLOCK_PLANKS: + case E_BLOCK_LOG: + case E_BLOCK_NOTE_BLOCK: + case E_BLOCK_BOOKCASE: + case E_BLOCK_OAK_WOOD_STAIRS: + case E_BLOCK_CHEST: + case E_BLOCK_CRAFTING_TABLE: + case E_BLOCK_SIGN_POST: + case E_BLOCK_OAK_DOOR: + case E_BLOCK_WALLSIGN: + case E_BLOCK_WOODEN_PRESSURE_PLATE: + case E_BLOCK_JUKEBOX: + case E_BLOCK_FENCE: + case E_BLOCK_TRAPDOOR: + case E_BLOCK_HUGE_BROWN_MUSHROOM: + case E_BLOCK_HUGE_RED_MUSHROOM: + case E_BLOCK_OAK_FENCE_GATE: + case E_BLOCK_DOUBLE_WOODEN_SLAB: + case E_BLOCK_WOODEN_SLAB: + case E_BLOCK_SPRUCE_WOOD_STAIRS: + case E_BLOCK_BIRCH_WOOD_STAIRS: + case E_BLOCK_JUNGLE_WOOD_STAIRS: + case E_BLOCK_TRAPPED_CHEST: + case E_BLOCK_DAYLIGHT_SENSOR: + case E_BLOCK_NEW_LOG: + case E_BLOCK_ACACIA_WOOD_STAIRS: + case E_BLOCK_DARK_OAK_WOOD_STAIRS: + case E_BLOCK_STANDING_BANNER: + case E_BLOCK_WALL_BANNER: + case E_BLOCK_INVERTED_DAYLIGHT_SENSOR: + case E_BLOCK_SPRUCE_FENCE_GATE: + case E_BLOCK_BIRCH_FENCE_GATE: + case E_BLOCK_JUNGLE_FENCE_GATE: + case E_BLOCK_DARK_OAK_FENCE_GATE: + case E_BLOCK_ACACIA_FENCE_GATE: + case E_BLOCK_SPRUCE_FENCE: + case E_BLOCK_BIRCH_FENCE: + case E_BLOCK_JUNGLE_FENCE: + case E_BLOCK_DARK_OAK_FENCE: + case E_BLOCK_ACACIA_FENCE: + case E_BLOCK_SPRUCE_DOOR: + case E_BLOCK_BIRCH_DOOR: + case E_BLOCK_JUNGLE_DOOR: + case E_BLOCK_ACACIA_DOOR: + case E_BLOCK_DARK_OAK_DOOR: + { + return true; + } + default: + { + return false; + } + } +} + + + + + +bool IsBlockMaterialPlants(BLOCKTYPE a_BlockType) +{ + switch (a_BlockType) + { + case E_BLOCK_SAPLING: + case E_BLOCK_DANDELION: + case E_BLOCK_FLOWER: + case E_BLOCK_BROWN_MUSHROOM: + case E_BLOCK_RED_MUSHROOM: + case E_BLOCK_CROPS: + case E_BLOCK_REEDS: + case E_BLOCK_PUMPKIN_STEM: + case E_BLOCK_MELON_STEM: + case E_BLOCK_LILY_PAD: + case E_BLOCK_NETHER_WART: + case E_BLOCK_COCOA_POD: + case E_BLOCK_CARROTS: + case E_BLOCK_POTATOES: + case E_BLOCK_CHORUS_PLANT: + case E_BLOCK_CHORUS_FLOWER: + case E_BLOCK_BEETROOTS: + { + return true; + } + default: + { + return false; + } + } +} + + + + + +bool IsBlockMaterialVine(BLOCKTYPE a_BlockType) +{ + switch (a_BlockType) + { + case E_BLOCK_TALL_GRASS: + case E_BLOCK_DEAD_BUSH: + case E_BLOCK_VINES: + case E_BLOCK_BIG_FLOWER: + { + return true; + } + default: + { + return false; + } + } +} + + + + + +bool IsBlockMaterialIron(BLOCKTYPE a_BlockType) +{ + switch (a_BlockType) + { + case E_BLOCK_LAPIS_BLOCK: + case E_BLOCK_GOLD_BLOCK: + case E_BLOCK_IRON_BLOCK: + case E_BLOCK_DIAMOND_BLOCK: + case E_BLOCK_IRON_DOOR: + case E_BLOCK_IRON_BARS: + case E_BLOCK_BREWING_STAND: + case E_BLOCK_CAULDRON: + case E_BLOCK_EMERALD_BLOCK: + case E_BLOCK_COMMAND_BLOCK: + case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: + case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: + case E_BLOCK_BLOCK_OF_REDSTONE: + case E_BLOCK_HOPPER: + case E_BLOCK_IRON_TRAPDOOR: + case E_BLOCK_REPEATING_COMMAND_BLOCK: + case E_BLOCK_CHAIN_COMMAND_BLOCK: + case E_BLOCK_STRUCTURE_BLOCK: + { + return true; + } + default: + { + return false; + } + } +} + + + + + +bool IsBlockMaterialLeaves(BLOCKTYPE a_BlockType) +{ + return (a_BlockType == E_BLOCK_LEAVES) || (a_BlockType == E_BLOCK_NEW_LEAVES); +} + + + + + +bool IsBlockMaterialGourd(BLOCKTYPE a_BlockType) +{ + switch (a_BlockType) + { + case E_BLOCK_PUMPKIN: + case E_BLOCK_JACK_O_LANTERN: + case E_BLOCK_MELON: + { + return true; + } + default: + { + return false; + } + } +} + + + + + +bool IsBlockMaterialRock(BLOCKTYPE a_BlockType) +{ + switch (a_BlockType) + { + case E_BLOCK_STONE: + case E_BLOCK_COBBLESTONE: + case E_BLOCK_BEDROCK: + case E_BLOCK_GOLD_ORE: + case E_BLOCK_IRON_ORE: + case E_BLOCK_COAL_ORE: + case E_BLOCK_LAPIS_ORE: + case E_BLOCK_DISPENSER: + case E_BLOCK_SANDSTONE: + case E_BLOCK_DOUBLE_STONE_SLAB: + case E_BLOCK_STONE_SLAB: + case E_BLOCK_BRICK: + case E_BLOCK_MOSSY_COBBLESTONE: + case E_BLOCK_OBSIDIAN: + case E_BLOCK_MOB_SPAWNER: + case E_BLOCK_DIAMOND_ORE: + case E_BLOCK_FURNACE: + case E_BLOCK_LIT_FURNACE: + case E_BLOCK_COBBLESTONE_STAIRS: + case E_BLOCK_STONE_PRESSURE_PLATE: + case E_BLOCK_REDSTONE_ORE: + case E_BLOCK_REDSTONE_ORE_GLOWING: + case E_BLOCK_NETHERRACK: + case E_BLOCK_STONE_BRICKS: + case E_BLOCK_BRICK_STAIRS: + case E_BLOCK_STONE_BRICK_STAIRS: + case E_BLOCK_NETHER_BRICK: + case E_BLOCK_NETHER_BRICK_FENCE: + case E_BLOCK_NETHER_BRICK_STAIRS: + case E_BLOCK_ENCHANTMENT_TABLE: + case E_BLOCK_END_PORTAL_FRAME: + case E_BLOCK_END_STONE: + case E_BLOCK_SANDSTONE_STAIRS: + case E_BLOCK_EMERALD_ORE: + case E_BLOCK_ENDER_CHEST: + case E_BLOCK_COBBLESTONE_WALL: + case E_BLOCK_NETHER_QUARTZ_ORE: + case E_BLOCK_QUARTZ_BLOCK: + case E_BLOCK_QUARTZ_STAIRS: + case E_BLOCK_DROPPER: + case E_BLOCK_STAINED_CLAY: + case E_BLOCK_PRISMARINE_BLOCK: + case E_BLOCK_HARDENED_CLAY: + case E_BLOCK_BLOCK_OF_COAL: + case E_BLOCK_RED_SANDSTONE: + case E_BLOCK_RED_SANDSTONE_STAIRS: + case E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB: + case E_BLOCK_RED_SANDSTONE_SLAB: + case E_BLOCK_PURPUR_BLOCK: + case E_BLOCK_PURPUR_PILLAR: + case E_BLOCK_PURPUR_STAIRS: + case E_BLOCK_PURPUR_DOUBLE_SLAB: + case E_BLOCK_PURPUR_SLAB: + case E_BLOCK_END_BRICKS: + case E_BLOCK_MAGMA: + case E_BLOCK_RED_NETHER_BRICK: + case E_BLOCK_BONE_BLOCK: + case E_BLOCK_OBSERVER: + { + return true; + } + default: + { + return false; + } + } +} + + + + + +//////////////////////////////////////////////////////////////////////////////// +// cBlockInfo: + +cBlockInfo::cBlockInfo(): + m_BlockType(E_BLOCK_STONE), + m_LightValue(0x00), + m_SpreadLightFalloff(0x0f), + m_Transparent(false), + m_OneHitDig(false), + m_PistonBreakable(false), + m_IsRainBlocker(false), + m_IsSkylightDispersant(false), + m_IsSolid(true), + m_UseableBySpectator(false), + m_FullyOccupiesVoxel(false), + m_CanBeTerraformed(false), + m_BlockHeight(1.0), + m_Hardness(0.0f), + m_Handler() +{ +} + + + + + +bool cBlockInfo::IsSnowable(BLOCKTYPE a_BlockType) +{ + return ( + (a_BlockType == E_BLOCK_ICE) || + (a_BlockType == E_BLOCK_LEAVES) || + (!IsTransparent(a_BlockType) && (a_BlockType != E_BLOCK_PACKED_ICE)) + ); +} + + + + + void cBlockInfo::sHandlerDeleter::operator () (cBlockHandler * a_Handler) { delete a_Handler; diff --git a/src/BlockInfo.h b/src/BlockInfo.h index 9ba89858f..9644eb208 100644 --- a/src/BlockInfo.h +++ b/src/BlockInfo.h @@ -37,14 +37,7 @@ public: { return ((Get(a_Type).m_IsSkylightDispersant) || (Get(a_Type).m_SpreadLightFalloff > 1)); } - inline static bool IsSnowable (BLOCKTYPE a_Type) - { - return ( - (a_Type == E_BLOCK_ICE) || - (a_Type == E_BLOCK_LEAVES) || - (!IsTransparent(a_Type) && (a_Type != E_BLOCK_PACKED_ICE)) - ); - } + static bool IsSnowable(BLOCKTYPE a_Type); inline static bool IsSolid (BLOCKTYPE a_Type) { return Get(a_Type).m_IsSolid; } inline static bool IsUseableBySpectator (BLOCKTYPE a_Type) { return Get(a_Type).m_UseableBySpectator; } inline static bool FullyOccupiesVoxel (BLOCKTYPE a_Type) { return Get(a_Type).m_FullyOccupiesVoxel; } @@ -57,24 +50,8 @@ public: inline static cBlockHandler * GetHandler (BLOCKTYPE a_Type) { return Get(a_Type).m_Handler.get(); } /** Creates a default BlockInfo structure, initializes all values to their defaults */ - cBlockInfo(): - m_BlockType(E_BLOCK_STONE), - m_LightValue(0x00), - m_SpreadLightFalloff(0x0f), - m_Transparent(false), - m_OneHitDig(false), - m_PistonBreakable(false), - m_IsRainBlocker(false), - m_IsSkylightDispersant(false), - m_IsSolid(true), - m_UseableBySpectator(false), - m_FullyOccupiesVoxel(false), - m_CanBeTerraformed(false), - m_BlockHeight(1.0), - m_Hardness(0.0f), - m_Handler() - { - } + cBlockInfo(); + private: /** Storage for all the BlockInfo structures. */ @@ -133,6 +110,40 @@ private: +bool IsBlockWater(BLOCKTYPE a_BlockType); + +bool IsBlockIce(BLOCKTYPE a_BlockType); + +bool IsBlockWaterOrIce(BLOCKTYPE a_BlockType); + +bool IsBlockLava(BLOCKTYPE a_BlockType); + +bool IsBlockLiquid(BLOCKTYPE a_BlockType); + +bool IsBlockRail(BLOCKTYPE a_BlockType); + +bool IsBlockTypeOfDirt(BLOCKTYPE a_BlockType); + +bool IsBlockFence(BLOCKTYPE a_BlockType); + +bool IsBlockMaterialWood(BLOCKTYPE a_BlockType); + +bool IsBlockMaterialPlants(BLOCKTYPE a_BlockType); + +bool IsBlockMaterialVine(BLOCKTYPE a_BlockType); + +bool IsBlockMaterialIron(BLOCKTYPE a_BlockType); + +bool IsBlockMaterialLeaves(BLOCKTYPE a_BlockType); + +bool IsBlockMaterialGourd(BLOCKTYPE a_BlockType); + +bool IsBlockMaterialRock(BLOCKTYPE a_BlockType); + + + + + class cBlockInfo::cBlockInfoArray: public std::array { diff --git a/src/BlockType.cpp b/src/BlockType.cpp new file mode 100644 index 000000000..cecfb752b --- /dev/null +++ b/src/BlockType.cpp @@ -0,0 +1,309 @@ +// BlockType.cpp + +// Implements the helper functions for converting Block Type string to int etc. + +#include "Globals.h" +#include "IniFile.h" +#include "Item.h" +#include "Mobs/Monster.h" + + + + + +class cBlockIDMap +{ + // Making the map case-insensitive: + struct Comparator + { + bool operator ()(const AString & a_Item1, const AString & a_Item2) const + { + return (NoCaseCompare(a_Item1, a_Item2) > 0); + } + } ; + + typedef std::map, Comparator> ItemMap; + +public: + static bool m_bHasRunInit; + + cBlockIDMap(void) + { + // Dont load items.ini on construct, this will search the wrong path when running as a service. + } + + + void init() + { + m_bHasRunInit = true; + + cIniFile Ini; + if (!Ini.ReadFile("items.ini")) + { + return; + } + int KeyID = Ini.FindKey("Items"); + if (KeyID == cIniFile::noID) + { + return; + } + int NumValues = Ini.GetNumValues(KeyID); + for (int i = 0; i < NumValues; i++) + { + AString Name = Ini.GetValueName(KeyID, i); + if (Name.empty()) + { + continue; + } + AString Value = Ini.GetValue(KeyID, i); + AddToMap(Name, Value); + } // for i - Ini.Values[] + } + + + int Resolve(const AString & a_ItemName) + { + ItemMap::iterator itr = m_Map.find(a_ItemName); + if (itr == m_Map.end()) + { + return -1; + } + return itr->second.first; + } + + + bool ResolveItem(const AString & a_ItemName, cItem & a_Item) + { + // Split into parts divided by either ':' or '^' + AStringVector Split = StringSplitAndTrim(a_ItemName, ":^"); + if (Split.empty()) + { + return false; + } + + ItemMap::iterator itr = m_Map.find(Split[0]); + if (itr != m_Map.end()) + { + // Resolved as a string, assign the type and the default damage / count + a_Item.m_ItemType = itr->second.first; + a_Item.m_ItemDamage = itr->second.second; + if (a_Item.m_ItemDamage == -1) + { + a_Item.m_ItemDamage = 0; + } + } + else + { + // Not a resolvable string, try pure numbers: "45:6", "45^6" etc. + if (!StringToInteger(Split[0], a_Item.m_ItemType)) + { + // Parsing the number failed + return false; + } + } + + // Parse the damage, if present: + if (Split.size() < 2) + { + // Not present, set the item as valid and return success: + a_Item.m_ItemCount = 1; + return true; + } + + if (!StringToInteger(Split[1], a_Item.m_ItemDamage)) + { + // Parsing the number failed + return false; + } + a_Item.m_ItemCount = 1; + return true; + } + + + AString Desolve(short a_ItemType, short a_ItemDamage) + { + // First try an exact match, both ItemType and ItemDamage ("birchplanks=5:2"): + for (ItemMap::iterator itr = m_Map.begin(), end = m_Map.end(); itr != end; ++itr) + { + if ((itr->second.first == a_ItemType) && (itr->second.second == a_ItemDamage)) + { + return itr->first; + } + } // for itr - m_Map[] + + // There is no exact match, try matching ItemType only ("planks=5"): + if (a_ItemDamage == 0) + { + for (ItemMap::iterator itr = m_Map.begin(), end = m_Map.end(); itr != end; ++itr) + { + if ((itr->second.first == a_ItemType) && (itr->second.second == -1)) + { + return itr->first; + } + } // for itr - m_Map[] + } + + // No match at all, synthesize a string ("5:1"): + AString res; + if (a_ItemDamage == -1) + { + Printf(res, "%d", a_ItemType); + } + else + { + Printf(res, "%d:%d", a_ItemType, a_ItemDamage); + } + return res; + } + + +protected: + ItemMap m_Map; + + + void AddToMap(const AString & a_Name, const AString & a_Value) + { + AStringVector Split = StringSplit(a_Value, ":"); + if (Split.size() == 1) + { + Split = StringSplit(a_Value, "^"); + } + if (Split.empty()) + { + return; + } + short ItemType; + if (!StringToInteger(Split[0], ItemType)) + { + ASSERT(!"Invalid item type"); + } + short ItemDamage = -1; + if (Split.size() > 1 && !StringToInteger(Split[1], ItemDamage)) + { + ASSERT(!"Invalid item damage"); + } + m_Map[a_Name] = std::make_pair(ItemType, ItemDamage); + } +} ; + + + + +bool cBlockIDMap::m_bHasRunInit = false; +static cBlockIDMap gsBlockIDMap; + + + + + +/* +// Quick self-test: +class Tester +{ +public: + Tester(void) + { + cItem Item; + gsBlockIDMap.ResolveItem("charcoal", Item); + AString Charcoal = gsBlockIDMap.Desolve(Item.m_ItemType, Item.m_ItemDamage); + ASSERT(Charcoal == "charcoal"); + } +} test; +//*/ + + + + + +int BlockStringToType(const AString & a_BlockTypeString) +{ + int res = atoi(a_BlockTypeString.c_str()); + if ((res != 0) || (a_BlockTypeString.compare("0") == 0)) + { + // It was a valid number, return that + return res; + } + + if (!gsBlockIDMap.m_bHasRunInit) + { + gsBlockIDMap.init(); + } + return gsBlockIDMap.Resolve(TrimString(a_BlockTypeString)); +} + + + + + +bool StringToItem(const AString & a_ItemTypeString, cItem & a_Item) +{ + AString ItemName = TrimString(a_ItemTypeString); + if (ItemName.substr(0, 10) == "minecraft:") + { + ItemName = ItemName.substr(10); + } + + if (!gsBlockIDMap.m_bHasRunInit) + { + gsBlockIDMap.init(); + } + return gsBlockIDMap.ResolveItem(ItemName, a_Item); +} + + + + + +AString ItemToString(const cItem & a_Item) +{ + if (!gsBlockIDMap.m_bHasRunInit) + { + gsBlockIDMap.init(); + } + return gsBlockIDMap.Desolve(a_Item.m_ItemType, a_Item.m_ItemDamage); +} + + + + + +AString ItemTypeToString(short a_ItemType) +{ + if (!gsBlockIDMap.m_bHasRunInit) + { + gsBlockIDMap.init(); + } + return gsBlockIDMap.Desolve(a_ItemType, -1); +} + + + + + +AString ItemToFullString(const cItem & a_Item) +{ + AString res; + Printf(res, "%s:%d * %d", ItemToString(a_Item).c_str(), a_Item.m_ItemDamage, a_Item.m_ItemCount); + return res; +} + + + + + +cItem GetIniItemSet(cIniFile & a_IniFile, const char * a_Section, const char * a_Key, const char * a_Default) +{ + AString ItemStr = a_IniFile.GetValueSet(a_Section, a_Key, a_Default); + cItem res; + if (!StringToItem(ItemStr, res)) + { + res.Empty(); + } + return res; +} + + + + + + diff --git a/src/BlockType.h b/src/BlockType.h new file mode 100644 index 000000000..bd4b0c625 --- /dev/null +++ b/src/BlockType.h @@ -0,0 +1,1188 @@ +#pragma once + + +// tolua_begin + + +enum ENUM_BLOCK_TYPE : BLOCKTYPE +{ + E_BLOCK_AIR = 0, + E_BLOCK_STONE = 1, + E_BLOCK_GRASS = 2, + E_BLOCK_DIRT = 3, + E_BLOCK_COBBLESTONE = 4, + E_BLOCK_PLANKS = 5, + E_BLOCK_SAPLING = 6, + E_BLOCK_BEDROCK = 7, + E_BLOCK_WATER = 8, + E_BLOCK_STATIONARY_WATER = 9, + E_BLOCK_LAVA = 10, + E_BLOCK_STATIONARY_LAVA = 11, + E_BLOCK_SAND = 12, + E_BLOCK_GRAVEL = 13, + E_BLOCK_GOLD_ORE = 14, + E_BLOCK_IRON_ORE = 15, + E_BLOCK_COAL_ORE = 16, + E_BLOCK_LOG = 17, + E_BLOCK_LEAVES = 18, + E_BLOCK_SPONGE = 19, + E_BLOCK_GLASS = 20, + E_BLOCK_LAPIS_ORE = 21, + E_BLOCK_LAPIS_BLOCK = 22, + E_BLOCK_DISPENSER = 23, + E_BLOCK_SANDSTONE = 24, + E_BLOCK_NOTE_BLOCK = 25, + E_BLOCK_BED = 26, + E_BLOCK_POWERED_RAIL = 27, + E_BLOCK_DETECTOR_RAIL = 28, + E_BLOCK_STICKY_PISTON = 29, + E_BLOCK_COBWEB = 30, + E_BLOCK_TALL_GRASS = 31, + E_BLOCK_DEAD_BUSH = 32, + E_BLOCK_PISTON = 33, + E_BLOCK_PISTON_EXTENSION = 34, + E_BLOCK_WOOL = 35, + E_BLOCK_PISTON_MOVED_BLOCK = 36, + E_BLOCK_DANDELION = 37, + E_BLOCK_FLOWER = 38, + E_BLOCK_BROWN_MUSHROOM = 39, + E_BLOCK_RED_MUSHROOM = 40, + E_BLOCK_GOLD_BLOCK = 41, + E_BLOCK_IRON_BLOCK = 42, + E_BLOCK_DOUBLE_STONE_SLAB = 43, + E_BLOCK_STONE_SLAB = 44, + E_BLOCK_BRICK = 45, + E_BLOCK_TNT = 46, + E_BLOCK_BOOKCASE = 47, + E_BLOCK_MOSSY_COBBLESTONE = 48, + E_BLOCK_OBSIDIAN = 49, + E_BLOCK_TORCH = 50, + E_BLOCK_FIRE = 51, + E_BLOCK_MOB_SPAWNER = 52, + E_BLOCK_OAK_WOOD_STAIRS = 53, + E_BLOCK_CHEST = 54, + E_BLOCK_REDSTONE_WIRE = 55, + E_BLOCK_DIAMOND_ORE = 56, + E_BLOCK_DIAMOND_BLOCK = 57, + E_BLOCK_CRAFTING_TABLE = 58, + E_BLOCK_WORKBENCH = 58, + E_BLOCK_WHEAT = 59, + E_BLOCK_CROPS = E_BLOCK_WHEAT, + E_BLOCK_FARMLAND = 60, + E_BLOCK_FURNACE = 61, + E_BLOCK_LIT_FURNACE = 62, + E_BLOCK_BURNING_FURNACE = 62, + E_BLOCK_SIGN_POST = 63, + E_BLOCK_OAK_DOOR = 64, + E_BLOCK_LADDER = 65, + E_BLOCK_RAIL = 66, + E_BLOCK_MINECART_TRACKS = 66, + E_BLOCK_COBBLESTONE_STAIRS = 67, + E_BLOCK_WALLSIGN = 68, + E_BLOCK_LEVER = 69, + E_BLOCK_STONE_PRESSURE_PLATE = 70, + E_BLOCK_IRON_DOOR = 71, + E_BLOCK_WOODEN_PRESSURE_PLATE = 72, + E_BLOCK_REDSTONE_ORE = 73, + E_BLOCK_REDSTONE_ORE_GLOWING = 74, + E_BLOCK_REDSTONE_TORCH_OFF = 75, + E_BLOCK_REDSTONE_TORCH_ON = 76, + E_BLOCK_STONE_BUTTON = 77, + E_BLOCK_SNOW = 78, + E_BLOCK_ICE = 79, + E_BLOCK_SNOW_BLOCK = 80, + E_BLOCK_CACTUS = 81, + E_BLOCK_CLAY = 82, + E_BLOCK_SUGARCANE = 83, + E_BLOCK_REEDS = 83, + E_BLOCK_JUKEBOX = 84, + E_BLOCK_FENCE = 85, + E_BLOCK_PUMPKIN = 86, + E_BLOCK_NETHERRACK = 87, + E_BLOCK_SOULSAND = 88, + E_BLOCK_GLOWSTONE = 89, + E_BLOCK_NETHER_PORTAL = 90, + E_BLOCK_JACK_O_LANTERN = 91, + E_BLOCK_CAKE = 92, + E_BLOCK_REDSTONE_REPEATER_OFF = 93, + E_BLOCK_REDSTONE_REPEATER_ON = 94, + E_BLOCK_STAINED_GLASS = 95, + E_BLOCK_TRAPDOOR = 96, + E_BLOCK_SILVERFISH_EGG = 97, + E_BLOCK_STONE_BRICKS = 98, + E_BLOCK_HUGE_BROWN_MUSHROOM = 99, + E_BLOCK_HUGE_RED_MUSHROOM = 100, + E_BLOCK_IRON_BARS = 101, + E_BLOCK_GLASS_PANE = 102, + E_BLOCK_MELON = 103, + E_BLOCK_PUMPKIN_STEM = 104, + E_BLOCK_MELON_STEM = 105, + E_BLOCK_VINES = 106, + E_BLOCK_OAK_FENCE_GATE = 107, + E_BLOCK_BRICK_STAIRS = 108, + E_BLOCK_STONE_BRICK_STAIRS = 109, + E_BLOCK_MYCELIUM = 110, + E_BLOCK_LILY_PAD = 111, + E_BLOCK_NETHER_BRICK = 112, + E_BLOCK_NETHER_BRICK_FENCE = 113, + E_BLOCK_NETHER_BRICK_STAIRS = 114, + E_BLOCK_NETHER_WART = 115, + E_BLOCK_ENCHANTMENT_TABLE = 116, + E_BLOCK_BREWING_STAND = 117, + E_BLOCK_CAULDRON = 118, + E_BLOCK_END_PORTAL = 119, + E_BLOCK_END_PORTAL_FRAME = 120, + E_BLOCK_END_STONE = 121, + E_BLOCK_DRAGON_EGG = 122, + E_BLOCK_REDSTONE_LAMP_OFF = 123, + E_BLOCK_REDSTONE_LAMP_ON = 124, + E_BLOCK_DOUBLE_WOODEN_SLAB = 125, + E_BLOCK_WOODEN_SLAB = 126, + E_BLOCK_COCOA_POD = 127, + E_BLOCK_SANDSTONE_STAIRS = 128, + E_BLOCK_EMERALD_ORE = 129, + E_BLOCK_ENDER_CHEST = 130, + E_BLOCK_TRIPWIRE_HOOK = 131, + E_BLOCK_TRIPWIRE = 132, + E_BLOCK_EMERALD_BLOCK = 133, + E_BLOCK_SPRUCE_WOOD_STAIRS = 134, + E_BLOCK_BIRCH_WOOD_STAIRS = 135, + E_BLOCK_JUNGLE_WOOD_STAIRS = 136, + E_BLOCK_COMMAND_BLOCK = 137, + E_BLOCK_BEACON = 138, + E_BLOCK_COBBLESTONE_WALL = 139, + E_BLOCK_FLOWER_POT = 140, + E_BLOCK_CARROTS = 141, + E_BLOCK_POTATOES = 142, + E_BLOCK_WOODEN_BUTTON = 143, + E_BLOCK_HEAD = 144, + E_BLOCK_ANVIL = 145, + E_BLOCK_TRAPPED_CHEST = 146, + E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE = 147, + E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE = 148, + + E_BLOCK_INACTIVE_COMPARATOR = 149, + E_BLOCK_ACTIVE_COMPARATOR = 150, + E_BLOCK_DAYLIGHT_SENSOR = 151, + E_BLOCK_BLOCK_OF_REDSTONE = 152, + + E_BLOCK_NETHER_QUARTZ_ORE = 153, + E_BLOCK_HOPPER = 154, + E_BLOCK_QUARTZ_BLOCK = 155, + E_BLOCK_QUARTZ_STAIRS = 156, + E_BLOCK_ACTIVATOR_RAIL = 157, + + E_BLOCK_DROPPER = 158, + E_BLOCK_STAINED_CLAY = 159, // Synonym to terracotta + E_BLOCK_TERRACOTTA = 159, // Synonym to stained clay + E_BLOCK_STAINED_GLASS_PANE = 160, + E_BLOCK_NEW_LEAVES = 161, // Acacia and Dark Oak IDs in Minecraft 1.7.x + E_BLOCK_NEW_LOG = 162, + E_BLOCK_ACACIA_WOOD_STAIRS = 163, + E_BLOCK_DARK_OAK_WOOD_STAIRS = 164, + E_BLOCK_SLIME_BLOCK = 165, + E_BLOCK_BARRIER = 166, + E_BLOCK_IRON_TRAPDOOR = 167, + E_BLOCK_PRISMARINE_BLOCK = 168, + E_BLOCK_SEA_LANTERN = 169, + E_BLOCK_HAY_BALE = 170, + E_BLOCK_CARPET = 171, + E_BLOCK_HARDENED_CLAY = 172, + E_BLOCK_BLOCK_OF_COAL = 173, + E_BLOCK_PACKED_ICE = 174, + E_BLOCK_BIG_FLOWER = 175, + E_BLOCK_STANDING_BANNER = 176, + E_BLOCK_WALL_BANNER = 177, + E_BLOCK_INVERTED_DAYLIGHT_SENSOR = 178, + E_BLOCK_RED_SANDSTONE = 179, + E_BLOCK_RED_SANDSTONE_STAIRS = 180, + E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB = 181, + E_BLOCK_RED_SANDSTONE_SLAB = 182, + E_BLOCK_SPRUCE_FENCE_GATE = 183, + E_BLOCK_BIRCH_FENCE_GATE = 184, + E_BLOCK_JUNGLE_FENCE_GATE = 185, + E_BLOCK_DARK_OAK_FENCE_GATE = 186, + E_BLOCK_ACACIA_FENCE_GATE = 187, + E_BLOCK_SPRUCE_FENCE = 188, + E_BLOCK_BIRCH_FENCE = 189, + E_BLOCK_JUNGLE_FENCE = 190, + E_BLOCK_DARK_OAK_FENCE = 191, + E_BLOCK_ACACIA_FENCE = 192, + E_BLOCK_SPRUCE_DOOR = 193, + E_BLOCK_BIRCH_DOOR = 194, + E_BLOCK_JUNGLE_DOOR = 195, + E_BLOCK_ACACIA_DOOR = 196, + E_BLOCK_DARK_OAK_DOOR = 197, + E_BLOCK_END_ROD = 198, + E_BLOCK_CHORUS_PLANT = 199, + E_BLOCK_CHORUS_FLOWER = 200, + E_BLOCK_PURPUR_BLOCK = 201, + E_BLOCK_PURPUR_PILLAR = 202, + E_BLOCK_PURPUR_STAIRS = 203, + E_BLOCK_PURPUR_DOUBLE_SLAB = 204, + E_BLOCK_PURPUR_SLAB = 205, + E_BLOCK_END_BRICKS = 206, + E_BLOCK_BEETROOTS = 207, + E_BLOCK_GRASS_PATH = 208, + E_BLOCK_END_GATEWAY = 209, + E_BLOCK_REPEATING_COMMAND_BLOCK = 210, + E_BLOCK_CHAIN_COMMAND_BLOCK = 211, + E_BLOCK_FROSTED_ICE = 212, + E_BLOCK_MAGMA = 213, + E_BLOCK_NETHER_WART_BLOCK = 214, + E_BLOCK_RED_NETHER_BRICK = 215, + E_BLOCK_BONE_BLOCK = 216, + E_BLOCK_STRUCTURE_VOID = 217, + E_BLOCK_OBSERVER = 218, + E_BLOCK_WHITE_SHULKER_BOX = 219, + E_BLOCK_ORANGE_SHULKER_BOX = 220, + E_BLOCK_MAGENTA_SHULKER_BOX = 221, + E_BLOCK_LIGHT_BLUE_SHULKER_BOX = 222, + E_BLOCK_YELLOW_SHULKER_BOX = 223, + E_BLOCK_LIME_SHULKER_BOX = 224, + E_BLOCK_PINK_SHULKER_BOX = 225, + E_BLOCK_GRAY_SHULKER_BOX = 226, + E_BLOCK_LIGHT_GRAY_SHULKER_BOX = 227, + E_BLOCK_CYAN_SHULKER_BOX = 228, + E_BLOCK_PURPLE_SHULKER_BOX = 229, + E_BLOCK_BLUE_SHULKER_BOX = 230, + E_BLOCK_BROWN_SHULKER_BOX = 231, + E_BLOCK_GREEN_SHULKER_BOX = 232, + E_BLOCK_RED_SHULKER_BOX = 233, + E_BLOCK_BLACK_SHULKER_BOX = 234, + E_BLOCK_WHITE_GLAZED_TERRACOTTA = 235, + E_BLOCK_ORANGE_GLAZED_TERRACOTTA = 236, + E_BLOCK_MAGENTA_GLAZED_TERRACOTTA = 237, + E_BLOCK_LIGHT_BLUE_GLAZED_TERRACOTTA = 238, + E_BLOCK_YELLOW_GLAZED_TERRACOTTA = 239, + E_BLOCK_LIME_GLAZED_TERRACOTTA = 240, + E_BLOCK_PINK_GLAZED_TERRACOTTA = 241, + E_BLOCK_GRAY_GLAZED_TERRACOTTA = 242, + E_BLOCK_LIGHT_GRAY_GLAZED_TERRACOTTA = 243, + E_BLOCK_CYAN_GLAZED_TERRACOTTA = 244, + E_BLOCK_PURPLE_GLAZED_TERRACOTTA = 245, + E_BLOCK_BLUE_GLAZED_TERRACOTTA = 246, + E_BLOCK_BROWN_GLAZED_TERRACOTTA = 247, + E_BLOCK_GREEN_GLAZED_TERRACOTTA = 248, + E_BLOCK_RED_GLAZED_TERRACOTTA = 249, + E_BLOCK_BLACK_GLAZED_TERRACOTTA = 250, + E_BLOCK_CONCRETE = 251, + E_BLOCK_CONCRETE_POWDER = 252, + // ... + E_BLOCK_STRUCTURE_BLOCK = 255, + + // Keep these two as the last values. Update the last block value to the last block with an id less than 255 when adding another block + // IsValidBlock() depends on this (255 gets checked additionally because there is a gap. See https://minecraft.gamepedia.com/Data_values#Block_IDs + E_BLOCK_NUMBER_OF_TYPES = E_BLOCK_CONCRETE_POWDER + 1, ///< Number of individual (different) blocktypes + E_BLOCK_MAX_TYPE_ID = E_BLOCK_NUMBER_OF_TYPES - 1, ///< Maximum BlockType number used + + E_BLOCK_UNFINISHED = 254, // Special type used as a placeholder, signifying that the block lacks implementation + + // Synonym or ID compatibility + E_BLOCK_YELLOW_FLOWER = E_BLOCK_DANDELION, + E_BLOCK_RED_ROSE = E_BLOCK_FLOWER, + E_BLOCK_WOODEN_DOOR = E_BLOCK_OAK_DOOR, + E_BLOCK_FENCE_GATE = E_BLOCK_OAK_FENCE_GATE, + E_BLOCK_WOODEN_STAIRS = E_BLOCK_OAK_WOOD_STAIRS, +}; + + + + + +enum ENUM_ITEM_TYPE : short +{ + E_ITEM_EMPTY = -1, + + E_ITEM_FIRST = 256, // First true item type + + E_ITEM_IRON_SHOVEL = 256, + E_ITEM_IRON_PICKAXE = 257, + E_ITEM_IRON_AXE = 258, + E_ITEM_FLINT_AND_STEEL = 259, + E_ITEM_RED_APPLE = 260, + E_ITEM_BOW = 261, + E_ITEM_ARROW = 262, + E_ITEM_COAL = 263, + E_ITEM_DIAMOND = 264, + E_ITEM_IRON = 265, + E_ITEM_GOLD = 266, + E_ITEM_IRON_SWORD = 267, + E_ITEM_WOODEN_SWORD = 268, + E_ITEM_WOODEN_SHOVEL = 269, + E_ITEM_WOODEN_PICKAXE = 270, + E_ITEM_WOODEN_AXE = 271, + E_ITEM_STONE_SWORD = 272, + E_ITEM_STONE_SHOVEL = 273, + E_ITEM_STONE_PICKAXE = 274, + E_ITEM_STONE_AXE = 275, + E_ITEM_DIAMOND_SWORD = 276, + E_ITEM_DIAMOND_SHOVEL = 277, + E_ITEM_DIAMOND_PICKAXE = 278, + E_ITEM_DIAMOND_AXE = 279, + E_ITEM_STICK = 280, + E_ITEM_BOWL = 281, + E_ITEM_MUSHROOM_SOUP = 282, + E_ITEM_GOLD_SWORD = 283, + E_ITEM_GOLD_SHOVEL = 284, + E_ITEM_GOLD_PICKAXE = 285, + E_ITEM_GOLD_AXE = 286, + E_ITEM_STRING = 287, + E_ITEM_FEATHER = 288, + E_ITEM_GUNPOWDER = 289, + E_ITEM_WOODEN_HOE = 290, + E_ITEM_STONE_HOE = 291, + E_ITEM_IRON_HOE = 292, + E_ITEM_DIAMOND_HOE = 293, + E_ITEM_GOLD_HOE = 294, + E_ITEM_SEEDS = 295, + E_ITEM_WHEAT = 296, + E_ITEM_BREAD = 297, + E_ITEM_LEATHER_CAP = 298, + E_ITEM_LEATHER_TUNIC = 299, + E_ITEM_LEATHER_PANTS = 300, + E_ITEM_LEATHER_BOOTS = 301, + E_ITEM_CHAIN_HELMET = 302, + E_ITEM_CHAIN_CHESTPLATE = 303, + E_ITEM_CHAIN_LEGGINGS = 304, + E_ITEM_CHAIN_BOOTS = 305, + E_ITEM_IRON_HELMET = 306, + E_ITEM_IRON_CHESTPLATE = 307, + E_ITEM_IRON_LEGGINGS = 308, + E_ITEM_IRON_BOOTS = 309, + E_ITEM_DIAMOND_HELMET = 310, + E_ITEM_DIAMOND_CHESTPLATE = 311, + E_ITEM_DIAMOND_LEGGINGS = 312, + E_ITEM_DIAMOND_BOOTS = 313, + E_ITEM_GOLD_HELMET = 314, + E_ITEM_GOLD_CHESTPLATE = 315, + E_ITEM_GOLD_LEGGINGS = 316, + E_ITEM_GOLD_BOOTS = 317, + E_ITEM_FLINT = 318, + E_ITEM_RAW_PORKCHOP = 319, + E_ITEM_COOKED_PORKCHOP = 320, + E_ITEM_PAINTING = 321, + E_ITEM_GOLDEN_APPLE = 322, + E_ITEM_SIGN = 323, + E_ITEM_WOODEN_DOOR = 324, + E_ITEM_BUCKET = 325, + E_ITEM_WATER_BUCKET = 326, + E_ITEM_LAVA_BUCKET = 327, + E_ITEM_MINECART = 328, + E_ITEM_SADDLE = 329, + E_ITEM_IRON_DOOR = 330, + E_ITEM_REDSTONE_DUST = 331, + E_ITEM_SNOWBALL = 332, + E_ITEM_BOAT = 333, + E_ITEM_LEATHER = 334, + E_ITEM_MILK = 335, + E_ITEM_CLAY_BRICK = 336, + E_ITEM_CLAY = 337, + E_ITEM_SUGARCANE = 338, + E_ITEM_SUGAR_CANE = 338, + E_ITEM_PAPER = 339, + E_ITEM_BOOK = 340, + E_ITEM_SLIMEBALL = 341, + E_ITEM_CHEST_MINECART = 342, + E_ITEM_FURNACE_MINECART = 343, + E_ITEM_EGG = 344, + E_ITEM_COMPASS = 345, + E_ITEM_FISHING_ROD = 346, + E_ITEM_CLOCK = 347, + E_ITEM_GLOWSTONE_DUST = 348, + E_ITEM_RAW_FISH = 349, + E_ITEM_COOKED_FISH = 350, + E_ITEM_DYE = 351, + E_ITEM_BONE = 352, + E_ITEM_SUGAR = 353, + E_ITEM_CAKE = 354, + E_ITEM_BED = 355, + E_ITEM_REDSTONE_REPEATER = 356, + E_ITEM_COOKIE = 357, + E_ITEM_MAP = 358, + E_ITEM_SHEARS = 359, + E_ITEM_MELON_SLICE = 360, + E_ITEM_PUMPKIN_SEEDS = 361, + E_ITEM_MELON_SEEDS = 362, + E_ITEM_RAW_BEEF = 363, + E_ITEM_STEAK = 364, + E_ITEM_RAW_CHICKEN = 365, + E_ITEM_COOKED_CHICKEN = 366, + E_ITEM_ROTTEN_FLESH = 367, + E_ITEM_ENDER_PEARL = 368, + E_ITEM_BLAZE_ROD = 369, + E_ITEM_GHAST_TEAR = 370, + E_ITEM_GOLD_NUGGET = 371, + E_ITEM_NETHER_WART = 372, + E_ITEM_POTION = 373, + E_ITEM_POTIONS = 373, // OBSOLETE, use E_ITEM_POTION instead + E_ITEM_GLASS_BOTTLE = 374, + E_ITEM_SPIDER_EYE = 375, + E_ITEM_FERMENTED_SPIDER_EYE = 376, + E_ITEM_BLAZE_POWDER = 377, + E_ITEM_MAGMA_CREAM = 378, + E_ITEM_BREWING_STAND = 379, + E_ITEM_CAULDRON = 380, + E_ITEM_EYE_OF_ENDER = 381, + E_ITEM_GLISTERING_MELON = 382, + E_ITEM_SPAWN_EGG = 383, + E_ITEM_BOTTLE_O_ENCHANTING = 384, + E_ITEM_FIRE_CHARGE = 385, + E_ITEM_BOOK_AND_QUILL = 386, + E_ITEM_WRITTEN_BOOK = 387, + E_ITEM_EMERALD = 388, + E_ITEM_ITEM_FRAME = 389, + E_ITEM_FLOWER_POT = 390, + E_ITEM_CARROT = 391, + E_ITEM_POTATO = 392, + E_ITEM_BAKED_POTATO = 393, + E_ITEM_POISONOUS_POTATO = 394, + E_ITEM_EMPTY_MAP = 395, + E_ITEM_GOLDEN_CARROT = 396, + E_ITEM_HEAD = 397, + E_ITEM_CARROT_ON_STICK = 398, + E_ITEM_NETHER_STAR = 399, + E_ITEM_PUMPKIN_PIE = 400, + E_ITEM_FIREWORK_ROCKET = 401, + E_ITEM_FIREWORK_STAR = 402, + E_ITEM_ENCHANTED_BOOK = 403, + E_ITEM_COMPARATOR = 404, + E_ITEM_NETHER_BRICK = 405, + E_ITEM_NETHER_QUARTZ = 406, + E_ITEM_MINECART_WITH_TNT = 407, + E_ITEM_MINECART_WITH_HOPPER = 408, + E_ITEM_PRISMARINE_SHARD = 409, + E_ITEM_PRISMARINE_CRYSTALS = 410, + E_ITEM_RAW_RABBIT = 411, + E_ITEM_COOKED_RABBIT = 412, + E_ITEM_RABBIT_STEW = 413, + E_ITEM_RABBITS_FOOT = 414, + E_ITEM_RABBIT_HIDE = 415, + E_ITEM_ARMOR_STAND = 416, + E_ITEM_IRON_HORSE_ARMOR = 417, + E_ITEM_GOLD_HORSE_ARMOR = 418, + E_ITEM_DIAMOND_HORSE_ARMOR = 419, + E_ITEM_LEAD = 420, + E_ITEM_LEASH = E_ITEM_LEAD, + E_ITEM_NAME_TAG = 421, + E_ITEM_MINECART_WITH_COMMAND_BLOCK = 422, + E_ITEM_RAW_MUTTON = 423, + E_ITEM_COOKED_MUTTON = 424, + E_ITEM_BANNER = 425, + E_ITEM_END_CRYSTAL = 426, + E_ITEM_SPRUCE_DOOR = 427, + E_ITEM_BIRCH_DOOR = 428, + E_ITEM_JUNGLE_DOOR = 429, + E_ITEM_ACACIA_DOOR = 430, + E_ITEM_DARK_OAK_DOOR = 431, + E_ITEM_CHORUS_FRUIT = 432, + E_ITEM_POPPED_CHORUS_FRUIT = 433, + E_ITEM_BEETROOT = 434, + E_ITEM_BEETROOT_SEEDS = 435, + E_ITEM_BEETROOT_SOUP = 436, + E_ITEM_DRAGON_BREATH = 437, + E_ITEM_SPLASH_POTION = 438, + E_ITEM_SPECTRAL_ARROW = 439, + E_ITEM_TIPPED_ARROW = 440, + E_ITEM_LINGERING_POTION = 441, + E_ITEM_SHIELD = 442, + E_ITEM_ELYTRA = 443, + E_ITEM_SPRUCE_BOAT = 444, + E_ITEM_BIRCH_BOAT = 445, + E_ITEM_JUNGLE_BOAT = 446, + E_ITEM_ACACIA_BOAT = 447, + E_ITEM_DARK_OAK_BOAT = 448, + E_ITEM_TOTEM_OF_UNDYING = 449, + E_ITEM_SHULKER_SHELL = 450, + E_ITEM_IRON_NUGGET = 452, + + // Keep these two as the last values of the consecutive list, without a number - they will get their correct number assigned automagically by C++ + // IsValidItem() depends on this! + E_ITEM_NUMBER_OF_CONSECUTIVE_TYPES, ///< Number of individual (different) consecutive itemtypes + E_ITEM_MAX_CONSECUTIVE_TYPE_ID = E_ITEM_NUMBER_OF_CONSECUTIVE_TYPES - 1, ///< Maximum consecutive ItemType number used + + E_ITEM_FIRST_DISC = 2256, + E_ITEM_13_DISC = 2256, + E_ITEM_CAT_DISC = 2257, + E_ITEM_BLOCKS_DISC = 2258, + E_ITEM_CHIRP_DISC = 2259, + E_ITEM_FAR_DISC = 2260, + E_ITEM_MALL_DISC = 2261, + E_ITEM_MELLOHI_DISC = 2262, + E_ITEM_STAL_DISC = 2263, + E_ITEM_STRAD_DISC = 2264, + E_ITEM_WARD_DISC = 2265, + E_ITEM_11_DISC = 2266, + E_ITEM_WAIT_DISC = 2267, + + // Keep these two as the last values of the disc list, without a number - they will get their correct number assigned automagically by C++ + // IsValidItem() depends on this! + E_ITEM_LAST_DISC_PLUS_ONE, ///< Useless, really, but needs to be present for the following value + E_ITEM_LAST_DISC = E_ITEM_LAST_DISC_PLUS_ONE - 1, ///< Maximum disc itemtype number used + + E_ITEM_LAST = E_ITEM_LAST_DISC, ///< Maximum valid ItemType +}; + + + + + +enum ENUM_BLOCK_META : NIBBLETYPE +{ + // Please keep this list alpha-sorted by the blocktype part + // then number-sorted for the same block + + //////////////////////////////////////////////////////////////////////////////// + // Block metas: + + // E_BLOCK_ANVIL metas + E_BLOCK_ANVIL_Z = 0, + E_BLOCK_ANVIL_X = 1, + E_BLOCK_ANVIL_NO_DAMAGE = 0, + E_BLOCK_ANVIL_LOW_DAMAGE = 4, + E_BLOCK_ANVIL_HIGH_DAMAGE = 8, + + // E_BLOCK_BED metas: + E_BLOCK_BED_ZP = 0, + E_BLOCK_BED_XM = 1, + E_BLOCK_BED_ZM = 2, + E_BLOCK_BED_XP = 3, + E_BLOCK_BED_OCCUPIED = 4, + E_BLOCK_BED_BED_HEAD = 8, + + // E_BLOCK_BIG_FLOWER metas: + E_META_BIG_FLOWER_SUNFLOWER = 0, + E_META_BIG_FLOWER_LILAC = 1, + E_META_BIG_FLOWER_DOUBLE_TALL_GRASS = 2, + E_META_BIG_FLOWER_LARGE_FERN = 3, + E_META_BIG_FLOWER_ROSE_BUSH = 4, + E_META_BIG_FLOWER_PEONY = 5, + // 0x8 is supposedly a bit flag but all vanilla plants have this value + E_META_BIG_FLOWER_TOP = 10, + + // E_BLOCK_BREWING_STAND metas + E_META_BREWING_STAND_FILLED_SLOT_XP = 1, + E_META_BREWING_STAND_FILLED_SLOT_XM_ZP = 2, + E_META_BREWING_STAND_FILLED_SLOT_XM_ZM = 4, + + // E_BLOCK_BUTTON metas + E_BLOCK_BUTTON_YM = 0, + E_BLOCK_BUTTON_XP = 1, + E_BLOCK_BUTTON_XM = 2, + E_BLOCK_BUTTON_ZP = 3, + E_BLOCK_BUTTON_ZM = 4, + E_BLOCK_BUTTON_YP = 5, + E_BLOCK_BUTTON_PRESSED = 8, + + // E_BLOCK_CARPET metas: + E_META_CARPET_WHITE = 0, + E_META_CARPET_ORANGE = 1, + E_META_CARPET_MAGENTA = 2, + E_META_CARPET_LIGHTBLUE = 3, + E_META_CARPET_YELLOW = 4, + E_META_CARPET_LIGHTGREEN = 5, + E_META_CARPET_PINK = 6, + E_META_CARPET_GRAY = 7, + E_META_CARPET_LIGHTGRAY = 8, + E_META_CARPET_CYAN = 9, + E_META_CARPET_PURPLE = 10, + E_META_CARPET_BLUE = 11, + E_META_CARPET_BROWN = 12, + E_META_CARPET_GREEN = 13, + E_META_CARPET_RED = 14, + E_META_CARPET_BLACK = 15, + + // E_BLOCK_CHEST metas: + E_META_CHEST_FACING_ZM = 2, + E_META_CHEST_FACING_ZP = 3, + E_META_CHEST_FACING_XM = 4, + E_META_CHEST_FACING_XP = 5, + + // E_BLOCK_CONCRETE metas: + E_META_CONCRETE_WHITE = 0, + E_META_CONCRETE_ORANGE = 1, + E_META_CONCRETE_MAGENTA = 2, + E_META_CONCRETE_LIGHTBLUE = 3, + E_META_CONCRETE_YELLOW = 4, + E_META_CONCRETE_LIGHTGREEN = 5, + E_META_CONCRETE_PINK = 6, + E_META_CONCRETE_GRAY = 7, + E_META_CONCRETE_LIGHTGRAY = 8, + E_META_CONCRETE_CYAN = 9, + E_META_CONCRETE_PURPLE = 10, + E_META_CONCRETE_BLUE = 11, + E_META_CONCRETE_BROWN = 12, + E_META_CONCRETE_GREEN = 13, + E_META_CONCRETE_RED = 14, + E_META_CONCRETE_BLACK = 15, + + // E_BLOCK_CONCRETE_POWDER metas: + E_META_CONCRETE_POWDER_WHITE = 0, + E_META_CONCRETE_POWDER_ORANGE = 1, + E_META_CONCRETE_POWDER_MAGENTA = 2, + E_META_CONCRETE_POWDER_LIGHTBLUE = 3, + E_META_CONCRETE_POWDER_YELLOW = 4, + E_META_CONCRETE_POWDER_LIGHTGREEN = 5, + E_META_CONCRETE_POWDER_PINK = 6, + E_META_CONCRETE_POWDER_GRAY = 7, + E_META_CONCRETE_POWDER_LIGHTGRAY = 8, + E_META_CONCRETE_POWDER_CYAN = 9, + E_META_CONCRETE_POWDER_PURPLE = 10, + E_META_CONCRETE_POWDER_BLUE = 11, + E_META_CONCRETE_POWDER_BROWN = 12, + E_META_CONCRETE_POWDER_GREEN = 13, + E_META_CONCRETE_POWDER_RED = 14, + E_META_CONCRETE_POWDER_BLACK = 15, + + // E_BLOCK_DIRT metas: + E_META_DIRT_NORMAL = 0, + E_META_DIRT_GRASSLESS = 1, + E_META_DIRT_COARSE = 1, + E_META_DIRT_PODZOL = 2, + + // E_BLOCK_DISPENSER / E_BLOCK_DROPPER metas: + E_META_DROPSPENSER_FACING_YM = 0, + E_META_DROPSPENSER_FACING_YP = 1, + E_META_DROPSPENSER_FACING_ZM = 2, + E_META_DROPSPENSER_FACING_ZP = 3, + E_META_DROPSPENSER_FACING_XM = 4, + E_META_DROPSPENSER_FACING_XP = 5, + E_META_DROPSPENSER_FACING_MASK = 7, + E_META_DROPSPENSER_ACTIVATED = 8, + + // E_BLOCK_DOUBLE_STONE_SLAB metas: + E_META_DOUBLE_STONE_SLAB_STONE = 0, + E_META_DOUBLE_STONE_SLAB_SANDSTON = 1, + E_META_DOUBLE_STONE_SLAB_WOODEN = 2, + E_META_DOUBLE_STONE_SLAB_COBBLESTONE = 3, + E_META_DOUBLE_STONE_SLAB_BRICK = 4, + E_META_DOUBLE_STONE_SLAB_STONE_BRICK = 5, + E_META_DOUBLE_STONE_SLAB_NETHER_BRICK = 6, + E_META_DOUBLE_STONE_SLAB_QUARTZ = 7, + E_META_DOUBLE_STONE_SLAB_SMOOTH_STONE = 8, + E_META_DOUBLE_STONE_SLAB_SMOOTH_SANDSTONE = 9, + E_META_DOUBLE_STONE_SLAB_TILE_QUARTZ = 10, + + // E_BLOCK_END_PORTAL_FRAME metas: + E_META_END_PORTAL_FRAME_ZP = 0, // Faces towards centre of portal + E_META_END_PORTAL_FRAME_XM = 1, + E_META_END_PORTAL_FRAME_ZM = 2, + E_META_END_PORTAL_FRAME_XP = 3, + E_META_END_PORTAL_FRAME_ZP_EYE = 4, // Frames with ender eye + E_META_END_PORTAL_FRAME_XM_EYE = 5, + E_META_END_PORTAL_FRAME_ZM_EYE = 6, + E_META_END_PORTAL_FRAME_XP_EYE = 7, + E_META_END_PORTAL_FRAME_NO_EYE = 0, // Just the eye bitflag + E_META_END_PORTAL_FRAME_EYE = 4, + + // E_BLOCK_FLOWER metas: + E_META_FLOWER_POPPY = 0, + E_META_FLOWER_BLUE_ORCHID = 1, + E_META_FLOWER_ALLIUM = 2, + E_META_FLOWER_RED_TULIP = 4, + E_META_FLOWER_ORANGE_TULIP = 5, + E_META_FLOWER_WHITE_TULIP = 6, + E_META_FLOWER_PINK_TULIP = 7, + E_META_FLOWER_OXEYE_DAISY = 8, + + // E_BLOCK_JUKEBOX metas: + E_META_JUKEBOX_OFF = 0, + E_META_JUKEBOX_ON = 1, + + // E_BLOCK_HOPPER metas: + E_META_HOPPER_FACING_YM = 0, + E_META_HOPPER_UNATTACHED = 1, // Hopper doesn't move items up, there's no YP + E_META_HOPPER_FACING_ZM = 2, + E_META_HOPPER_FACING_ZP = 3, + E_META_HOPPER_FACING_XM = 4, + E_META_HOPPER_FACING_XP = 5, + + // E_BLOCK_LEAVES metas: + E_META_LEAVES_APPLE = 0, + E_META_LEAVES_CONIFER = 1, + E_META_LEAVES_BIRCH = 2, + E_META_LEAVES_JUNGLE = 3, + E_META_LEAVES_APPLE_NO_DECAY = 4, + E_META_LEAVES_CONIFER_NO_DECAY = 5, + E_META_LEAVES_BIRCH_NO_DECAY = 6, + E_META_LEAVES_JUNGLE_NO_DECAY = 7, + E_META_LEAVES_APPLE_CHECK_DECAY = 8, + E_META_LEAVES_CONIFER_CHECK_DECAY = 9, + E_META_LEAVES_BIRCH_CHECK_DECAY = 10, + E_META_LEAVES_JUNGLE_CHECK_DECAY = 11, + + // E_BLOCK_LEAVES meta cont. (Block ID 161): + E_META_NEWLEAVES_ACACIA = 0, + E_META_NEWLEAVES_DARK_OAK = 1, + E_META_NEWLEAVES_ACACIA_NO_DECAY = 4, + E_META_NEWLEAVES_DARK_OAK_NO_DECAY = 5, + E_META_NEWLEAVES_ACACIA_CHECK_DECAY = 8, + E_META_NEWLEAVES_DARK_OAK_CHECK_DECAY = 9, + + // E_BLOCK_LOG metas: + E_META_LOG_APPLE = 0, + E_META_LOG_CONIFER = 1, + E_META_LOG_BIRCH = 2, + E_META_LOG_JUNGLE = 3, + + // E_BLOCK_NEW_LOG metas: + E_META_NEW_LOG_ACACIA_WOOD = 0, + E_META_NEW_LOG_DARK_OAK_WOOD = 1, + + // E_BLOCK_PISTON metas: + E_META_PISTON_DOWN = 0, + E_META_PISTON_U = 1, + E_META_PISTON_ZM = 2, + E_META_PISTON_ZP = 3, + E_META_PISTON_XM = 4, + E_META_PISTON_XP = 5, + E_META_PISTON_HEAD_STICKY = 8, + E_META_PISTON_EXTENDED = 8, + + // E_BLOCK_PLANKS metas: + E_META_PLANKS_OAK = 0, + E_META_PLANKS_SPRUCE = 1, + E_META_PLANKS_BIRCH = 2, + E_META_PLANKS_JUNGLE = 3, + E_META_PLANKS_ACACIA = 4, + E_META_PLANKS_DARK_OAK = 5, + + // E_BLOCK_(XXX_WEIGHTED)_PRESSURE_PLATE metas: + E_META_PRESSURE_PLATE_RAISED = 0, + E_META_PRESSURE_PLATE_DEPRESSED = 1, + + // E_BLOCK_PRISMARINE_BLOCK metas: + E_META_PRISMARINE_BLOCK_ROUGH = 0, + E_META_PRISMARINE_BLOCK_BRICKS = 1, + E_META_PRISMARINE_BLOCK_DARK = 2, + + // E_BLOCK_QUARTZ_BLOCK metas: + E_META_QUARTZ_NORMAL = 0, + E_META_QUARTZ_CHISELLED = 1, + E_META_QUARTZ_PILLAR = 2, + + // E_BLOCK_RAIL metas + E_META_RAIL_ZM_ZP = 0, + E_META_RAIL_XM_XP = 1, + E_META_RAIL_ASCEND_XP = 2, + E_META_RAIL_ASCEND_XM = 3, + E_META_RAIL_ASCEND_ZM = 4, + E_META_RAIL_ASCEND_ZP = 5, + E_META_RAIL_CURVED_ZP_XP = 6, + E_META_RAIL_CURVED_ZP_XM = 7, + E_META_RAIL_CURVED_ZM_XM = 8, + E_META_RAIL_CURVED_ZM_XP = 9, + + // E_BLOCK_RED_SANDSTONE metas: + E_META_RED_SANDSTONE_NORMAL = 0, + E_META_RED_SANDSTONE_ORNAMENT = 1, + E_META_RED_SANDSTONE_SMOOTH = 2, + + // E_BLOCK_SAND metas: + E_META_SAND_NORMAL = 0, + E_META_SAND_RED = 1, + + // E_BLOCK_SANDSTONE metas: + E_META_SANDSTONE_NORMAL = 0, + E_META_SANDSTONE_ORNAMENT = 1, + E_META_SANDSTONE_SMOOTH = 2, + + // E_BLOCK_SAPLING metas (lowest 3 bits): + E_META_SAPLING_APPLE = 0, + E_META_SAPLING_CONIFER = 1, + E_META_SAPLING_BIRCH = 2, + E_META_SAPLING_JUNGLE = 3, + E_META_SAPLING_ACACIA = 4, + E_META_SAPLING_DARK_OAK = 5, + + // E_BLOCK_SILVERFISH_EGG metas: + E_META_SILVERFISH_EGG_STONE = 0, + E_META_SILVERFISH_EGG_COBBLESTONE = 1, + E_META_SILVERFISH_EGG_STONE_BRICK = 2, + + // E_BLOCK_SNOW metas: + E_META_SNOW_LAYER_ONE = 0, + E_META_SNOW_LAYER_TWO = 1, + E_META_SNOW_LAYER_THREE = 2, + E_META_SNOW_LAYER_FOUR = 3, + E_META_SNOW_LAYER_FIVE = 4, + E_META_SNOW_LAYER_SIX = 5, + E_META_SNOW_LAYER_SEVEN = 6, + E_META_SNOW_LAYER_EIGHT = 7, + + // E_BLOCK_SPONGE metas: + E_META_SPONGE_DRY = 0, + E_META_SPONGE_WET = 1, + + // E_BLOCK_STAINED_CLAY metas: + E_META_STAINED_CLAY_WHITE = 0, + E_META_STAINED_CLAY_ORANGE = 1, + E_META_STAINED_CLAY_MAGENTA = 2, + E_META_STAINED_CLAY_LIGHTBLUE = 3, + E_META_STAINED_CLAY_YELLOW = 4, + E_META_STAINED_CLAY_LIGHTGREEN = 5, + E_META_STAINED_CLAY_PINK = 6, + E_META_STAINED_CLAY_GRAY = 7, + E_META_STAINED_CLAY_LIGHTGRAY = 8, + E_META_STAINED_CLAY_CYAN = 9, + E_META_STAINED_CLAY_PURPLE = 10, + E_META_STAINED_CLAY_BLUE = 11, + E_META_STAINED_CLAY_BROWN = 12, + E_META_STAINED_CLAY_GREEN = 13, + E_META_STAINED_CLAY_RED = 14, + E_META_STAINED_CLAY_BLACK = 15, + + // E_BLOCK_STAINED_GLASS metas: + E_META_STAINED_GLASS_WHITE = 0, + E_META_STAINED_GLASS_ORANGE = 1, + E_META_STAINED_GLASS_MAGENTA = 2, + E_META_STAINED_GLASS_LIGHTBLUE = 3, + E_META_STAINED_GLASS_YELLOW = 4, + E_META_STAINED_GLASS_LIGHTGREEN = 5, + E_META_STAINED_GLASS_PINK = 6, + E_META_STAINED_GLASS_GRAY = 7, + E_META_STAINED_GLASS_LIGHTGRAY = 8, + E_META_STAINED_GLASS_CYAN = 9, + E_META_STAINED_GLASS_PURPLE = 10, + E_META_STAINED_GLASS_BLUE = 11, + E_META_STAINED_GLASS_BROWN = 12, + E_META_STAINED_GLASS_GREEN = 13, + E_META_STAINED_GLASS_RED = 14, + E_META_STAINED_GLASS_BLACK = 15, + + // E_BLOCK_STAINED_GLASS_PANE metas: + E_META_STAINED_GLASS_PANE_WHITE = 0, + E_META_STAINED_GLASS_PANE_ORANGE = 1, + E_META_STAINED_GLASS_PANE_MAGENTA = 2, + E_META_STAINED_GLASS_PANE_LIGHTBLUE = 3, + E_META_STAINED_GLASS_PANE_YELLOW = 4, + E_META_STAINED_GLASS_PANE_LIGHTGREEN = 5, + E_META_STAINED_GLASS_PANE_PINK = 6, + E_META_STAINED_GLASS_PANE_GRAY = 7, + E_META_STAINED_GLASS_PANE_LIGHTGRAY = 8, + E_META_STAINED_GLASS_PANE_CYAN = 9, + E_META_STAINED_GLASS_PANE_PURPLE = 10, + E_META_STAINED_GLASS_PANE_BLUE = 11, + E_META_STAINED_GLASS_PANE_BROWN = 12, + E_META_STAINED_GLASS_PANE_GREEN = 13, + E_META_STAINED_GLASS_PANE_RED = 14, + E_META_STAINED_GLASS_PANE_BLACK = 15, + + // E_BLOCK_STAIRS metas: + E_BLOCK_STAIRS_XP = 0, + E_BLOCK_STAIRS_XM = 1, + E_BLOCK_STAIRS_ZP = 2, + E_BLOCK_STAIRS_ZM = 3, + E_BLOCK_STAIRS_UPSIDE_DOWN = 4, + + // E_BLOCK_STONE metas: + E_META_STONE_STONE = 0, + E_META_STONE_GRANITE = 1, + E_META_STONE_POLISHED_GRANITE = 2, + E_META_STONE_DIORITE = 3, + E_META_STONE_POLISHED_DIORITE = 4, + E_META_STONE_ANDESITE = 5, + E_META_STONE_POLISHED_ANDESITE = 6, + + // E_BLOCK_STONE_SLAB metas: + E_META_STONE_SLAB_STONE = 0, + E_META_STONE_SLAB_SANDSTONE = 1, + E_META_STONE_SLAB_PLANKS = 2, + E_META_STONE_SLAB_COBBLESTONE = 3, + E_META_STONE_SLAB_BRICK = 4, + E_META_STONE_SLAB_STONE_BRICK = 5, + E_META_STONE_SLAB_NETHER_BRICK = 6, + E_META_STONE_SLAB_QUARTZ = 7, + + // E_BLOCK_STONE_BRICKS metas: + E_META_STONE_BRICK_NORMAL = 0, + E_META_STONE_BRICK_MOSSY = 1, + E_META_STONE_BRICK_CRACKED = 2, + E_META_STONE_BRICK_ORNAMENT = 3, + + // E_BLOCK_TALL_GRASS metas: + E_META_TALL_GRASS_DEAD_SHRUB = 0, + E_META_TALL_GRASS_GRASS = 1, + E_META_TALL_GRASS_FERN = 2, + E_META_TALL_GRASS_BIOME = 3, + + // E_BLOCK_TORCH, E_BLOCK_REDSTONE_TORCH_OFF, E_BLOCK_REDSTONE_TORCH_ON metas: + E_META_TORCH_EAST = 1, // east face of the block, pointing east + E_META_TORCH_WEST = 2, + E_META_TORCH_SOUTH = 3, + E_META_TORCH_NORTH = 4, + E_META_TORCH_FLOOR = 5, + E_META_TORCH_XM = 1, // Torch attached to the XM side of its block + E_META_TORCH_XP = 2, // Torch attached to the XP side of its block + E_META_TORCH_ZM = 3, // Torch attached to the ZM side of its block + E_META_TORCH_ZP = 4, // Torch attached to the ZP side of its block + + // E_META_LOG metas: + E_META_LOG_OAK_UP_DOWN = 0, + E_META_LOG_SPRUCE_UP_DOWN = 1, + E_META_LOG_BIRCH_UP_DOWN = 2, + E_META_LOG_JUNGLE_UP_DOWN = 3, + E_META_LOG_OAK_X = 4, + E_META_LOG_SPRUCE_X = 5, + E_META_LOG_BIRCH_X = 6, + E_META_LOG_JUNGLE_X = 7, + E_META_LOG_OAK_Z = 8, + E_META_LOG_SPRUCE_Z = 9, + E_META_LOG_BIRCH_Z = 10, + E_META_LOG_JUNGLE_Z = 11, + E_META_LOG_OAK_BARK_ONLY = 12, + E_META_LOG_SPRUCE_BARK_ONLY = 13, + E_META_LOG_BIRCH_BARK_ONLY = 14, + E_META_LOG_JUNGLE_BARK_ONLY = 15, + + // E_META_LOG metas cont. (Block ID 162): + E_META_NEWLOG_ACACIA_UP_DOWN = 0, + E_META_NEWLOG_DARK_OAK_UP_DOWN = 1, + E_META_NEWLOG_ACACIA_X = 4, + E_META_NEWLOG_DARK_OAK_X = 5, + E_META_NEWLOG_ACACIA_Z = 8, + E_META_NEWLOG_DARK_OAK_Z = 9, + E_META_NEWLOG_ACACIA_BARK_ONLY = 12, + E_META_NEWLOG_DARK_OAK_BARK_ONLY = 13, + + // E_BLOCK_WOODEN_DOUBLE_SLAB metas: + E_META_WOODEN_DOUBLE_SLAB_OAK = 0, + E_META_WOODEN_DOUBLE_SLAB_SPRUCE = 1, + E_META_WOODEN_DOUBLE_SLAB_BIRCH = 2, + E_META_WOODEN_DOUBLE_SLAB_JUNGLE = 3, + E_META_WOODEN_DOUBLE_SLAB_ACACIA = 4, + E_META_WOODEN_DOUBLE_SLAB_DARK_OAK = 5, + + // E_BLOCK_WOODEN_SLAB metas: + E_META_WOODEN_SLAB_OAK = 0, + E_META_WOODEN_SLAB_SPRUCE = 1, + E_META_WOODEN_SLAB_BIRCH = 2, + E_META_WOODEN_SLAB_JUNGLE = 3, + E_META_WOODEN_SLAB_ACACIA = 4, + E_META_WOODEN_SLAB_DARK_OAK = 5, + E_META_WOODEN_SLAB_UPSIDE_DOWN = 8, + + // E_BLOCK_WOOL metas: + E_META_WOOL_WHITE = 0, + E_META_WOOL_ORANGE = 1, + E_META_WOOL_MAGENTA = 2, + E_META_WOOL_LIGHTBLUE = 3, + E_META_WOOL_YELLOW = 4, + E_META_WOOL_LIGHTGREEN = 5, + E_META_WOOL_PINK = 6, + E_META_WOOL_GRAY = 7, + E_META_WOOL_LIGHTGRAY = 8, + E_META_WOOL_CYAN = 9, + E_META_WOOL_PURPLE = 10, + E_META_WOOL_BLUE = 11, + E_META_WOOL_BROWN = 12, + E_META_WOOL_GREEN = 13, + E_META_WOOL_RED = 14, + E_META_WOOL_BLACK = 15, +}; + + + + + +enum ENUM_ITEM_META : short +{ + // Please keep this list alpha-sorted by the itemtype part + // then number-sorted for the same item + + //////////////////////////////////////////////////////////////////////////////// + // Item metas: + + // E_ITEM_BANNER metas: + E_META_BANNER_BLACK = 0, + E_META_BANNER_RED = 1, + E_META_BANNER_GREEN = 2, + E_META_BANNER_BROWN = 3, + E_META_BANNER_BLUE = 4, + E_META_BANNER_PURPLE = 5, + E_META_BANNER_CYAN = 6, + E_META_BANNER_LIGHTGRAY = 7, + E_META_BANNER_GRAY = 8, + E_META_BANNER_PINK = 9, + E_META_BANNER_LIGHTGREEN = 10, + E_META_BANNER_YELLOW = 11, + E_META_BANNER_LIGHTBLUE = 12, + E_META_BANNER_MAGENTA = 13, + E_META_BANNER_ORANGE = 14, + E_META_BANNER_WHITE = 15, + + // E_ITEM_COAL metas: + E_META_COAL_NORMAL = 0, + E_META_COAL_CHARCOAL = 1, + + // E_ITEM_DYE metas: + E_META_DYE_BLACK = 0, + E_META_DYE_RED = 1, + E_META_DYE_GREEN = 2, + E_META_DYE_BROWN = 3, + E_META_DYE_BLUE = 4, + E_META_DYE_PURPLE = 5, + E_META_DYE_CYAN = 6, + E_META_DYE_LIGHTGRAY = 7, + E_META_DYE_GRAY = 8, + E_META_DYE_PINK = 9, + E_META_DYE_LIGHTGREEN = 10, + E_META_DYE_YELLOW = 11, + E_META_DYE_LIGHTBLUE = 12, + E_META_DYE_MAGENTA = 13, + E_META_DYE_ORANGE = 14, + E_META_DYE_WHITE = 15, + + // E_ITEM_GOLDEN_APPLE metas: + E_META_GOLDEN_APPLE_NORMAL = 0, + E_META_GOLDEN_APPLE_ENCHANTED = 1, + + // E_ITEM_HEAD metas: + E_META_HEAD_SKELETON = 0, + E_META_HEAD_WITHER = 1, + E_META_HEAD_ZOMBIE = 2, + E_META_HEAD_PLAYER = 3, + E_META_HEAD_CREEPER = 4, + E_META_HEAD_DRAGON = 5, + + // E_ITEM_RAW_FISH metas: + E_META_RAW_FISH_FISH = 0, + E_META_RAW_FISH_SALMON = 1, + E_META_RAW_FISH_CLOWNFISH = 2, + E_META_RAW_FISH_PUFFERFISH = 3, + + // E_ITEM_COOKED_FISH metas: + E_META_COOKED_FISH_FISH = 0, + E_META_COOKED_FISH_SALMON = 1, + + // E_ITEM_MINECART_TRACKS metas: + E_META_TRACKS_X = 1, + E_META_TRACKS_Z = 0, + + // E_ITEM_SPAWN_EGG metas: + // See also cMonster::eType, since monster type and spawn egg meta are the same + E_META_SPAWN_EGG_PICKUP = 1, + E_META_SPAWN_EGG_EXPERIENCE_ORB = 2, + E_META_SPAWN_EGG_LEASH_KNOT = 8, + E_META_SPAWN_EGG_PAINTING = 9, + E_META_SPAWN_EGG_ARROW = 10, + E_META_SPAWN_EGG_SNOWBALL = 11, + E_META_SPAWN_EGG_FIREBALL = 12, + E_META_SPAWN_EGG_SMALL_FIREBALL = 13, + E_META_SPAWN_EGG_ENDER_PEARL = 14, + E_META_SPAWN_EGG_EYE_OF_ENDER = 15, + E_META_SPAWN_EGG_SPLASH_POTION = 16, + E_META_SPAWN_EGG_EXP_BOTTLE = 17, + E_META_SPAWN_EGG_ITEM_FRAME = 18, + E_META_SPAWN_EGG_WITHER_SKULL = 19, + E_META_SPAWN_EGG_PRIMED_TNT = 20, + E_META_SPAWN_EGG_FALLING_BLOCK = 21, + E_META_SPAWN_EGG_FIREWORK = 22, + E_META_SPAWN_EGG_BOAT = 41, + E_META_SPAWN_EGG_MINECART = 42, + E_META_SPAWN_EGG_MINECART_CHEST = 43, + E_META_SPAWN_EGG_MINECART_FURNACE = 44, + E_META_SPAWN_EGG_MINECART_TNT = 45, + E_META_SPAWN_EGG_MINECART_HOPPER = 46, + E_META_SPAWN_EGG_MINECART_SPAWNER = 47, + E_META_SPAWN_EGG_CREEPER = 50, + E_META_SPAWN_EGG_SKELETON = 51, + E_META_SPAWN_EGG_SPIDER = 52, + E_META_SPAWN_EGG_GIANT = 53, + E_META_SPAWN_EGG_ZOMBIE = 54, + E_META_SPAWN_EGG_SLIME = 55, + E_META_SPAWN_EGG_GHAST = 56, + E_META_SPAWN_EGG_ZOMBIE_PIGMAN = 57, + E_META_SPAWN_EGG_ENDERMAN = 58, + E_META_SPAWN_EGG_CAVE_SPIDER = 59, + E_META_SPAWN_EGG_SILVERFISH = 60, + E_META_SPAWN_EGG_BLAZE = 61, + E_META_SPAWN_EGG_MAGMA_CUBE = 62, + E_META_SPAWN_EGG_ENDER_DRAGON = 63, + E_META_SPAWN_EGG_WITHER = 64, + E_META_SPAWN_EGG_BAT = 65, + E_META_SPAWN_EGG_WITCH = 66, + E_META_SPAWN_EGG_GUARDIAN = 68, + E_META_SPAWN_EGG_PIG = 90, + E_META_SPAWN_EGG_SHEEP = 91, + E_META_SPAWN_EGG_COW = 92, + E_META_SPAWN_EGG_CHICKEN = 93, + E_META_SPAWN_EGG_SQUID = 94, + E_META_SPAWN_EGG_WOLF = 95, + E_META_SPAWN_EGG_MOOSHROOM = 96, + E_META_SPAWN_EGG_SNOW_GOLEM = 97, + E_META_SPAWN_EGG_OCELOT = 98, + E_META_SPAWN_EGG_IRON_GOLEM = 99, + E_META_SPAWN_EGG_HORSE = 100, + E_META_SPAWN_EGG_RABBIT = 101, + E_META_SPAWN_EGG_VILLAGER = 120, + E_META_SPAWN_EGG_ENDER_CRYSTAL = 200, +} ; + +// tolua_end + + + + +// fwd: +class cItem; +class cIniFile; + + + + + +// tolua_begin + +/** Translates a blocktype string into blocktype. Takes either a number or an items.ini alias as input. Returns -1 on failure. */ +extern int BlockStringToType(const AString & a_BlockTypeString); + +/** Translates an itemtype string into an item. Takes either a number, number^number, number:number or an items.ini alias as input. Returns true if successful. */ +extern bool StringToItem(const AString & a_ItemTypeString, cItem & a_Item); + +/** Translates a full item into a string. If the ItemType is not recognized, the ItemType number is output into the string. */ +extern AString ItemToString(const cItem & a_Item); + +/** Translates itemtype into a string. If the type is not recognized, the itemtype number is output into the string. */ +extern AString ItemTypeToString(short a_ItemType); + +/** Translates a full item into a fully-specified string (including meta and count). If the ItemType is not recognized, the ItemType number is output into the string. */ +extern AString ItemToFullString(const cItem & a_Item); + +/** Returns a cItem representing the item described in an IniFile's value; if the value doesn't exist, creates it with the provided default. */ +extern cItem GetIniItemSet(cIniFile & a_IniFile, const char * a_Section, const char * a_Key, const char * a_Default); + +// tolua_end + + + + + +/** Base case for IsOneOf to handle empty template aguments. */ +template +bool IsOneOf(BLOCKTYPE a_BlockType) +{ + return false; +} + + +/** Returns true if a_BlockType is equal to any of the variadic template arguments. +Some example usage: +\code + IsOneOf<>(E_BLOCK_AIR) == false + IsOneOf(E_BLOCK_DIRT) == false + IsOneOf(E_BLOCK_DIRT) == true +\endcode +The implementation is ugly but it is equivalent to this C++17 fold expression: +\code + ((a_BlockType == Types) || ...) +\endcode +Just written to be valid without fold expressions or SFINAE. */ +template +bool IsOneOf(BLOCKTYPE a_BlockType) +{ + return ((a_BlockType == Head) || (IsOneOf(a_BlockType))); +} + + + diff --git a/src/BlockTypeRegistry.h b/src/BlockTypeRegistry.h index 2048105df..529e13eb2 100644 --- a/src/BlockTypeRegistry.h +++ b/src/BlockTypeRegistry.h @@ -12,6 +12,7 @@ // fwd: +class cBlockHandler; class BlockState; diff --git a/src/Blocks/BlockBigFlower.h b/src/Blocks/BlockBigFlower.h index f81b16bd2..720c8f40a 100644 --- a/src/Blocks/BlockBigFlower.h +++ b/src/Blocks/BlockBigFlower.h @@ -3,6 +3,7 @@ #include "BlockHandler.h" #include "ChunkInterface.h" +#include "../BlockInfo.h" #include "../Items/ItemHandler.h" diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h index 8f90f84e5..10d3569d0 100644 --- a/src/Blocks/BlockButton.h +++ b/src/Blocks/BlockButton.h @@ -1,6 +1,7 @@ #pragma once #include "BlockHandler.h" +#include "../BlockInfo.h" #include "../Chunk.h" #include "Mixins.h" diff --git a/src/Blocks/BlockCactus.h b/src/Blocks/BlockCactus.h index 8c24cda9f..a00f5b6d4 100644 --- a/src/Blocks/BlockCactus.h +++ b/src/Blocks/BlockCactus.h @@ -1,6 +1,7 @@ #pragma once #include "BlockPlant.h" +#include "../BlockInfo.h" diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index 596e69793..ccb34c5a9 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -2,6 +2,7 @@ #pragma once #include "BlockHandler.h" +#include "../BlockInfo.h" #include "../Entities/Player.h" #include "../Chunk.h" #include "Mixins.h" diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 789ef4dd5..75f6610ce 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -2,7 +2,7 @@ #pragma once #include "../Defines.h" - +#include "../Item.h" #include "../BoundingBox.h" diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index 5c929c4c5..5a18cffac 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -1,6 +1,7 @@ #include "Globals.h" #include "BlockPiston.h" +#include "../BlockInfo.h" #include "../Item.h" #include "../World.h" #include "../Entities/Player.h" diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index a136cd6e0..ef58c243c 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -11,7 +11,9 @@ #include "BlockHandler.h" #include "ChunkInterface.h" +#include "../BlockInfo.h" #include "../Entities/Player.h" +#include "../BlockInfo.h" diff --git a/src/Blocks/BlockStems.h b/src/Blocks/BlockStems.h index 0eb091b3c..202d71b19 100644 --- a/src/Blocks/BlockStems.h +++ b/src/Blocks/BlockStems.h @@ -10,7 +10,7 @@ /** Handler for stems from which produce grows in an adjacent block (melon, pumpkin) after it becomes ripe (meta == 7). ProduceBlockType is the blocktype for the produce to be grown. StemPickupType is the item type for the pickup resulting from breaking the stem. */ -template +template class cBlockStemsHandler: public cBlockPlant { diff --git a/src/Blocks/ChunkInterface.cpp b/src/Blocks/ChunkInterface.cpp index eff3f4da9..fd64ee9fc 100644 --- a/src/Blocks/ChunkInterface.cpp +++ b/src/Blocks/ChunkInterface.cpp @@ -6,6 +6,7 @@ #include "WorldInterface.h" #include "../ChunkMap.h" #include "../World.h" +#include "../BlockInfo.h" diff --git a/src/Blocks/ChunkInterface.h b/src/Blocks/ChunkInterface.h index 4ff2fb3fe..345fca4d2 100644 --- a/src/Blocks/ChunkInterface.h +++ b/src/Blocks/ChunkInterface.h @@ -5,10 +5,17 @@ + +// fwd: +class cItem; class cChunkMap; class cWorldInterface; class cPlayer; + + + + class cChunkInterface: public cForEachChunkProvider { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 92f7b11b5..5012fc3e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,9 +15,9 @@ set(FOLDERS SET (SRCS BiomeDef.cpp BlockArea.cpp - BlockID.cpp BlockInfo.cpp BlockState.cpp + BlockType.cpp BlockTypePalette.cpp BlockTypeRegistry.cpp BrewingRecipes.cpp @@ -38,6 +38,7 @@ SET (SRCS CraftingRecipes.cpp Cuboid.cpp DeadlockDetect.cpp + Defines.cpp Enchantments.cpp FastRandom.cpp FurnaceRecipe.cpp @@ -85,11 +86,11 @@ SET (HDRS AllocationPool.h BiomeDef.h BlockArea.h - BlockID.h BlockInServerPluginInterface.h BlockInfo.h BlockState.h BlockTracer.h + BlockType.h BlockTypePalette.h BlockTypeRegistry.h BrewingRecipes.h @@ -179,7 +180,7 @@ include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/TCLAP/include") configure_file("BuildInfo.h.cmake" "${CMAKE_BINARY_DIR}/include/BuildInfo.h") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set_source_files_properties(BlockID.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors") + set_source_files_properties(BlockType.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors") set_source_files_properties(ByteBuffer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors") set_source_files_properties(ClientHandle.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors ") set_source_files_properties(Statistics.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors") diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 9dc0e8aee..d9601e451 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -7,6 +7,7 @@ #include "Chunk.h" +#include "BlockInfo.h" #include "World.h" #include "ClientHandle.h" #include "Server.h" diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index a095880c3..a480c2c66 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -5,6 +5,7 @@ #include "Globals.h" #include "ChunkData.h" +#include "BlockType.h" diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index fdaf7390d..cb6ba07ca 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "ChunkMap.h" +#include "BlockInfo.h" #include "World.h" #include "Root.h" #include "Entities/Player.h" diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 9a92a3005..92ed2013f 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1,6 +1,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "ClientHandle.h" +#include "BlockInfo.h" #include "Server.h" #include "World.h" #include "Chunk.h" diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp index e986a2f87..1a8a68523 100644 --- a/src/CraftingRecipes.cpp +++ b/src/CraftingRecipes.cpp @@ -83,7 +83,7 @@ cItem & cCraftingGrid::GetItem(int x, int y) const -void cCraftingGrid::SetItem(int x, int y, ENUM_ITEM_ID a_ItemType, char a_ItemCount, short a_ItemHealth) +void cCraftingGrid::SetItem(int x, int y, ENUM_ITEM_TYPE a_ItemType, char a_ItemCount, short a_ItemHealth) { // Accessible through scripting, must verify parameters: if ((x < 0) || (x >= m_Width) || (y < 0) || (y >= m_Height)) @@ -235,7 +235,7 @@ void cCraftingRecipe::Clear(void) -void cCraftingRecipe::SetResult(ENUM_ITEM_ID a_ItemType, char a_ItemCount, short a_ItemHealth) +void cCraftingRecipe::SetResult(ENUM_ITEM_TYPE a_ItemType, char a_ItemCount, short a_ItemHealth) { m_Result = cItem(a_ItemType, a_ItemCount, a_ItemHealth); } diff --git a/src/CraftingRecipes.h b/src/CraftingRecipes.h index 1c4e87461..9659e53fc 100644 --- a/src/CraftingRecipes.h +++ b/src/CraftingRecipes.h @@ -33,7 +33,7 @@ public: int GetWidth (void) const {return m_Width; } int GetHeight(void) const {return m_Height; } cItem & GetItem (int x, int y) const; - void SetItem (int x, int y, ENUM_ITEM_ID a_ItemType, char a_ItemCount, short a_ItemHealth); + void SetItem (int x, int y, ENUM_ITEM_TYPE a_ItemType, char a_ItemCount, short a_ItemHealth); void SetItem (int x, int y, const cItem & a_Item); void Clear (void); @@ -72,13 +72,13 @@ public: int GetIngredientsHeight(void) const {return m_Ingredients.GetHeight(); } cItem & GetIngredient (int x, int y) const {return m_Ingredients.GetItem(x, y); } const cItem & GetResult (void) const {return m_Result; } - void SetResult (ENUM_ITEM_ID a_ItemType, char a_ItemCount, short a_ItemHealth); + void SetResult (ENUM_ITEM_TYPE a_ItemType, char a_ItemCount, short a_ItemHealth); void SetResult (const cItem & a_Item) { m_Result = a_Item; } - void SetIngredient (int x, int y, ENUM_ITEM_ID a_ItemType, char a_ItemCount, short a_ItemHealth) + void SetIngredient (int x, int y, ENUM_ITEM_TYPE a_ItemType, char a_ItemCount, short a_ItemHealth) { m_Ingredients.SetItem(x, y, a_ItemType, a_ItemCount, a_ItemHealth); } diff --git a/src/Defines.cpp b/src/Defines.cpp new file mode 100644 index 000000000..4e0ad775a --- /dev/null +++ b/src/Defines.cpp @@ -0,0 +1,627 @@ +#include "Globals.h" + +#include "Defines.h" +#include "BlockType.h" + + + + + +const char * ClickActionToString(int a_ClickAction) +{ + switch (a_ClickAction) + { + case caLeftClick: return "caLeftClick"; + case caRightClick: return "caRightClick"; + case caShiftLeftClick: return "caShiftLeftClick"; + case caShiftRightClick: return "caShiftRightClick"; + case caNumber1: return "caNumber1"; + case caNumber2: return "caNumber2"; + case caNumber3: return "caNumber3"; + case caNumber4: return "caNumber4"; + case caNumber5: return "caNumber5"; + case caNumber6: return "caNumber6"; + case caNumber7: return "caNumber7"; + case caNumber8: return "caNumber8"; + case caNumber9: return "caNumber9"; + case caMiddleClick: return "caMiddleClick"; + case caDropKey: return "caDropKey"; + case caCtrlDropKey: return "caCtrlDropKey"; + case caLeftClickOutside: return "caLeftClickOutside"; + case caRightClickOutside: return "caRightClickOutside"; + case caLeftClickOutsideHoldNothing: return "caLeftClickOutsideHoldNothing"; + case caRightClickOutsideHoldNothing: return "caRightClickOutsideHoldNothing"; + case caLeftPaintBegin: return "caLeftPaintBegin"; + case caRightPaintBegin: return "caRightPaintBegin"; + case caMiddlePaintBegin: return "caMiddlePaintBegin"; + case caLeftPaintProgress: return "caLeftPaintProgress"; + case caRightPaintProgress: return "caRightPaintProgress"; + case caMiddlePaintProgress: return "caMiddlePaintProgress"; + case caLeftPaintEnd: return "caLeftPaintEnd"; + case caRightPaintEnd: return "caRightPaintEnd"; + case caMiddlePaintEnd: return "caMiddlePaintEnd"; + case caDblClick: return "caDblClick"; + + case caUnknown: return "caUnknown"; + } + UNREACHABLE("Unknown click action"); +} + + + + + +/** Returns a blockface mirrored around the Y axis (doesn't change up / down). */ +eBlockFace MirrorBlockFaceY(eBlockFace a_BlockFace) +{ + switch (a_BlockFace) + { + case BLOCK_FACE_XM: return BLOCK_FACE_XP; + case BLOCK_FACE_XP: return BLOCK_FACE_XM; + case BLOCK_FACE_ZM: return BLOCK_FACE_ZP; + case BLOCK_FACE_ZP: return BLOCK_FACE_ZM; + case BLOCK_FACE_NONE: + case BLOCK_FACE_YM: + case BLOCK_FACE_YP: + { + return a_BlockFace; + } + } + UNREACHABLE("Unsupported block face"); +} + + + + + +/** Returns a blockface rotated around the Y axis counter-clockwise. */ +eBlockFace RotateBlockFaceCCW(eBlockFace a_BlockFace) +{ + switch (a_BlockFace) + { + case BLOCK_FACE_XM: return BLOCK_FACE_ZP; + case BLOCK_FACE_XP: return BLOCK_FACE_ZM; + case BLOCK_FACE_ZM: return BLOCK_FACE_XM; + case BLOCK_FACE_ZP: return BLOCK_FACE_XP; + case BLOCK_FACE_NONE: + case BLOCK_FACE_YM: + case BLOCK_FACE_YP: + { + return a_BlockFace; + } + } + UNREACHABLE("Unsupported block face"); +} + + + + + +eBlockFace RotateBlockFaceCW(eBlockFace a_BlockFace) +{ + switch (a_BlockFace) + { + case BLOCK_FACE_XM: return BLOCK_FACE_ZM; + case BLOCK_FACE_XP: return BLOCK_FACE_ZP; + case BLOCK_FACE_ZM: return BLOCK_FACE_XP; + case BLOCK_FACE_ZP: return BLOCK_FACE_XM; + case BLOCK_FACE_NONE: + case BLOCK_FACE_YM: + case BLOCK_FACE_YP: + { + return a_BlockFace; + } + } + UNREACHABLE("Unsupported block face"); +} + + + + + +eBlockFace ReverseBlockFace(eBlockFace a_BlockFace) +{ + switch (a_BlockFace) + { + case BLOCK_FACE_YP: return BLOCK_FACE_YM; + case BLOCK_FACE_XP: return BLOCK_FACE_XM; + case BLOCK_FACE_ZP: return BLOCK_FACE_ZM; + case BLOCK_FACE_YM: return BLOCK_FACE_YP; + case BLOCK_FACE_XM: return BLOCK_FACE_XP; + case BLOCK_FACE_ZM: return BLOCK_FACE_ZP; + case BLOCK_FACE_NONE: return a_BlockFace; + } + UNREACHABLE("Unsupported block face"); +} + + + + + +/** Returns the textual representation of the BlockFace constant. */ +AString BlockFaceToString(eBlockFace a_BlockFace) +{ + switch (a_BlockFace) + { + case BLOCK_FACE_XM: return "BLOCK_FACE_XM"; + case BLOCK_FACE_XP: return "BLOCK_FACE_XP"; + case BLOCK_FACE_YM: return "BLOCK_FACE_YM"; + case BLOCK_FACE_YP: return "BLOCK_FACE_YP"; + case BLOCK_FACE_ZM: return "BLOCK_FACE_ZM"; + case BLOCK_FACE_ZP: return "BLOCK_FACE_ZP"; + case BLOCK_FACE_NONE: return "BLOCK_FACE_NONE"; + } + UNREACHABLE("Unsupported block face"); +} + + + + + +bool IsValidBlock(int a_BlockType) +{ + if ( + ( + (a_BlockType > -1) && + (a_BlockType <= E_BLOCK_MAX_TYPE_ID) + ) || + (a_BlockType == 255) // the blocks 253-254 don't exist yet -> https://minecraft.gamepedia.com/Data_values#Block_IDs + ) + { + return true; + } + return false; +} + + + + + +bool IsValidItem(int a_ItemType) +{ + if ( + ((a_ItemType >= E_ITEM_FIRST) && (a_ItemType <= E_ITEM_MAX_CONSECUTIVE_TYPE_ID)) || // Basic items range + ((a_ItemType >= E_ITEM_FIRST_DISC) && (a_ItemType <= E_ITEM_LAST_DISC)) // Music discs' special range + ) + { + return true; + } + + if (a_ItemType == 0) + { + return false; + } + + return IsValidBlock(a_ItemType); +} + + + + + +eDimension StringToDimension(const AString & a_DimensionString) +{ + // First try decoding as a number + int res; + if (StringToInteger(a_DimensionString, res)) + { + // It was a valid number + return static_cast(res); + } + + // Decode using a built-in map: + static struct + { + eDimension m_Dimension; + const char * m_String; + } DimensionMap [] = + { + { dimOverworld, "Overworld"}, + { dimOverworld, "Normal"}, + { dimOverworld, "World"}, + { dimNether, "Nether"}, + { dimNether, "Hell"}, // Alternate name for Nether + { dimEnd, "End"}, + { dimEnd, "Sky"}, // Old name for End + } ; + for (size_t i = 0; i < ARRAYCOUNT(DimensionMap); i++) + { + if (NoCaseCompare(DimensionMap[i].m_String, a_DimensionString) == 0) + { + return DimensionMap[i].m_Dimension; + } + } // for i - DimensionMap[] + + // Not found + LOGWARNING("Unknown dimension: \"%s\". Setting to Overworld", a_DimensionString.c_str()); + return dimOverworld; +} + + + + + +AString DimensionToString(eDimension a_Dimension) +{ + // Decode using a built-in map: + static struct + { + eDimension m_Dimension; + const char * m_String; + } DimensionMap[] = + { + { dimOverworld, "Overworld" }, + { dimNether, "Nether" }, + { dimEnd, "End" }, + }; + + for (size_t i = 0; i < ARRAYCOUNT(DimensionMap); i++) + { + if (DimensionMap[i].m_Dimension == a_Dimension) + { + return DimensionMap[i].m_String; + } + } // for i - DimensionMap[] + + // Not found + LOGWARNING("Unknown dimension: \"%i\". Setting to Overworld", static_cast(a_Dimension)); + return "Overworld"; +} + + + + + +AString DamageTypeToString(eDamageType a_DamageType) +{ + // Make sure to keep this alpha-sorted. + switch (a_DamageType) + { + case dtAdmin: return "dtAdmin"; + case dtAttack: return "dtAttack"; + case dtCactusContact: return "dtCactusContact"; + case dtDrowning: return "dtDrowning"; + case dtEnderPearl: return "dtEnderPearl"; + case dtFalling: return "dtFalling"; + case dtFireContact: return "dtFireContact"; + case dtInVoid: return "dtInVoid"; + case dtLavaContact: return "dtLavaContact"; + case dtLightning: return "dtLightning"; + case dtOnFire: return "dtOnFire"; + case dtPoisoning: return "dtPoisoning"; + case dtWithering: return "dtWithering"; + case dtPotionOfHarming: return "dtPotionOfHarming"; + case dtRangedAttack: return "dtRangedAttack"; + case dtStarving: return "dtStarving"; + case dtSuffocating: return "dtSuffocation"; + case dtExplosion: return "dtExplosion"; + } + UNREACHABLE("Unsupported damage type"); +} + + + + + +eDamageType StringToDamageType(const AString & a_DamageTypeString) +{ + // First try decoding as a number: + int res; + if (!StringToInteger(a_DamageTypeString, res)) + { + // It was a valid number + return static_cast(res); + } + + // Decode using a built-in map: + static struct + { + eDamageType m_DamageType; + const char * m_String; + } DamageTypeMap [] = + { + // Cannonical names: + { dtAttack, "dtAttack"}, + { dtRangedAttack, "dtRangedAttack"}, + { dtLightning, "dtLightning"}, + { dtFalling, "dtFalling"}, + { dtDrowning, "dtDrowning"}, + { dtSuffocating, "dtSuffocation"}, + { dtStarving, "dtStarving"}, + { dtCactusContact, "dtCactusContact"}, + { dtLavaContact, "dtLavaContact"}, + { dtPoisoning, "dtPoisoning"}, + { dtWithering, "dtWithering"}, + { dtOnFire, "dtOnFire"}, + { dtFireContact, "dtFireContact"}, + { dtInVoid, "dtInVoid"}, + { dtPotionOfHarming, "dtPotionOfHarming"}, + { dtAdmin, "dtAdmin"}, + { dtExplosion, "dtExplosion"}, + + // Common synonyms: + { dtAttack, "dtPawnAttack"}, + { dtAttack, "dtEntityAttack"}, + { dtAttack, "dtMob"}, + { dtAttack, "dtMobAttack"}, + { dtRangedAttack, "dtArrowAttack"}, + { dtRangedAttack, "dtArrow"}, + { dtRangedAttack, "dtProjectile"}, + { dtFalling, "dtFall"}, + { dtDrowning, "dtDrown"}, + { dtSuffocating, "dtSuffocation"}, + { dtStarving, "dtStarvation"}, + { dtStarving, "dtHunger"}, + { dtCactusContact, "dtCactus"}, + { dtCactusContact, "dtCactuses"}, + { dtCactusContact, "dtCacti"}, + { dtLavaContact, "dtLava"}, + { dtPoisoning, "dtPoison"}, + { dtWithering, "dtWither"}, + { dtOnFire, "dtBurning"}, + { dtFireContact, "dtInFire"}, + { dtAdmin, "dtPlugin"}, + } ; + for (size_t i = 0; i < ARRAYCOUNT(DamageTypeMap); i++) + { + if (NoCaseCompare(DamageTypeMap[i].m_String, a_DamageTypeString) == 0) + { + return DamageTypeMap[i].m_DamageType; + } + } // for i - DamageTypeMap[] + + // Not found: + return static_cast(-1); +} + + + + + +void AddFaceDirection(int & a_BlockX, int & a_BlockY, int & a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse) +{ + if (!a_bInverse) + { + switch (a_BlockFace) + { + case BLOCK_FACE_YP: a_BlockY++; break; + case BLOCK_FACE_YM: a_BlockY--; break; + case BLOCK_FACE_ZM: a_BlockZ--; break; + case BLOCK_FACE_ZP: a_BlockZ++; break; + case BLOCK_FACE_XP: a_BlockX++; break; + case BLOCK_FACE_XM: a_BlockX--; break; + case BLOCK_FACE_NONE: + { + LOGWARNING("%s: Unknown face: %d", __FUNCTION__, a_BlockFace); + ASSERT(!"AddFaceDirection(): Unknown face"); + break; + } + } + } + else + { + switch (a_BlockFace) + { + case BLOCK_FACE_YP: a_BlockY--; break; + case BLOCK_FACE_YM: a_BlockY++; break; + case BLOCK_FACE_ZM: a_BlockZ++; break; + case BLOCK_FACE_ZP: a_BlockZ--; break; + case BLOCK_FACE_XP: a_BlockX--; break; + case BLOCK_FACE_XM: a_BlockX++; break; + case BLOCK_FACE_NONE: + { + LOGWARNING("%s: Unknown inv face: %d", __FUNCTION__, a_BlockFace); + ASSERT(!"AddFaceDirection(): Unknown face"); + break; + } + } + } +} + + + + + +bool ItemCategory::IsPickaxe(short a_ItemType) +{ + switch (a_ItemType) + { + case E_ITEM_WOODEN_PICKAXE: + case E_ITEM_STONE_PICKAXE: + case E_ITEM_IRON_PICKAXE: + case E_ITEM_GOLD_PICKAXE: + case E_ITEM_DIAMOND_PICKAXE: + { + return true; + } + default: + { + return false; + } + } +} + + + + + +bool ItemCategory::IsAxe(short a_ItemType) +{ + switch (a_ItemType) + { + case E_ITEM_WOODEN_AXE: + case E_ITEM_STONE_AXE: + case E_ITEM_IRON_AXE: + case E_ITEM_GOLD_AXE: + case E_ITEM_DIAMOND_AXE: + { + return true; + } + default: + { + return false; + } + } +} + + + + + +bool ItemCategory::IsSword(short a_ItemID) +{ + return (a_ItemID == E_ITEM_WOODEN_SWORD) + || (a_ItemID == E_ITEM_STONE_SWORD) + || (a_ItemID == E_ITEM_IRON_SWORD) + || (a_ItemID == E_ITEM_GOLD_SWORD) + || (a_ItemID == E_ITEM_DIAMOND_SWORD); +} + + + + + +bool ItemCategory::IsHoe(short a_ItemID) +{ + return (a_ItemID == E_ITEM_WOODEN_HOE) + || (a_ItemID == E_ITEM_STONE_HOE) + || (a_ItemID == E_ITEM_IRON_HOE) + || (a_ItemID == E_ITEM_GOLD_HOE) + || (a_ItemID == E_ITEM_DIAMOND_HOE); +} + + + + + +bool ItemCategory::IsShovel(short a_ItemID) +{ + return (a_ItemID == E_ITEM_WOODEN_SHOVEL) + || (a_ItemID == E_ITEM_STONE_SHOVEL) + || (a_ItemID == E_ITEM_IRON_SHOVEL) + || (a_ItemID == E_ITEM_GOLD_SHOVEL) + || (a_ItemID == E_ITEM_DIAMOND_SHOVEL); +} + + + + + +bool ItemCategory::IsTool(short a_ItemID) +{ + return IsPickaxe( a_ItemID) + || IsAxe ( a_ItemID) + || IsSword ( a_ItemID) + || IsHoe ( a_ItemID) + || IsShovel ( a_ItemID); +} + + + + + +bool ItemCategory::IsHelmet(short a_ItemType) +{ + return ( + (a_ItemType == E_ITEM_LEATHER_CAP) || + (a_ItemType == E_ITEM_GOLD_HELMET) || + (a_ItemType == E_ITEM_CHAIN_HELMET) || + (a_ItemType == E_ITEM_IRON_HELMET) || + (a_ItemType == E_ITEM_DIAMOND_HELMET) + ); +} + + + + + +bool ItemCategory::IsChestPlate(short a_ItemType) +{ + return ( + (a_ItemType == E_ITEM_LEATHER_TUNIC) || + (a_ItemType == E_ITEM_GOLD_CHESTPLATE) || + (a_ItemType == E_ITEM_CHAIN_CHESTPLATE) || + (a_ItemType == E_ITEM_IRON_CHESTPLATE) || + (a_ItemType == E_ITEM_DIAMOND_CHESTPLATE) + ); +} + + + + + +bool ItemCategory::IsLeggings(short a_ItemType) +{ + return ( + (a_ItemType == E_ITEM_LEATHER_PANTS) || + (a_ItemType == E_ITEM_GOLD_LEGGINGS) || + (a_ItemType == E_ITEM_CHAIN_LEGGINGS) || + (a_ItemType == E_ITEM_IRON_LEGGINGS) || + (a_ItemType == E_ITEM_DIAMOND_LEGGINGS) + ); +} + + + + + +bool ItemCategory::IsBoots(short a_ItemType) +{ + return ( + (a_ItemType == E_ITEM_LEATHER_BOOTS) || + (a_ItemType == E_ITEM_GOLD_BOOTS) || + (a_ItemType == E_ITEM_CHAIN_BOOTS) || + (a_ItemType == E_ITEM_IRON_BOOTS) || + (a_ItemType == E_ITEM_DIAMOND_BOOTS) + ); +} + + + + + +bool ItemCategory::IsMinecart(short a_ItemType) +{ + return ( + (a_ItemType == E_ITEM_MINECART) || + (a_ItemType == E_ITEM_CHEST_MINECART) || + (a_ItemType == E_ITEM_FURNACE_MINECART) || + (a_ItemType == E_ITEM_MINECART_WITH_TNT) || + (a_ItemType == E_ITEM_MINECART_WITH_HOPPER) + ); +} + + + + + +bool ItemCategory::IsArmor(short a_ItemType) +{ + return ( + IsHelmet(a_ItemType) || + IsChestPlate(a_ItemType) || + IsLeggings(a_ItemType) || + IsBoots(a_ItemType) + ); +} + + + + + +bool ItemCategory::IsHorseArmor(short a_ItemType) +{ + switch (a_ItemType) + { + case E_ITEM_IRON_HORSE_ARMOR: + case E_ITEM_GOLD_HORSE_ARMOR: + case E_ITEM_DIAMOND_HORSE_ARMOR: + { + return true; + } + default: + { + return false; + } + } +} diff --git a/src/Defines.h b/src/Defines.h index 1b17b6913..b7fd570b4 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -238,674 +238,194 @@ enum eSkinPart - -inline const char * ClickActionToString(int a_ClickAction) -{ - switch (a_ClickAction) - { - case caLeftClick: return "caLeftClick"; - case caRightClick: return "caRightClick"; - case caShiftLeftClick: return "caShiftLeftClick"; - case caShiftRightClick: return "caShiftRightClick"; - case caNumber1: return "caNumber1"; - case caNumber2: return "caNumber2"; - case caNumber3: return "caNumber3"; - case caNumber4: return "caNumber4"; - case caNumber5: return "caNumber5"; - case caNumber6: return "caNumber6"; - case caNumber7: return "caNumber7"; - case caNumber8: return "caNumber8"; - case caNumber9: return "caNumber9"; - case caMiddleClick: return "caMiddleClick"; - case caDropKey: return "caDropKey"; - case caCtrlDropKey: return "caCtrlDropKey"; - case caLeftClickOutside: return "caLeftClickOutside"; - case caRightClickOutside: return "caRightClickOutside"; - case caLeftClickOutsideHoldNothing: return "caLeftClickOutsideHoldNothing"; - case caRightClickOutsideHoldNothing: return "caRightClickOutsideHoldNothing"; - case caLeftPaintBegin: return "caLeftPaintBegin"; - case caRightPaintBegin: return "caRightPaintBegin"; - case caMiddlePaintBegin: return "caMiddlePaintBegin"; - case caLeftPaintProgress: return "caLeftPaintProgress"; - case caRightPaintProgress: return "caRightPaintProgress"; - case caMiddlePaintProgress: return "caMiddlePaintProgress"; - case caLeftPaintEnd: return "caLeftPaintEnd"; - case caRightPaintEnd: return "caRightPaintEnd"; - case caMiddlePaintEnd: return "caMiddlePaintEnd"; - case caDblClick: return "caDblClick"; - - case caUnknown: return "caUnknown"; - } - UNREACHABLE("Unknown click action"); -} - - - - - -/** Returns a blockface mirrored around the Y axis (doesn't change up / down). */ -inline eBlockFace MirrorBlockFaceY(eBlockFace a_BlockFace) -{ - switch (a_BlockFace) - { - case BLOCK_FACE_XM: return BLOCK_FACE_XP; - case BLOCK_FACE_XP: return BLOCK_FACE_XM; - case BLOCK_FACE_ZM: return BLOCK_FACE_ZP; - case BLOCK_FACE_ZP: return BLOCK_FACE_ZM; - case BLOCK_FACE_NONE: - case BLOCK_FACE_YM: - case BLOCK_FACE_YP: - { - return a_BlockFace; - } - } - UNREACHABLE("Unsupported block face"); -} - - - - - -/** Returns a blockface rotated around the Y axis counter-clockwise. */ -inline eBlockFace RotateBlockFaceCCW(eBlockFace a_BlockFace) -{ - switch (a_BlockFace) - { - case BLOCK_FACE_XM: return BLOCK_FACE_ZP; - case BLOCK_FACE_XP: return BLOCK_FACE_ZM; - case BLOCK_FACE_ZM: return BLOCK_FACE_XM; - case BLOCK_FACE_ZP: return BLOCK_FACE_XP; - case BLOCK_FACE_NONE: - case BLOCK_FACE_YM: - case BLOCK_FACE_YP: - { - return a_BlockFace; - } - } - UNREACHABLE("Unsupported block face"); -} - - - - - -inline eBlockFace RotateBlockFaceCW(eBlockFace a_BlockFace) -{ - switch (a_BlockFace) - { - case BLOCK_FACE_XM: return BLOCK_FACE_ZM; - case BLOCK_FACE_XP: return BLOCK_FACE_ZP; - case BLOCK_FACE_ZM: return BLOCK_FACE_XP; - case BLOCK_FACE_ZP: return BLOCK_FACE_XM; - case BLOCK_FACE_NONE: - case BLOCK_FACE_YM: - case BLOCK_FACE_YP: - { - return a_BlockFace; - } - } - UNREACHABLE("Unsupported block face"); -} - - - - - -inline eBlockFace ReverseBlockFace(eBlockFace a_BlockFace) -{ - switch (a_BlockFace) - { - case BLOCK_FACE_YP: return BLOCK_FACE_YM; - case BLOCK_FACE_XP: return BLOCK_FACE_XM; - case BLOCK_FACE_ZP: return BLOCK_FACE_ZM; - case BLOCK_FACE_YM: return BLOCK_FACE_YP; - case BLOCK_FACE_XM: return BLOCK_FACE_XP; - case BLOCK_FACE_ZM: return BLOCK_FACE_ZP; - case BLOCK_FACE_NONE: return a_BlockFace; - } - UNREACHABLE("Unsupported block face"); -} - - - - - -/** Returns the textual representation of the BlockFace constant. */ -inline AString BlockFaceToString(eBlockFace a_BlockFace) -{ - switch (a_BlockFace) - { - case BLOCK_FACE_XM: return "BLOCK_FACE_XM"; - case BLOCK_FACE_XP: return "BLOCK_FACE_XP"; - case BLOCK_FACE_YM: return "BLOCK_FACE_YM"; - case BLOCK_FACE_YP: return "BLOCK_FACE_YP"; - case BLOCK_FACE_ZM: return "BLOCK_FACE_ZM"; - case BLOCK_FACE_ZP: return "BLOCK_FACE_ZP"; - case BLOCK_FACE_NONE: return "BLOCK_FACE_NONE"; - } - UNREACHABLE("Unsupported block face"); -} - - - - - -inline bool IsValidBlock(int a_BlockType) -{ - if ( - ( - (a_BlockType > -1) && - (a_BlockType <= E_BLOCK_MAX_TYPE_ID) - ) || - (a_BlockType == 255) // the blocks 253-254 don't exist yet -> https://minecraft.gamepedia.com/Data_values#Block_IDs - ) - { - return true; - } - return false; -} - - - - - -inline bool IsValidItem(int a_ItemType) +/** Dimension of a world */ +enum eDimension { - if ( - ((a_ItemType >= E_ITEM_FIRST) && (a_ItemType <= E_ITEM_MAX_CONSECUTIVE_TYPE_ID)) || // Basic items range - ((a_ItemType >= E_ITEM_FIRST_DISC) && (a_ItemType <= E_ITEM_LAST_DISC)) // Music discs' special range - ) - { - return true; - } - - if (a_ItemType == 0) - { - return false; - } - - return IsValidBlock(a_ItemType); -} - -// tolua_end - - - - - -inline bool IsBlockWater(BLOCKTYPE a_BlockType) -{ - return ((a_BlockType == E_BLOCK_WATER) || (a_BlockType == E_BLOCK_STATIONARY_WATER)); -} - - - - - -inline bool IsBlockIce(BLOCKTYPE a_BlockType) -{ - switch (a_BlockType) - { - case E_BLOCK_ICE: - case E_BLOCK_PACKED_ICE: - case E_BLOCK_FROSTED_ICE: - { - return true; - } - default: - { - return false; - } - } -} - - - - - -inline bool IsBlockWaterOrIce(BLOCKTYPE a_BlockType) -{ - return (IsBlockWater(a_BlockType) || IsBlockIce(a_BlockType)); -} - - - - - -inline bool IsBlockLava(BLOCKTYPE a_BlockType) -{ - return ((a_BlockType == E_BLOCK_LAVA) || (a_BlockType == E_BLOCK_STATIONARY_LAVA)); -} - - - - - -inline bool IsBlockLiquid(BLOCKTYPE a_BlockType) -{ - return IsBlockWater(a_BlockType) || IsBlockLava(a_BlockType); -} - - - - -inline bool IsBlockRail(BLOCKTYPE a_BlockType) -{ - switch (a_BlockType) - { - case E_BLOCK_RAIL: - case E_BLOCK_ACTIVATOR_RAIL: - case E_BLOCK_DETECTOR_RAIL: - case E_BLOCK_POWERED_RAIL: - { - return true; - } - default: return false; - } -} - - - - - -inline bool IsBlockTypeOfDirt(BLOCKTYPE a_BlockType) -{ - switch (a_BlockType) - { - case E_BLOCK_DIRT: - case E_BLOCK_GRASS: - case E_BLOCK_FARMLAND: - case E_BLOCK_GRASS_PATH: - { - return true; - } - } - return false; -} - - - - -inline bool IsBlockFence(BLOCKTYPE a_BlockType) -{ - switch (a_BlockType) - { - case E_BLOCK_ACACIA_FENCE: - case E_BLOCK_ACACIA_FENCE_GATE: - case E_BLOCK_BIRCH_FENCE: - case E_BLOCK_BIRCH_FENCE_GATE: - case E_BLOCK_COBBLESTONE_WALL: - case E_BLOCK_DARK_OAK_FENCE: - case E_BLOCK_DARK_OAK_FENCE_GATE: - case E_BLOCK_FENCE: - case E_BLOCK_JUNGLE_FENCE: - case E_BLOCK_JUNGLE_FENCE_GATE: - case E_BLOCK_NETHER_BRICK_FENCE: - case E_BLOCK_OAK_FENCE_GATE: - case E_BLOCK_SPRUCE_FENCE: - case E_BLOCK_SPRUCE_FENCE_GATE: - { - return true; - } - default: - { - return false; - } - } -} - - - - - -inline bool IsBlockMaterialWood(BLOCKTYPE a_BlockType) -{ - switch (a_BlockType) - { - case E_BLOCK_PLANKS: - case E_BLOCK_LOG: - case E_BLOCK_NOTE_BLOCK: - case E_BLOCK_BOOKCASE: - case E_BLOCK_OAK_WOOD_STAIRS: - case E_BLOCK_CHEST: - case E_BLOCK_CRAFTING_TABLE: - case E_BLOCK_SIGN_POST: - case E_BLOCK_OAK_DOOR: - case E_BLOCK_WALLSIGN: - case E_BLOCK_WOODEN_PRESSURE_PLATE: - case E_BLOCK_JUKEBOX: - case E_BLOCK_FENCE: - case E_BLOCK_TRAPDOOR: - case E_BLOCK_HUGE_BROWN_MUSHROOM: - case E_BLOCK_HUGE_RED_MUSHROOM: - case E_BLOCK_OAK_FENCE_GATE: - case E_BLOCK_DOUBLE_WOODEN_SLAB: - case E_BLOCK_WOODEN_SLAB: - case E_BLOCK_SPRUCE_WOOD_STAIRS: - case E_BLOCK_BIRCH_WOOD_STAIRS: - case E_BLOCK_JUNGLE_WOOD_STAIRS: - case E_BLOCK_TRAPPED_CHEST: - case E_BLOCK_DAYLIGHT_SENSOR: - case E_BLOCK_NEW_LOG: - case E_BLOCK_ACACIA_WOOD_STAIRS: - case E_BLOCK_DARK_OAK_WOOD_STAIRS: - case E_BLOCK_STANDING_BANNER: - case E_BLOCK_WALL_BANNER: - case E_BLOCK_INVERTED_DAYLIGHT_SENSOR: - case E_BLOCK_SPRUCE_FENCE_GATE: - case E_BLOCK_BIRCH_FENCE_GATE: - case E_BLOCK_JUNGLE_FENCE_GATE: - case E_BLOCK_DARK_OAK_FENCE_GATE: - case E_BLOCK_ACACIA_FENCE_GATE: - case E_BLOCK_SPRUCE_FENCE: - case E_BLOCK_BIRCH_FENCE: - case E_BLOCK_JUNGLE_FENCE: - case E_BLOCK_DARK_OAK_FENCE: - case E_BLOCK_ACACIA_FENCE: - case E_BLOCK_SPRUCE_DOOR: - case E_BLOCK_BIRCH_DOOR: - case E_BLOCK_JUNGLE_DOOR: - case E_BLOCK_ACACIA_DOOR: - case E_BLOCK_DARK_OAK_DOOR: - { - return true; - } - default: - { - return false; - } - } -} - - - - - -inline bool IsBlockMaterialPlants(BLOCKTYPE a_BlockType) -{ - switch (a_BlockType) - { - case E_BLOCK_SAPLING: - case E_BLOCK_DANDELION: - case E_BLOCK_FLOWER: - case E_BLOCK_BROWN_MUSHROOM: - case E_BLOCK_RED_MUSHROOM: - case E_BLOCK_CROPS: - case E_BLOCK_REEDS: - case E_BLOCK_PUMPKIN_STEM: - case E_BLOCK_MELON_STEM: - case E_BLOCK_LILY_PAD: - case E_BLOCK_NETHER_WART: - case E_BLOCK_COCOA_POD: - case E_BLOCK_CARROTS: - case E_BLOCK_POTATOES: - case E_BLOCK_CHORUS_PLANT: - case E_BLOCK_CHORUS_FLOWER: - case E_BLOCK_BEETROOTS: - { - return true; - } - default: - { - return false; - } - } -} - - - - - -inline bool IsBlockMaterialVine(BLOCKTYPE a_BlockType) -{ - switch (a_BlockType) - { - case E_BLOCK_TALL_GRASS: - case E_BLOCK_DEAD_BUSH: - case E_BLOCK_VINES: - case E_BLOCK_BIG_FLOWER: - { - return true; - } - default: - { - return false; - } - } -} - - - - - -inline bool IsBlockMaterialIron(BLOCKTYPE a_BlockType) -{ - switch (a_BlockType) - { - case E_BLOCK_LAPIS_BLOCK: - case E_BLOCK_GOLD_BLOCK: - case E_BLOCK_IRON_BLOCK: - case E_BLOCK_DIAMOND_BLOCK: - case E_BLOCK_IRON_DOOR: - case E_BLOCK_IRON_BARS: - case E_BLOCK_BREWING_STAND: - case E_BLOCK_CAULDRON: - case E_BLOCK_EMERALD_BLOCK: - case E_BLOCK_COMMAND_BLOCK: - case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: - case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: - case E_BLOCK_BLOCK_OF_REDSTONE: - case E_BLOCK_HOPPER: - case E_BLOCK_IRON_TRAPDOOR: - case E_BLOCK_REPEATING_COMMAND_BLOCK: - case E_BLOCK_CHAIN_COMMAND_BLOCK: - case E_BLOCK_STRUCTURE_BLOCK: - { - return true; - } - default: - { - return false; - } - } -} + dimNether = -1, + dimOverworld = 0, + dimEnd = 1, + dimNotSet = 255, // For things that need an "indeterminate" state, such as cProtocol's LastSentDimension +} ; -inline bool IsBlockMaterialAnvil(BLOCKTYPE a_BlockType) -{ - return (a_BlockType == E_BLOCK_ANVIL); -} +/** Damage type, used in the TakeDamageInfo structure and related functions */ +enum eDamageType +{ + // Canonical names for the types (as documented in the plugin wiki): + dtAttack, // Being attacked by a mob + dtRangedAttack, // Being attacked by a projectile, possibly from a mob + dtLightning, // Hit by a lightning strike + dtFalling, // Falling down; dealt when hitting the ground + dtDrowning, // Drowning in water / lava + dtSuffocating, // Suffocating inside a block + dtStarving, // Hunger + dtCactusContact, // Contact with a cactus block + dtLavaContact, // Contact with a lava block + dtPoisoning, // Having the poison effect + dtWithering, // Having the wither effect + dtOnFire, // Being on fire + dtFireContact, // Standing inside a fire block + dtInVoid, // Falling into the Void (Y < 0) + dtPotionOfHarming, + dtEnderPearl, // Thrown an ender pearl, teleported by it + dtAdmin, // Damage applied by an admin command + dtExplosion, // Damage applied by an explosion + + // Some common synonyms: + dtPawnAttack = dtAttack, + dtEntityAttack = dtAttack, + dtMob = dtAttack, + dtMobAttack = dtAttack, + dtArrowAttack = dtRangedAttack, + dtArrow = dtRangedAttack, + dtProjectile = dtRangedAttack, + dtFall = dtFalling, + dtDrown = dtDrowning, + dtSuffocation = dtSuffocating, + dtStarvation = dtStarving, + dtHunger = dtStarving, + dtCactus = dtCactusContact, + dtCactuses = dtCactusContact, + dtCacti = dtCactusContact, + dtLava = dtLavaContact, + dtPoison = dtPoisoning, + dtWither = dtWithering, + dtBurning = dtOnFire, + dtInFire = dtFireContact, + dtPlugin = dtAdmin, +} ; -inline bool IsBlocksWeb(BLOCKTYPE a_BlockType) -{ - return (a_BlockType == E_BLOCK_COBWEB); -} +/** The source of an explosion. +Also dictates the type of the additional data passed to the explosion handlers: +| esBed | Vector3i * | Bed exploding in the Nether or in the End +| esEnderCrystal | cEnderCrystal * | +| esGhastFireball | cGhastFireballEntity * | +| esMonster | cMonster * | +| esOther | nullptr | Any other explosion unaccounted for +| esPlugin | nullptr | Explosion primarily attributed to a plugin +| esPrimedTNT | cTNTEntity * | +| esWitherBirth | cMonster * | +| esWitherSkull | cProjectileEntity * | +*/ +enum eExplosionSource +{ + esBed, + esEnderCrystal, + esGhastFireball, + esMonster, + esOther, + esPlugin, + esPrimedTNT, + esWitherBirth, + esWitherSkull, + esMax, +} ; -inline bool IsBlockMaterialLeaves(BLOCKTYPE a_BlockType) +enum eShrapnelLevel { - return (a_BlockType == E_BLOCK_LEAVES) || (a_BlockType == E_BLOCK_NEW_LEAVES); -} + slNone, + slGravityAffectedOnly, + slAll +} ; -inline bool IsBlocksWool(BLOCKTYPE a_BlockType) +enum eSpreadSource { - return (a_BlockType == E_BLOCK_WOOL); -} + ssFireSpread, + ssGrassSpread, + ssMushroomSpread, + ssMycelSpread, + ssVineSpread, +} ; -inline bool IsBlockMaterialGourd(BLOCKTYPE a_BlockType) +enum eMessageType { - switch (a_BlockType) - { - case E_BLOCK_PUMPKIN: - case E_BLOCK_JACK_O_LANTERN: - case E_BLOCK_MELON: - { - return true; - } - default: - { - return false; - } - } -} + // https://forum.cuberite.org/thread-1212.html + // MessageType... + mtCustom, // Send raw data without any processing + mtFailure, // Something could not be done (i.e. command not executed due to insufficient privilege) + mtInformation, // Informational message (i.e. command usage) + mtSuccess, // Something executed successfully + mtWarning, // Something concerning (i.e. reload) is about to happen + mtFatal, // Something catastrophic occured (i.e. plugin crash) + mtDeath, // Denotes death of player + mtPrivateMessage, // Player to player messaging identifier + mtJoin, // A player has joined the server + mtLeave, // A player has left the server + mtMaxPlusOne, // The first invalid type, used for checking on LuaAPI boundaries + // Common aliases: + mtFail = mtFailure, + mtError = mtFailure, + mtInfo = mtInformation, + mtPM = mtPrivateMessage, +}; -inline bool IsBlockMaterialCoral(BLOCKTYPE a_BlockType) -{ - return false; // yes, there is no block in minecraft which belongs to this type. -} +/** Returns a textual representation of the click action. */ +const char * ClickActionToString(int a_ClickAction); +/** Returns a blockface mirrored around the Y axis (doesn't change up / down). */ +eBlockFace MirrorBlockFaceY(eBlockFace a_BlockFace); +/** Returns a blockface rotated around the Y axis counter-clockwise. */ +eBlockFace RotateBlockFaceCCW(eBlockFace a_BlockFace); -inline bool IsBlockMaterialRock(BLOCKTYPE a_BlockType) -{ - switch (a_BlockType) - { - case E_BLOCK_STONE: - case E_BLOCK_COBBLESTONE: - case E_BLOCK_BEDROCK: - case E_BLOCK_GOLD_ORE: - case E_BLOCK_IRON_ORE: - case E_BLOCK_COAL_ORE: - case E_BLOCK_LAPIS_ORE: - case E_BLOCK_DISPENSER: - case E_BLOCK_SANDSTONE: - case E_BLOCK_DOUBLE_STONE_SLAB: - case E_BLOCK_STONE_SLAB: - case E_BLOCK_BRICK: - case E_BLOCK_MOSSY_COBBLESTONE: - case E_BLOCK_OBSIDIAN: - case E_BLOCK_MOB_SPAWNER: - case E_BLOCK_DIAMOND_ORE: - case E_BLOCK_FURNACE: - case E_BLOCK_LIT_FURNACE: - case E_BLOCK_COBBLESTONE_STAIRS: - case E_BLOCK_STONE_PRESSURE_PLATE: - case E_BLOCK_REDSTONE_ORE: - case E_BLOCK_REDSTONE_ORE_GLOWING: - case E_BLOCK_NETHERRACK: - case E_BLOCK_STONE_BRICKS: - case E_BLOCK_BRICK_STAIRS: - case E_BLOCK_STONE_BRICK_STAIRS: - case E_BLOCK_NETHER_BRICK: - case E_BLOCK_NETHER_BRICK_FENCE: - case E_BLOCK_NETHER_BRICK_STAIRS: - case E_BLOCK_ENCHANTMENT_TABLE: - case E_BLOCK_END_PORTAL_FRAME: - case E_BLOCK_END_STONE: - case E_BLOCK_SANDSTONE_STAIRS: - case E_BLOCK_EMERALD_ORE: - case E_BLOCK_ENDER_CHEST: - case E_BLOCK_COBBLESTONE_WALL: - case E_BLOCK_NETHER_QUARTZ_ORE: - case E_BLOCK_QUARTZ_BLOCK: - case E_BLOCK_QUARTZ_STAIRS: - case E_BLOCK_DROPPER: - case E_BLOCK_STAINED_CLAY: - case E_BLOCK_PRISMARINE_BLOCK: - case E_BLOCK_HARDENED_CLAY: - case E_BLOCK_BLOCK_OF_COAL: - case E_BLOCK_RED_SANDSTONE: - case E_BLOCK_RED_SANDSTONE_STAIRS: - case E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB: - case E_BLOCK_RED_SANDSTONE_SLAB: - case E_BLOCK_PURPUR_BLOCK: - case E_BLOCK_PURPUR_PILLAR: - case E_BLOCK_PURPUR_STAIRS: - case E_BLOCK_PURPUR_DOUBLE_SLAB: - case E_BLOCK_PURPUR_SLAB: - case E_BLOCK_END_BRICKS: - case E_BLOCK_MAGMA: - case E_BLOCK_RED_NETHER_BRICK: - case E_BLOCK_BONE_BLOCK: - case E_BLOCK_OBSERVER: - { - return true; - } - default: - { - return false; - } - } -} +/** Returns a blockface rotated around the Y axis clockwise. */ +eBlockFace RotateBlockFaceCW(eBlockFace a_BlockFace); +/** Returns a blockface opposite to the one specified. */ +eBlockFace ReverseBlockFace(eBlockFace a_BlockFace); +/** Returns the textual representation of the BlockFace constant. */ +AString BlockFaceToString(eBlockFace a_BlockFace); +/** Returns true if the specified block type is valid (known). */ +bool IsValidBlock(int a_BlockType); +/** Returns true if the specified item type is valid (known). */ +bool IsValidItem(int a_ItemType); -inline void AddFaceDirection(int & a_BlockX, int & a_BlockY, int & a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse = false) // tolua_export -{ // tolua_export - if (!a_bInverse) - { - switch (a_BlockFace) - { - case BLOCK_FACE_YP: a_BlockY++; break; - case BLOCK_FACE_YM: a_BlockY--; break; - case BLOCK_FACE_ZM: a_BlockZ--; break; - case BLOCK_FACE_ZP: a_BlockZ++; break; - case BLOCK_FACE_XP: a_BlockX++; break; - case BLOCK_FACE_XM: a_BlockX--; break; - case BLOCK_FACE_NONE: - { - LOGWARNING("%s: Unknown face: %d", __FUNCTION__, a_BlockFace); - ASSERT(!"AddFaceDirection(): Unknown face"); - break; - } - } - } - else - { - switch (a_BlockFace) - { - case BLOCK_FACE_YP: a_BlockY--; break; - case BLOCK_FACE_YM: a_BlockY++; break; - case BLOCK_FACE_ZM: a_BlockZ++; break; - case BLOCK_FACE_ZP: a_BlockZ--; break; - case BLOCK_FACE_XP: a_BlockX--; break; - case BLOCK_FACE_XM: a_BlockX++; break; - case BLOCK_FACE_NONE: - { - LOGWARNING("%s: Unknown inv face: %d", __FUNCTION__, a_BlockFace); - ASSERT(!"AddFaceDirection(): Unknown face"); - break; - } - } - } -} // tolua_export +/** Translates a dimension string to dimension enum. Takes either a number or a dimension alias (built-in). Returns dimOverworld on failure */ +extern eDimension StringToDimension(const AString & a_DimensionString); +/** Translates a dimension enum to dimension string. +Takes an eDimension enum value and returns "Overworld" on failure. */ +extern AString DimensionToString(eDimension a_Dimension); +/** Translates damage type constant to a string representation (built-in). */ +extern AString DamageTypeToString(eDamageType a_DamageType); +/** Translates a damage type string to damage type. Takes either a number or a damage type alias (built-in). Returns -1 on failure */ +extern eDamageType StringToDamageType(const AString & a_DamageString); +/** Modifies the specified coords so that they point to the block adjacent to the one specified through its specified face. +If a_Inverse is true, the opposite direction is used instead. */ +void AddFaceDirection(int & a_BlockX, int & a_BlockY, int & a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse = false); -inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse = false) -{ - int Y = a_BlockY; - AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse); - a_BlockY = Clamp(static_cast(Y), 0, cChunkDef::Height - 1); -} +// tolua_end @@ -944,24 +464,6 @@ inline void VectorToEuler(double a_X, double a_Y, double a_Z, double & a_Pan, do -inline float GetSignf(float a_Val) -{ - return (a_Val < 0.f) ? -1.f : 1.f; -} - - - - - -inline float GetSpecialSignf( float a_Val) -{ - return (a_Val <= 0.f) ? -1.f : 1.f; -} - - - - - template inline T Diff(T a_Val1, T a_Val2) { return std::abs(a_Val1 - a_Val2); @@ -973,34 +475,6 @@ template inline T Diff(T a_Val1, T a_Val2) // tolua_begin -enum eMessageType -{ - // https://forum.cuberite.org/thread-1212.html - // MessageType... - - mtCustom, // Send raw data without any processing - mtFailure, // Something could not be done (i.e. command not executed due to insufficient privilege) - mtInformation, // Informational message (i.e. command usage) - mtSuccess, // Something executed successfully - mtWarning, // Something concerning (i.e. reload) is about to happen - mtFatal, // Something catastrophic occured (i.e. plugin crash) - mtDeath, // Denotes death of player - mtPrivateMessage, // Player to player messaging identifier - mtJoin, // A player has joined the server - mtLeave, // A player has left the server - mtMaxPlusOne, // The first invalid type, used for checking on LuaAPI boundaries - - // Common aliases: - mtFail = mtFailure, - mtError = mtFailure, - mtInfo = mtInformation, - mtPM = mtPrivateMessage, -}; - - - - - /** Normalizes an angle in degrees to the [-180, +180) range: */ inline double NormalizeAngleDegrees(const double a_Degrees) { @@ -1018,165 +492,31 @@ inline double NormalizeAngleDegrees(const double a_Degrees) namespace ItemCategory { - inline bool IsPickaxe(short a_ItemID) - { - return (a_ItemID == E_ITEM_WOODEN_PICKAXE) - || (a_ItemID == E_ITEM_STONE_PICKAXE) - || (a_ItemID == E_ITEM_IRON_PICKAXE) - || (a_ItemID == E_ITEM_GOLD_PICKAXE) - || (a_ItemID == E_ITEM_DIAMOND_PICKAXE); - } + bool IsPickaxe(short a_ItemType); + bool IsAxe(short a_ItemType); + bool IsSword(short a_ItemType); - inline bool IsAxe(short a_ItemID) - { - return (a_ItemID == E_ITEM_WOODEN_AXE) - || (a_ItemID == E_ITEM_STONE_AXE) - || (a_ItemID == E_ITEM_IRON_AXE) - || (a_ItemID == E_ITEM_GOLD_AXE) - || (a_ItemID == E_ITEM_DIAMOND_AXE); - } + bool IsHoe(short a_ItemType); + bool IsShovel(short a_ItemType); + bool IsTool(short a_ItemType); - inline bool IsSword(short a_ItemID) - { - return (a_ItemID == E_ITEM_WOODEN_SWORD) - || (a_ItemID == E_ITEM_STONE_SWORD) - || (a_ItemID == E_ITEM_IRON_SWORD) - || (a_ItemID == E_ITEM_GOLD_SWORD) - || (a_ItemID == E_ITEM_DIAMOND_SWORD); - } - + bool IsHelmet(short a_ItemType); + bool IsChestPlate(short a_ItemType); - inline bool IsHoe(short a_ItemID) - { - return (a_ItemID == E_ITEM_WOODEN_HOE) - || (a_ItemID == E_ITEM_STONE_HOE) - || (a_ItemID == E_ITEM_IRON_HOE) - || (a_ItemID == E_ITEM_GOLD_HOE) - || (a_ItemID == E_ITEM_DIAMOND_HOE); - } + bool IsLeggings(short a_ItemType); + bool IsBoots(short a_ItemType); + bool IsMinecart(short a_ItemType); - inline bool IsShovel(short a_ItemID) - { - return (a_ItemID == E_ITEM_WOODEN_SHOVEL) - || (a_ItemID == E_ITEM_STONE_SHOVEL) - || (a_ItemID == E_ITEM_IRON_SHOVEL) - || (a_ItemID == E_ITEM_GOLD_SHOVEL) - || (a_ItemID == E_ITEM_DIAMOND_SHOVEL); - } + bool IsArmor(short a_ItemType); - - - inline bool IsTool(short a_ItemID) - { - return IsPickaxe( a_ItemID) - || IsAxe ( a_ItemID) - || IsSword ( a_ItemID) - || IsHoe ( a_ItemID) - || IsShovel ( a_ItemID); - } - - - - inline bool IsHelmet(short a_ItemType) - { - return ( - (a_ItemType == E_ITEM_LEATHER_CAP) || - (a_ItemType == E_ITEM_GOLD_HELMET) || - (a_ItemType == E_ITEM_CHAIN_HELMET) || - (a_ItemType == E_ITEM_IRON_HELMET) || - (a_ItemType == E_ITEM_DIAMOND_HELMET) - ); - } - - - - inline bool IsChestPlate(short a_ItemType) - { - return ( - (a_ItemType == E_ITEM_LEATHER_TUNIC) || - (a_ItemType == E_ITEM_GOLD_CHESTPLATE) || - (a_ItemType == E_ITEM_CHAIN_CHESTPLATE) || - (a_ItemType == E_ITEM_IRON_CHESTPLATE) || - (a_ItemType == E_ITEM_DIAMOND_CHESTPLATE) - ); - } - - - - inline bool IsLeggings(short a_ItemType) - { - return ( - (a_ItemType == E_ITEM_LEATHER_PANTS) || - (a_ItemType == E_ITEM_GOLD_LEGGINGS) || - (a_ItemType == E_ITEM_CHAIN_LEGGINGS) || - (a_ItemType == E_ITEM_IRON_LEGGINGS) || - (a_ItemType == E_ITEM_DIAMOND_LEGGINGS) - ); - } - - - - inline bool IsBoots(short a_ItemType) - { - return ( - (a_ItemType == E_ITEM_LEATHER_BOOTS) || - (a_ItemType == E_ITEM_GOLD_BOOTS) || - (a_ItemType == E_ITEM_CHAIN_BOOTS) || - (a_ItemType == E_ITEM_IRON_BOOTS) || - (a_ItemType == E_ITEM_DIAMOND_BOOTS) - ); - } - - - - inline bool IsMinecart(short a_ItemType) - { - return ( - (a_ItemType == E_ITEM_MINECART) || - (a_ItemType == E_ITEM_CHEST_MINECART) || - (a_ItemType == E_ITEM_FURNACE_MINECART) || - (a_ItemType == E_ITEM_MINECART_WITH_TNT) || - (a_ItemType == E_ITEM_MINECART_WITH_HOPPER) - ); - } - - - - inline bool IsArmor(short a_ItemType) - { - return ( - IsHelmet(a_ItemType) || - IsChestPlate(a_ItemType) || - IsLeggings(a_ItemType) || - IsBoots(a_ItemType) - ); - } - - - - inline bool IsHorseArmor(short a_ItemType) - { - switch (a_ItemType) - { - case E_ITEM_IRON_HORSE_ARMOR: - case E_ITEM_GOLD_HORSE_ARMOR: - case E_ITEM_DIAMOND_HORSE_ARMOR: - { - return true; - } - default: - { - return false; - } - } - } + bool IsHorseArmor(short a_ItemType); } // tolua_end diff --git a/src/Enchantments.cpp b/src/Enchantments.cpp index 1a6f72c9e..53a8212e8 100644 --- a/src/Enchantments.cpp +++ b/src/Enchantments.cpp @@ -7,6 +7,7 @@ #include "WorldStorage/FastNBT.h" #include "FastRandom.h" #include "Noise/Noise.h" +#include "BlockType.h" diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp index d0ac27228..ec6b69326 100644 --- a/src/Entities/Boat.cpp +++ b/src/Entities/Boat.cpp @@ -5,6 +5,7 @@ #include "Globals.h" #include "Boat.h" +#include "../BlockInfo.h" #include "../World.h" #include "../ClientHandle.h" #include "Player.h" diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 209c10b44..a4d33db19 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -3,6 +3,7 @@ #include "Entity.h" #include "Player.h" +#include "../BlockInfo.h" #include "../World.h" #include "../Root.h" #include "../Matrix4.h" diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp index 132acd09a..628e4d34c 100644 --- a/src/Entities/FallingBlock.cpp +++ b/src/Entities/FallingBlock.cpp @@ -1,6 +1,7 @@ #include "Globals.h" #include "FallingBlock.h" +#include "../BlockInfo.h" #include "../World.h" #include "../ClientHandle.h" #include "../Simulator/SandSimulator.h" diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp index c4c89890b..5c16446c8 100644 --- a/src/Entities/Floater.cpp +++ b/src/Entities/Floater.cpp @@ -1,6 +1,7 @@ #include "Globals.h" +#include "../BlockInfo.h" #include "../BoundingBox.h" #include "../Chunk.h" #include "Floater.h" diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index 01d89ceb4..d5e50fc41 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -7,6 +7,7 @@ #include "Globals.h" #include "Minecart.h" +#include "../BlockInfo.h" #include "../ClientHandle.h" #include "../Chunk.h" #include "Player.h" diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index dd218aec9..9481daa8c 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -3,6 +3,7 @@ #include "Pawn.h" #include "Player.h" +#include "../BlockInfo.h" #include "../World.h" #include "../Bindings/PluginManager.h" #include "../BoundingBox.h" diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index b2148fa2b..9314c875d 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -7,6 +7,7 @@ #include "../Bindings/PluginManager.h" #include "ProjectileEntity.h" +#include "../BlockInfo.h" #include "../ClientHandle.h" #include "../LineBlockTracer.h" #include "../BoundingBox.h" diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index 240248b5a..193c75554 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -30,6 +30,7 @@ reduced in complexity in order for this generator to be useful, so the caves' sh #include "Globals.h" #include "Caves.h" +#include "../BlockInfo.h" diff --git a/src/Generating/ChunkGenerator.h b/src/Generating/ChunkGenerator.h index 5fe58c65a..52c9cd896 100644 --- a/src/Generating/ChunkGenerator.h +++ b/src/Generating/ChunkGenerator.h @@ -1,5 +1,6 @@ #pragma once +#include "../Defines.h" diff --git a/src/Generating/DungeonRoomsFinisher.cpp b/src/Generating/DungeonRoomsFinisher.cpp index 768dd27cf..c595a6451 100644 --- a/src/Generating/DungeonRoomsFinisher.cpp +++ b/src/Generating/DungeonRoomsFinisher.cpp @@ -5,6 +5,7 @@ #include "Globals.h" #include "DungeonRoomsFinisher.h" +#include "../BlockInfo.h" #include "../FastRandom.h" #include "../BlockEntities/ChestEntity.h" #include "../BlockEntities/MobSpawnerEntity.h" diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 7aece7219..5b328ec49 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -14,6 +14,7 @@ #include "../Simulator/FireSimulator.h" #include "../IniFile.h" #include "../MobSpawner.h" +#include "../BlockInfo.h" diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 1f2b5c916..903ca8eab 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -10,6 +10,7 @@ uses a prefabricate in a cBlockArea for drawing itself. #include "Prefab.h" #include "../WorldStorage/SchematicFileSerializer.h" #include "ChunkDesc.h" +#include "../BlockInfo.h" diff --git a/src/Generating/RoughRavines.cpp b/src/Generating/RoughRavines.cpp index a9e9a97de..a65f57268 100644 --- a/src/Generating/RoughRavines.cpp +++ b/src/Generating/RoughRavines.cpp @@ -6,6 +6,7 @@ #include "Globals.h" #include "RoughRavines.h" +#include "../BlockInfo.h" diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp index d3bd6114e..0b45502a6 100644 --- a/src/Generating/StructGen.cpp +++ b/src/Generating/StructGen.cpp @@ -6,6 +6,7 @@ #include "Trees.h" #include "../BlockArea.h" #include "../LinearUpscale.h" +#include "../BlockInfo.h" diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index de6da5265..558b4619e 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -5,6 +5,7 @@ #include "Globals.h" #include "Trees.h" +#include "../BlockType.h" diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index c2693608d..340d9adb8 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -6,6 +6,7 @@ #include "Globals.h" #include "VillageGen.h" #include "PieceGeneratorBFSTree.h" +#include "../BlockInfo.h" diff --git a/src/Globals.h b/src/Globals.h index 890394e2e..94fc7ce27 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -404,9 +404,3 @@ using cTickTimeLong = std::chrono::duration; #include "Vector3.h" #include "BiomeDef.h" #include "ChunkDef.h" -#include "BlockID.h" -#include "BlockInfo.h" - - - - diff --git a/src/Item.cpp b/src/Item.cpp index 16aa22b50..dd8f08f02 100644 --- a/src/Item.cpp +++ b/src/Item.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Item.h" +#include "BlockType.h" #include "ItemGrid.h" #include "json/json.h" #include "Items/ItemHandler.h" @@ -12,6 +13,83 @@ +cItem::cItem(): + m_ItemType(E_ITEM_EMPTY), + m_ItemCount(0), + m_ItemDamage(0), + m_CustomName(""), + m_RepairCost(0), + m_FireworkItem(), + m_ItemColor() +{ +} + + + + + +cItem::cItem( + short a_ItemType, + char a_ItemCount, + short a_ItemDamage, + const AString & a_Enchantments, + const AString & a_CustomName, + const AStringVector & a_LoreTable +): + m_ItemType (a_ItemType), + m_ItemCount (a_ItemCount), + m_ItemDamage (a_ItemDamage), + m_Enchantments(a_Enchantments), + m_CustomName (a_CustomName), + m_LoreTable (a_LoreTable), + m_RepairCost (0), + m_FireworkItem(), + m_ItemColor() +{ + if (!IsValidItem(m_ItemType)) + { + if ((m_ItemType != E_BLOCK_AIR) && (m_ItemType != E_ITEM_EMPTY)) + { + LOGWARNING("%s: creating an invalid item type (%d), resetting to empty.", __FUNCTION__, a_ItemType); + } + Empty(); + } +} + + + + + +void cItem::Empty() +{ + m_ItemType = E_ITEM_EMPTY; + m_ItemCount = 0; + m_ItemDamage = 0; + m_Enchantments.Clear(); + m_CustomName = ""; + m_LoreTable.clear(); + m_RepairCost = 0; + m_FireworkItem.EmptyData(); + m_ItemColor.Clear(); +} + + + + + +void cItem::Clear() +{ + m_ItemType = E_ITEM_EMPTY; + m_ItemCount = 0; + m_ItemDamage = 0; + m_RepairCost = 0; + m_ItemColor.Clear(); +} + + + + + cItem cItem::CopyOne(void) const { cItem res(*this); @@ -196,7 +274,7 @@ void cItem::GetJson(Json::Value & a_OutValue) const void cItem::FromJson(const Json::Value & a_Value) { - m_ItemType = static_cast(a_Value.get("ID", -1).asInt()); + m_ItemType = static_cast(a_Value.get("ID", -1).asInt()); if (m_ItemType > 0) { m_ItemCount = static_cast(a_Value.get("Count", -1).asInt()); diff --git a/src/Item.h b/src/Item.h index 306e36b0a..175f044b5 100644 --- a/src/Item.h +++ b/src/Item.h @@ -37,17 +37,7 @@ class cItem { public: /** Creates an empty item */ - cItem(void) : - m_ItemType(E_ITEM_EMPTY), - m_ItemCount(0), - m_ItemDamage(0), - m_CustomName(""), - m_RepairCost(0), - m_FireworkItem(), - m_ItemColor() - { - } - + cItem(void); /** Creates an item of the specified type, by default 1 piece with no damage and no enchantments */ cItem( @@ -57,27 +47,7 @@ public: const AString & a_Enchantments = "", const AString & a_CustomName = "", const AStringVector & a_LoreTable = {} - ) : - m_ItemType (a_ItemType), - m_ItemCount (a_ItemCount), - m_ItemDamage (a_ItemDamage), - m_Enchantments(a_Enchantments), - m_CustomName (a_CustomName), - m_LoreTable (a_LoreTable), - m_RepairCost (0), - m_FireworkItem(), - m_ItemColor() - { - if (!IsValidItem(m_ItemType)) - { - if ((m_ItemType != E_BLOCK_AIR) && (m_ItemType != E_ITEM_EMPTY)) - { - LOGWARNING("%s: creating an invalid item type (%d), resetting to empty.", __FUNCTION__, a_ItemType); - } - Empty(); - } - } - + ); // The constructor is disabled in code, because the compiler generates it anyway, // but it needs to stay because ToLua needs to generate the binding for it @@ -88,31 +58,14 @@ public: #endif + /** Empties the item and frees up any dynamic storage used by the internals. */ + void Empty(void); - void Empty(void) - { - m_ItemType = E_ITEM_EMPTY; - m_ItemCount = 0; - m_ItemDamage = 0; - m_Enchantments.Clear(); - m_CustomName = ""; - m_LoreTable.clear(); - m_RepairCost = 0; - m_FireworkItem.EmptyData(); - m_ItemColor.Clear(); - } - - - void Clear(void) - { - m_ItemType = E_ITEM_EMPTY; - m_ItemCount = 0; - m_ItemDamage = 0; - m_RepairCost = 0; - m_ItemColor.Clear(); - } - + /** Empties the item and frees up any dynamic storage used by the internals. + TODO: What is the usage difference? Merge with Empty()? */ + void Clear(void); + /** Returns true if the item represents an empty stack - either the type is invalid, or count is zero. */ bool IsEmpty(void) const { return ((m_ItemType <= 0) || (m_ItemCount <= 0)); diff --git a/src/Items/ItemBigFlower.h b/src/Items/ItemBigFlower.h index d433c4b87..8e96ad602 100644 --- a/src/Items/ItemBigFlower.h +++ b/src/Items/ItemBigFlower.h @@ -2,6 +2,7 @@ #pragma once #include "ItemHandler.h" +#include "../BlockInfo.h" diff --git a/src/Items/ItemBottle.h b/src/Items/ItemBottle.h index 18767dcde..319bc708f 100644 --- a/src/Items/ItemBottle.h +++ b/src/Items/ItemBottle.h @@ -2,6 +2,7 @@ #pragma once #include "ItemHandler.h" +#include "../BlockInfo.h" #include "../World.h" diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 8affff6ca..7b837d449 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -2,6 +2,7 @@ #pragma once #include "ItemHandler.h" +#include "../BlockInfo.h" #include "../World.h" #include "../Simulator/FluidSimulator.h" #include "../Blocks/BlockHandler.h" @@ -70,7 +71,7 @@ public: } BLOCKTYPE Block = a_World->GetBlock(BlockPos.x, BlockPos.y, BlockPos.z); - ENUM_ITEM_ID NewItemType; + ENUM_ITEM_TYPE NewItemType; if (IsBlockWater(Block)) { diff --git a/src/Items/ItemChest.h b/src/Items/ItemChest.h index 817020a25..ac4e4b471 100644 --- a/src/Items/ItemChest.h +++ b/src/Items/ItemChest.h @@ -2,6 +2,7 @@ #pragma once #include "ItemHandler.h" +#include "../BlockInfo.h" #include "../Blocks/BlockChest.h" diff --git a/src/Items/ItemPickaxe.h b/src/Items/ItemPickaxe.h index a23e9ec6d..58df18428 100644 --- a/src/Items/ItemPickaxe.h +++ b/src/Items/ItemPickaxe.h @@ -168,7 +168,7 @@ public: virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override { - if (!IsBlockMaterialIron(a_Block) && !IsBlockMaterialAnvil(a_Block) && !IsBlockMaterialRock(a_Block)) + if (!IsBlockMaterialIron(a_Block) && (a_Block != E_BLOCK_ANVIL) && !IsBlockMaterialRock(a_Block)) { return super::GetBlockBreakingStrength(a_Block); } diff --git a/src/Items/ItemShears.h b/src/Items/ItemShears.h index 9a6baa5e1..2ceb371f4 100644 --- a/src/Items/ItemShears.h +++ b/src/Items/ItemShears.h @@ -78,11 +78,11 @@ public: virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override { - if (IsBlocksWeb(a_Block) || IsBlockMaterialLeaves(a_Block)) + if ((a_Block == E_BLOCK_COBWEB) || IsBlockMaterialLeaves(a_Block)) { return 15.0f; } - else if (IsBlocksWool(a_Block)) + else if (a_Block == E_BLOCK_WOOL) { return 5.0f; } diff --git a/src/Items/ItemSword.h b/src/Items/ItemSword.h index 06543c37e..cdb85727c 100644 --- a/src/Items/ItemSword.h +++ b/src/Items/ItemSword.h @@ -2,6 +2,7 @@ #pragma once #include "ItemHandler.h" +#include "../BlockInfo.h" @@ -12,8 +13,8 @@ class cItemSwordHandler : { typedef cItemHandler super; public: - cItemSwordHandler(int a_ItemType) - : cItemHandler(a_ItemType) + cItemSwordHandler(int a_ItemType): + cItemHandler(a_ItemType) { } @@ -66,7 +67,6 @@ public: if ( IsBlockMaterialPlants(a_Block) || IsBlockMaterialVine(a_Block) || - IsBlockMaterialCoral(a_Block) || IsBlockMaterialLeaves(a_Block) || IsBlockMaterialGourd(a_Block) ) diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index 53f6b2d86..426de86ac 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -7,6 +7,7 @@ #include "LightingThread.h" #include "ChunkMap.h" #include "World.h" +#include "BlockInfo.h" @@ -541,6 +542,33 @@ void cLightingThread::CompressLight(NIBBLETYPE * a_LightArray, NIBBLETYPE * a_Ch +void cLightingThread::PropagateLight( + NIBBLETYPE * a_Light, + unsigned int a_SrcIdx, unsigned int a_DstIdx, + size_t & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut +) +{ + ASSERT(a_SrcIdx < ARRAYCOUNT(m_SkyLight)); + ASSERT(a_DstIdx < ARRAYCOUNT(m_BlockTypes)); + + if (a_Light[a_SrcIdx] <= a_Light[a_DstIdx] + cBlockInfo::GetSpreadLightFalloff(m_BlockTypes[a_DstIdx])) + { + // We're not offering more light than the dest block already has + return; + } + + a_Light[a_DstIdx] = a_Light[a_SrcIdx] - cBlockInfo::GetSpreadLightFalloff(m_BlockTypes[a_DstIdx]); + if (!a_IsSeedOut[a_DstIdx]) + { + a_IsSeedOut[a_DstIdx] = true; + a_SeedIdxOut[a_NumSeedsOut++] = a_DstIdx; + } +} + + + + + void cLightingThread::QueueChunkStay(cLightingChunkStay & a_ChunkStay) { // Move the ChunkStay from the Pending queue to the lighting queue. diff --git a/src/LightingThread.h b/src/LightingThread.h index 6c27ff7ba..4e009fd0c 100644 --- a/src/LightingThread.h +++ b/src/LightingThread.h @@ -159,28 +159,11 @@ protected: /** Compresses from 1-block-per-byte (faster calc) into 2-blocks-per-byte (MC storage): */ void CompressLight(NIBBLETYPE * a_LightArray, NIBBLETYPE * a_ChunkLight); - inline void PropagateLight( + void PropagateLight( NIBBLETYPE * a_Light, unsigned int a_SrcIdx, unsigned int a_DstIdx, size_t & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut - ) - { - ASSERT(a_SrcIdx < ARRAYCOUNT(m_SkyLight)); - ASSERT(a_DstIdx < ARRAYCOUNT(m_BlockTypes)); - - if (a_Light[a_SrcIdx] <= a_Light[a_DstIdx] + cBlockInfo::GetSpreadLightFalloff(m_BlockTypes[a_DstIdx])) - { - // We're not offering more light than the dest block already has - return; - } - - a_Light[a_DstIdx] = a_Light[a_SrcIdx] - cBlockInfo::GetSpreadLightFalloff(m_BlockTypes[a_DstIdx]); - if (!a_IsSeedOut[a_DstIdx]) - { - a_IsSeedOut[a_DstIdx] = true; - a_SeedIdxOut[a_NumSeedsOut++] = a_DstIdx; - } - } + ); /** Queues a chunkstay that has all of its chunks loaded. Called by cLightingChunkStay when all of its chunks are loaded. */ diff --git a/src/LineBlockTracer.cpp b/src/LineBlockTracer.cpp index d8386574b..0f1d798be 100644 --- a/src/LineBlockTracer.cpp +++ b/src/LineBlockTracer.cpp @@ -5,6 +5,7 @@ #include "Globals.h" #include "LineBlockTracer.h" +#include "BlockInfo.h" #include "World.h" #include "Chunk.h" #include "BoundingBox.h" diff --git a/src/Map.cpp b/src/Map.cpp index 479ea0bae..a17e332da 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -4,7 +4,7 @@ #include "Globals.h" #include "Map.h" - +#include "BlockInfo.h" #include "World.h" #include "Chunk.h" #include "Entities/Player.h" diff --git a/src/Map.h b/src/Map.h index 29fcf55bc..67c9a7dcd 100644 --- a/src/Map.h +++ b/src/Map.h @@ -9,6 +9,8 @@ #pragma once +#include "Defines.h" + diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index 41855a638..73531f2fc 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "MobSpawner.h" +#include "BlockInfo.h" #include "Mobs/IncludeAllMonsters.h" #include "World.h" diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 233ca70b3..5a01663e5 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "IncludeAllMonsters.h" +#include "../BlockInfo.h" #include "../Root.h" #include "../Server.h" #include "../ClientHandle.h" diff --git a/src/Mobs/MonsterTypes.h b/src/Mobs/MonsterTypes.h index 96b4d0df0..6aaa61dc6 100644 --- a/src/Mobs/MonsterTypes.h +++ b/src/Mobs/MonsterTypes.h @@ -6,47 +6,42 @@ // tolua_begin -/** Identifies individual monster type, as well as their network type-ID. */ +/** Identifies individual monster type. */ enum eMonsterType { mtInvalidType = -1, - mtBat = E_META_SPAWN_EGG_BAT, - mtBlaze = E_META_SPAWN_EGG_BLAZE, - mtCaveSpider = E_META_SPAWN_EGG_CAVE_SPIDER, - mtChicken = E_META_SPAWN_EGG_CHICKEN, - mtCow = E_META_SPAWN_EGG_COW, - mtCreeper = E_META_SPAWN_EGG_CREEPER, - mtEnderDragon = E_META_SPAWN_EGG_ENDER_DRAGON, - mtEnderman = E_META_SPAWN_EGG_ENDERMAN, - mtGhast = E_META_SPAWN_EGG_GHAST, - mtGiant = E_META_SPAWN_EGG_GIANT, - mtGuardian = E_META_SPAWN_EGG_GUARDIAN, - mtHorse = E_META_SPAWN_EGG_HORSE, - mtIronGolem = E_META_SPAWN_EGG_IRON_GOLEM, - mtMagmaCube = E_META_SPAWN_EGG_MAGMA_CUBE, - mtMooshroom = E_META_SPAWN_EGG_MOOSHROOM, - mtOcelot = E_META_SPAWN_EGG_OCELOT, - mtPig = E_META_SPAWN_EGG_PIG, - mtRabbit = E_META_SPAWN_EGG_RABBIT, - mtSheep = E_META_SPAWN_EGG_SHEEP, - mtSilverfish = E_META_SPAWN_EGG_SILVERFISH, - mtSkeleton = E_META_SPAWN_EGG_SKELETON, - mtSlime = E_META_SPAWN_EGG_SLIME, - mtSnowGolem = E_META_SPAWN_EGG_SNOW_GOLEM, - mtSpider = E_META_SPAWN_EGG_SPIDER, - mtSquid = E_META_SPAWN_EGG_SQUID, - mtVillager = E_META_SPAWN_EGG_VILLAGER, - mtWitch = E_META_SPAWN_EGG_WITCH, - mtWither = E_META_SPAWN_EGG_WITHER, - mtWolf = E_META_SPAWN_EGG_WOLF, - mtZombie = E_META_SPAWN_EGG_ZOMBIE, - mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN, - mtMax = 120, // This is just a hotfix for https://forum.cuberite.org/thread-1616.html. Tolua is too bad to find the highest value, so this is needed. + mtBat, + mtBlaze, + mtCaveSpider, + mtChicken, + mtCow, + mtCreeper, + mtEnderDragon, + mtEnderman, + mtGhast, + mtGiant, + mtGuardian, + mtHorse, + mtIronGolem, + mtMagmaCube, + mtMooshroom, + mtOcelot, + mtPig, + mtRabbit, + mtSheep, + mtSilverfish, + mtSkeleton, + mtSlime, + mtSnowGolem, + mtSpider, + mtSquid, + mtVillager, + mtWitch, + mtWither, + mtWolf, + mtZombie, + mtZombiePigman, } ; // tolua_end - - - - diff --git a/src/Mobs/Path.cpp b/src/Mobs/Path.cpp index fa57fa1ca..a2a5cf51c 100644 --- a/src/Mobs/Path.cpp +++ b/src/Mobs/Path.cpp @@ -2,6 +2,7 @@ #include "Globals.h" #include "Path.h" +#include "../BlockInfo.h" #include "../Chunk.h" #define JUMP_G_COST 20 diff --git a/src/Mobs/PathFinder.cpp b/src/Mobs/PathFinder.cpp index a4f237fbd..f2542cebc 100644 --- a/src/Mobs/PathFinder.cpp +++ b/src/Mobs/PathFinder.cpp @@ -1,5 +1,6 @@ #include "Globals.h" #include "PathFinder.h" +#include "../BlockInfo.h" #include "../Chunk.h" diff --git a/src/Mobs/SnowGolem.cpp b/src/Mobs/SnowGolem.cpp index 3ea97173f..ce94c9dae 100644 --- a/src/Mobs/SnowGolem.cpp +++ b/src/Mobs/SnowGolem.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "SnowGolem.h" +#include "../BlockInfo.h" #include "../World.h" diff --git a/src/NetherPortalScanner.cpp b/src/NetherPortalScanner.cpp index a4564d0f1..8de0a6dcc 100644 --- a/src/NetherPortalScanner.cpp +++ b/src/NetherPortalScanner.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "NetherPortalScanner.h" +#include "BlockInfo.h" #include "Entities/Entity.h" #include "World.h" diff --git a/src/Protocol/ChunkDataSerializer.h b/src/Protocol/ChunkDataSerializer.h index a77935258..27a3d9426 100644 --- a/src/Protocol/ChunkDataSerializer.h +++ b/src/Protocol/ChunkDataSerializer.h @@ -1,6 +1,7 @@ #pragma once #include "../ChunkData.h" +#include "../Defines.h" diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp index d381f0a42..9509fe51e 100644 --- a/src/Protocol/Protocol_1_8.cpp +++ b/src/Protocol/Protocol_1_8.cpp @@ -3092,7 +3092,7 @@ void cProtocol_1_8_0::ParseItemMetadata(cItem & a_Item, const AString & a_Metada } else if ((TagName == "Fireworks") || (TagName == "Explosion")) { - cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, NBT, tag, static_cast(a_Item.m_ItemType)); + cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, NBT, tag, static_cast(a_Item.m_ItemType)); } break; } @@ -3282,7 +3282,7 @@ void cProtocol_1_8_0::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item) } if ((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR)) { - cFireworkItem::WriteToNBTCompound(a_Item.m_FireworkItem, Writer, static_cast(a_Item.m_ItemType)); + cFireworkItem::WriteToNBTCompound(a_Item.m_FireworkItem, Writer, static_cast(a_Item.m_ItemType)); } Writer.Finish(); diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp index eac539ce3..d31db7ec4 100644 --- a/src/Protocol/Protocol_1_9.cpp +++ b/src/Protocol/Protocol_1_9.cpp @@ -3227,7 +3227,7 @@ void cProtocol_1_9_0::ParseItemMetadata(cItem & a_Item, const AString & a_Metada } else if ((TagName == "Fireworks") || (TagName == "Explosion")) { - cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, NBT, tag, static_cast(a_Item.m_ItemType)); + cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, NBT, tag, static_cast(a_Item.m_ItemType)); } else if (TagName == "EntityTag") { @@ -3592,7 +3592,7 @@ void cProtocol_1_9_0::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item) } if ((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR)) { - cFireworkItem::WriteToNBTCompound(a_Item.m_FireworkItem, Writer, static_cast(a_Item.m_ItemType)); + cFireworkItem::WriteToNBTCompound(a_Item.m_FireworkItem, Writer, static_cast(a_Item.m_ItemType)); } if (a_Item.m_ItemType == E_ITEM_POTION) { diff --git a/src/Root.h b/src/Root.h index 90676a7df..6c84e6bf7 100644 --- a/src/Root.h +++ b/src/Root.h @@ -14,6 +14,7 @@ // fwd: +class cItem; class cMonsterConfig; class cBrewingRecipes; class cCraftingRecipes; diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp index 304450b3c..2a9d6c289 100644 --- a/src/Simulator/FireSimulator.cpp +++ b/src/Simulator/FireSimulator.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "FireSimulator.h" +#include "../BlockInfo.h" #include "../World.h" #include "../Defines.h" #include "../Chunk.h" diff --git a/src/Simulator/FireSimulator.h b/src/Simulator/FireSimulator.h index 236be5686..f36407584 100644 --- a/src/Simulator/FireSimulator.h +++ b/src/Simulator/FireSimulator.h @@ -2,6 +2,7 @@ #pragma once #include "Simulator.h" +#include "../IniFile.h" diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp index b620dddce..14573e0de 100644 --- a/src/Simulator/FloodyFluidSimulator.cpp +++ b/src/Simulator/FloodyFluidSimulator.cpp @@ -7,6 +7,7 @@ #include "Globals.h" #include "FloodyFluidSimulator.h" +#include "../BlockInfo.h" #include "../World.h" #include "../Chunk.h" #include "../BlockArea.h" diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp index 5f0595d48..42bb521ed 100644 --- a/src/Simulator/SandSimulator.cpp +++ b/src/Simulator/SandSimulator.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "SandSimulator.h" +#include "../BlockInfo.h" #include "../World.h" #include "../Defines.h" #include "../Entities/FallingBlock.h" @@ -283,7 +284,7 @@ void cSandSimulator::FinishFalling( // Create a pickup instead: cItems Pickups; - Pickups.Add(static_cast(a_FallingBlockType), 1, a_FallingBlockMeta); + Pickups.Add(static_cast(a_FallingBlockType), 1, a_FallingBlockMeta); a_World->SpawnItemPickups( Pickups, static_cast(a_BlockX) + 0.5, diff --git a/src/Simulator/SandSimulator.h b/src/Simulator/SandSimulator.h index cee0a85e6..d7a27edd4 100644 --- a/src/Simulator/SandSimulator.h +++ b/src/Simulator/SandSimulator.h @@ -2,6 +2,7 @@ #pragma once #include "Simulator.h" +#include "../IniFile.h" diff --git a/src/Simulator/VanillaFluidSimulator.cpp b/src/Simulator/VanillaFluidSimulator.cpp index f6fe1e9ec..0fc84be59 100644 --- a/src/Simulator/VanillaFluidSimulator.cpp +++ b/src/Simulator/VanillaFluidSimulator.cpp @@ -4,6 +4,7 @@ #include "Globals.h" #include "VanillaFluidSimulator.h" +#include "../BlockInfo.h" #include "../World.h" #include "../Chunk.h" #include "../BlockArea.h" diff --git a/src/Tracer.cpp b/src/Tracer.cpp index 91a89f96c..dd4cde479 100644 --- a/src/Tracer.cpp +++ b/src/Tracer.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Tracer.h" +#include "BlockInfo.h" #include "World.h" #include "Entities/Entity.h" diff --git a/src/World.cpp b/src/World.cpp index 9c7928c89..464d84be5 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "World.h" +#include "BlockInfo.h" #include "ClientHandle.h" #include "Server.h" #include "Root.h" diff --git a/src/World.h b/src/World.h index e1341c9cb..b46440410 100644 --- a/src/World.h +++ b/src/World.h @@ -739,7 +739,7 @@ public: /** Does an explosion with the specified strength at the specified coordinates. Executes the HOOK_EXPLODING and HOOK_EXPLODED hooks as part of the processing. - a_SourceData exact type depends on the a_Source, see the declaration of the esXXX constants in BlockID.h for details. + a_SourceData exact type depends on the a_Source, see the declaration of the esXXX constants in Defines.h for details. Exported to Lua manually in ManualBindings_World.cpp in order to support the variable a_SourceData param. */ virtual void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void * a_SourceData) override; diff --git a/src/WorldStorage/FireworksSerializer.cpp b/src/WorldStorage/FireworksSerializer.cpp index 891a67e62..7cf3c3eea 100644 --- a/src/WorldStorage/FireworksSerializer.cpp +++ b/src/WorldStorage/FireworksSerializer.cpp @@ -2,12 +2,13 @@ #include "Globals.h" #include "FireworksSerializer.h" #include "../WorldStorage/FastNBT.h" +#include "../BlockType.h" -void cFireworkItem::WriteToNBTCompound(const cFireworkItem & a_FireworkItem, cFastNBTWriter & a_Writer, const ENUM_ITEM_ID a_Type) +void cFireworkItem::WriteToNBTCompound(const cFireworkItem & a_FireworkItem, cFastNBTWriter & a_Writer, const ENUM_ITEM_TYPE a_Type) { switch (a_Type) { @@ -58,7 +59,7 @@ void cFireworkItem::WriteToNBTCompound(const cFireworkItem & a_FireworkItem, cFa -void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNBT & a_NBT, int a_TagIdx, const ENUM_ITEM_ID a_Type) +void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNBT & a_NBT, int a_TagIdx, const ENUM_ITEM_TYPE a_Type) { if (a_TagIdx < 0) { diff --git a/src/WorldStorage/FireworksSerializer.h b/src/WorldStorage/FireworksSerializer.h index 9a24edadd..32264d2f3 100644 --- a/src/WorldStorage/FireworksSerializer.h +++ b/src/WorldStorage/FireworksSerializer.h @@ -10,6 +10,12 @@ #pragma once +#include "../BlockType.h" + + + + + class cFastNBTWriter; class cParsedNBT; @@ -62,10 +68,10 @@ public: } /** Writes firework NBT data to a Writer object */ - static void WriteToNBTCompound(const cFireworkItem & a_FireworkItem, cFastNBTWriter & a_Writer, const ENUM_ITEM_ID a_Type); + static void WriteToNBTCompound(const cFireworkItem & a_FireworkItem, cFastNBTWriter & a_Writer, const ENUM_ITEM_TYPE a_Type); /** Reads NBT data from a NBT object and populates a FireworkItem with it */ - static void ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNBT & a_NBT, int a_TagIdx, const ENUM_ITEM_ID a_Type); + static void ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNBT & a_NBT, int a_TagIdx, const ENUM_ITEM_TYPE a_Type); /** Converts the firework's vector of colours into a string of values separated by a semicolon */ static AString ColoursToString(const cFireworkItem & a_FireworkItem); diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 0a18cb7b3..014ee2c27 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -322,7 +322,7 @@ public: if ((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR)) { - cFireworkItem::WriteToNBTCompound(a_Item.m_FireworkItem, mWriter, static_cast(a_Item.m_ItemType)); + cFireworkItem::WriteToNBTCompound(a_Item.m_FireworkItem, mWriter, static_cast(a_Item.m_ItemType)); } if (!a_Item.m_Enchantments.IsEmpty()) diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 4712e6ab1..0480680dd 100755 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -15,6 +15,7 @@ #include "../StringCompression.h" #include "../SetChunkData.h" #include "../Root.h" +#include "../BlockType.h" #include "../BlockEntities/BeaconEntity.h" #include "../BlockEntities/BedEntity.h" @@ -363,10 +364,10 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT cChunkDef::BlockNibbles BlockLight; cChunkDef::BlockNibbles SkyLight; - memset(BlockTypes, E_BLOCK_AIR, sizeof(BlockTypes)); - memset(MetaData, 0, sizeof(MetaData)); - memset(SkyLight, 0xff, sizeof(SkyLight)); // By default, data not present in the NBT means air, which means full skylight - memset(BlockLight, 0x00, sizeof(BlockLight)); + memset(BlockTypes, 0, sizeof(BlockTypes)); + memset(MetaData, 0, sizeof(MetaData)); + memset(SkyLight, 0xff, sizeof(SkyLight)); // By default, data not present in the NBT means air, which means full skylight + memset(BlockLight, 0x00, sizeof(BlockLight)); // Load the blockdata, blocklight and skylight: int Level = a_NBT.FindChildByName(0, "Level"); @@ -779,7 +780,7 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_ int FireworksTag = a_NBT.FindChildByName(TagTag, ((a_Item.m_ItemType == E_ITEM_FIREWORK_STAR) ? "Explosion" : "Fireworks")); if (FireworksTag > 0) { - cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, a_NBT, FireworksTag, static_cast(a_Item.m_ItemType)); + cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, a_NBT, FireworksTag, static_cast(a_Item.m_ItemType)); } return true; diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h index 166230568..96945363e 100755 --- a/src/WorldStorage/WSSAnvil.h +++ b/src/WorldStorage/WSSAnvil.h @@ -15,7 +15,8 @@ -// fwd: ItemGrid.h +// fwd: +class cItem; class cItemGrid; class cMonster; class cProjectileEntity; diff --git a/tests/Generating/BasicGeneratorTest.cpp b/tests/Generating/BasicGeneratorTest.cpp index c54ca6507..4b27f5344 100644 --- a/tests/Generating/BasicGeneratorTest.cpp +++ b/tests/Generating/BasicGeneratorTest.cpp @@ -175,7 +175,18 @@ static void testGenerateNether(cChunkGenerator & aDefaultNetherGen) { TEST_EQUAL_MSG(chd.GetBlockType(x, 0, z), E_BLOCK_BEDROCK, Printf("Bedrock floor at {%d, 0, %d}", x, z)); auto y = chd.GetHeight(x, z); - TEST_EQUAL(y, prevHeight); // Same height across the entire chunk + auto topBlockType = chd.GetBlockType(x, y, z); + // Skip the mushrooms generated on the top bedrock layer: + if ( + (topBlockType == E_BLOCK_BROWN_MUSHROOM) || + (topBlockType == E_BLOCK_RED_MUSHROOM) + ) + { + y -= 1; + } + TEST_EQUAL_MSG(y, prevHeight, Printf("Failed: Same height across the entire chunk, at {%d, %d}: exp %d, got %d; top block: %d", + x, z, prevHeight, y, chd.GetBlockType(x, y, z) + )) auto blockType = chd.GetBlockType(x, y, z); TEST_EQUAL_MSG(blockType, E_BLOCK_BEDROCK, Printf("Bedrock ceiling at {%d, %d, %d}: %d", x, y, z, blockType) @@ -245,6 +256,11 @@ static void checkChunkChecksums( { cChunkDesc chd(coords.mCoords); aGenerator.Generate(chd); + /* + cFile f(Printf("Repeatability_%s-%02d-%02d.raw", aDimension, coords.mCoords.m_ChunkX, coords.mCoords.m_ChunkZ), cFile::fmWrite); + f.Write(chd.GetBlockTypes(), sizeof(chd.GetBlockTypes())); + f.Close(); + */ auto checksum = chunkSHA1(chd); TEST_EQUAL_MSG(checksum, coords.mChecksum, Printf("%s chunk %s SHA1: expected %s, got %s", aDimension, coords.mCoords.ToString(), coords.mChecksum, checksum) @@ -275,11 +291,11 @@ static void testRepeatability(cChunkGenerator & aDefaultOverworldGenerator, cChu // Test the default Nether generator: std::vector netherChecksums = { - { 0, 0, "-25231a9ce4bc57eaeaf1f4ad01c32ddd5b2293e5"}, - { 1, 0, "-61ef8824b6b241b4f0e28c09505bad5d7898a8a4"}, - { 1, 1, "6b3ba6dcb18568e21b3a5aae9ea58368079fbaf8"}, - {17, 0, "1acc3a28eb1be66b3e4a256f0712a48f96085a39"}, - { 8, 1024, "6f9b96e0613ca2fd879dbb53634b511e5649627a"}, + { 0, 0, "-487001a1ada9cdd7c8b557d3ff7081881f57c660"}, + { 1, 0, "a074ac7a1f2fbf4173324e5edd792197d6a29c2"}, + { 1, 1, "5867c5121f2a259ebc2aa53ecafed93dd3d6de95"}, + {17, 0, "-300191cee5b30592f7b61cd22ea08669eba3f569"}, + { 8, 1024, "69bbda09be981f5e3adc53d0a49995aff43f1290"}, }; checkChunkChecksums(aDefaultNetherGenerator, netherChecksums, "Nether"); } diff --git a/tests/Generating/CMakeLists.txt b/tests/Generating/CMakeLists.txt index cfdae6c68..cf8e2faa0 100644 --- a/tests/Generating/CMakeLists.txt +++ b/tests/Generating/CMakeLists.txt @@ -11,9 +11,11 @@ add_definitions(-DTEST_GLOBALS=1) set (SHARED_SRCS ${CMAKE_SOURCE_DIR}/src/BiomeDef.cpp ${CMAKE_SOURCE_DIR}/src/BlockArea.cpp - ${CMAKE_SOURCE_DIR}/src/BlockID.cpp + ${CMAKE_SOURCE_DIR}/src/BlockInfo.cpp + ${CMAKE_SOURCE_DIR}/src/BlockType.cpp ${CMAKE_SOURCE_DIR}/src/Cuboid.cpp ${CMAKE_SOURCE_DIR}/src/ChunkData.cpp + ${CMAKE_SOURCE_DIR}/src/Defines.cpp ${CMAKE_SOURCE_DIR}/src/Enchantments.cpp ${CMAKE_SOURCE_DIR}/src/FastRandom.cpp ${CMAKE_SOURCE_DIR}/src/IniFile.cpp @@ -71,10 +73,12 @@ set (GENERATING_SRCS set (SHARED_HDRS ${CMAKE_SOURCE_DIR}/src/BiomeDef.h ${CMAKE_SOURCE_DIR}/src/BlockArea.h - ${CMAKE_SOURCE_DIR}/src/BlockID.h + ${CMAKE_SOURCE_DIR}/src/BlockInfo.h + ${CMAKE_SOURCE_DIR}/src/BlockType.h ${CMAKE_SOURCE_DIR}/src/Cuboid.h ${CMAKE_SOURCE_DIR}/src/ChunkData.h ${CMAKE_SOURCE_DIR}/src/ChunkDef.h + ${CMAKE_SOURCE_DIR}/src/Defines.h ${CMAKE_SOURCE_DIR}/src/Enchantments.h ${CMAKE_SOURCE_DIR}/src/FastRandom.h ${CMAKE_SOURCE_DIR}/src/Globals.h @@ -157,7 +161,7 @@ add_library(GeneratorTestingSupport STATIC ${GENERATING_HDRS} ${STUBS} ) -target_link_libraries(GeneratorTestingSupport tolualib zlib fmt::fmt) +target_link_libraries(GeneratorTestingSupport tolualib zlib fmt::fmt jsoncpp_lib_static) source_group("Stubs" FILES ${STUBS}) source_group("Generating" FILES ${GENERATING_HDRS} ${GENERATING_SRCS}) diff --git a/tests/Generating/Stubs.cpp b/tests/Generating/Stubs.cpp index 7bbd6b2da..7ccd6305e 100644 --- a/tests/Generating/Stubs.cpp +++ b/tests/Generating/Stubs.cpp @@ -93,30 +93,6 @@ extern "C" int luaopen_lxp(lua_State * a_LuaState) -void cBlockInfo::sHandlerDeleter::operator () (cBlockHandler * a_Handler) -{ - delete a_Handler; -} - - - - - -cBlockInfo::cBlockInfoArray::cBlockInfoArray() -{ - cBlockInfoArray & BlockInfos = *this; - // The piece-loading code uses the handlers for rotations, so we need valid handlers - // Insert dummy handlers: - for (size_t i = 0; i < BlockInfos.size(); i++) - { - BlockInfos[i].m_Handler.reset(new cBlockHandler(static_cast(i))); - } -} - - - - - cBoundingBox::cBoundingBox(double, double, double, double, double, double) { } @@ -409,3 +385,43 @@ std::set cMobSpawner::GetAllowedMobTypes(EMCSBiome a_Biome) { return {}; } + + + + + +cItem::cItem() +{ +} + + + + + +cItem::cItem( + short a_ItemType, + char a_ItemCount, + short a_ItemDamage, + const AString & a_Enchantments, + const AString & a_CustomName, + const AStringVector & a_LoreTable +) +{ +} + + + + + +void cItem::Empty() +{ +} + + + + + +cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) +{ + return new cBlockHandler(a_BlockType); +} diff --git a/tests/LuaThreadStress/Stubs.cpp b/tests/LuaThreadStress/Stubs.cpp index 8b4a15f09..2255da47b 100644 --- a/tests/LuaThreadStress/Stubs.cpp +++ b/tests/LuaThreadStress/Stubs.cpp @@ -35,15 +35,6 @@ extern "C" int luaopen_lxp(lua_State * a_LuaState); -class cItems -{ - // Empty class placeholder -}; - - - - - void cManualBindings::Bind(lua_State * a_LuaState) { } @@ -104,6 +95,14 @@ void cBlockInfo::sHandlerDeleter::operator () (cBlockHandler * a_Handler) +cBlockInfo::cBlockInfo() +{ +} + + + + + cBlockInfo::cBlockInfoArray::cBlockInfoArray() { cBlockInfoArray & BlockInfos = *this; diff --git a/tests/SchematicFileSerializer/Stubs.cpp b/tests/SchematicFileSerializer/Stubs.cpp index 6bd253467..c02536ed3 100644 --- a/tests/SchematicFileSerializer/Stubs.cpp +++ b/tests/SchematicFileSerializer/Stubs.cpp @@ -13,10 +13,9 @@ -class cItems +cBlockInfo::cBlockInfo() { - // Empty class placeholder -}; +} -- cgit v1.2.3