From 0e2340ee345b9b62b3790ef98f2888f943c826e6 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 3 Mar 2013 14:00:49 +0000 Subject: Added missing item types, fixed placing stone walls. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1243 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Bindings.cpp | 13 +++++++++++- source/Bindings.h | 2 +- source/BlockID.h | 13 +++++++++++- source/Items/ItemHandler.cpp | 49 +++++++++++++++++++++++++++++--------------- 4 files changed, 58 insertions(+), 19 deletions(-) (limited to 'source') diff --git a/source/Bindings.cpp b/source/Bindings.cpp index 125bcbf44..5db1c385b 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 03/01/13 16:38:13. +** Generated automatically by tolua++-1.0.92 on 03/03/13 14:57:13. */ #ifndef __cplusplus @@ -21597,6 +21597,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_constant(tolua_S,"E_BLOCK_POTATOES",E_BLOCK_POTATOES); tolua_constant(tolua_S,"E_BLOCK_WOODEN_BUTTON",E_BLOCK_WOODEN_BUTTON); tolua_constant(tolua_S,"E_BLOCK_HEAD",E_BLOCK_HEAD); + tolua_constant(tolua_S,"E_BLOCK_ANVIL",E_BLOCK_ANVIL); tolua_constant(tolua_S,"E_BLOCK_TRAPPED_CHEST",E_BLOCK_TRAPPED_CHEST); tolua_constant(tolua_S,"E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE",E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE); tolua_constant(tolua_S,"E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE",E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE); @@ -21747,12 +21748,22 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_constant(tolua_S,"E_ITEM_WRITTEN_BOOK",E_ITEM_WRITTEN_BOOK); tolua_constant(tolua_S,"E_ITEM_EMERALD",E_ITEM_EMERALD); tolua_constant(tolua_S,"E_ITEM_FLOWER_POT",E_ITEM_FLOWER_POT); + tolua_constant(tolua_S,"E_ITEM_CARROT",E_ITEM_CARROT); + tolua_constant(tolua_S,"E_ITEM_POTATO",E_ITEM_POTATO); + tolua_constant(tolua_S,"E_ITEM_BAKED_POTATO",E_ITEM_BAKED_POTATO); + tolua_constant(tolua_S,"E_ITEM_POISONOUS_POTATO",E_ITEM_POISONOUS_POTATO); + tolua_constant(tolua_S,"E_ITEM_GOLDEN_CARROT",E_ITEM_GOLDEN_CARROT); + tolua_constant(tolua_S,"E_ITEM_HEAD",E_ITEM_HEAD); + tolua_constant(tolua_S,"E_ITEM_CARROT_ON_STICK",E_ITEM_CARROT_ON_STICK); + tolua_constant(tolua_S,"E_ITEM_PUMPKIN_PIE",E_ITEM_PUMPKIN_PIE); tolua_constant(tolua_S,"E_ITEM_FIREWORK_ROCKET",E_ITEM_FIREWORK_ROCKET); tolua_constant(tolua_S,"E_ITEM_FIREWORK_STAR",E_ITEM_FIREWORK_STAR); tolua_constant(tolua_S,"E_ITEM_ENCHANTED_BOOK",E_ITEM_ENCHANTED_BOOK); tolua_constant(tolua_S,"E_ITEM_COMPARATOR",E_ITEM_COMPARATOR); tolua_constant(tolua_S,"E_ITEM_NETHER_BRICK",E_ITEM_NETHER_BRICK); tolua_constant(tolua_S,"E_ITEM_NETHER_QUARTZ",E_ITEM_NETHER_QUARTZ); + tolua_constant(tolua_S,"E_ITEM_MINECART_WITH_TNT",E_ITEM_MINECART_WITH_TNT); + tolua_constant(tolua_S,"E_ITEM_MINECART_WITH_HOPPER",E_ITEM_MINECART_WITH_HOPPER); tolua_constant(tolua_S,"E_ITEM_NUMBER_OF_CONSECUTIVE_TYPES",E_ITEM_NUMBER_OF_CONSECUTIVE_TYPES); tolua_constant(tolua_S,"E_ITEM_MAX_CONSECUTIVE_TYPE_ID",E_ITEM_MAX_CONSECUTIVE_TYPE_ID); tolua_constant(tolua_S,"E_ITEM_FIRST_DISC",E_ITEM_FIRST_DISC); diff --git a/source/Bindings.h b/source/Bindings.h index 78c5967d9..69cdcc5f7 100644 --- a/source/Bindings.h +++ b/source/Bindings.h @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 03/01/13 16:38:13. +** Generated automatically by tolua++-1.0.92 on 03/03/13 14:57:13. */ /* Exported function */ diff --git a/source/BlockID.h b/source/BlockID.h index cd886d535..5110c86ad 100644 --- a/source/BlockID.h +++ b/source/BlockID.h @@ -309,7 +309,6 @@ enum ENUM_ITEM_ID 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, @@ -317,12 +316,24 @@ enum ENUM_ITEM_ID E_ITEM_WRITTEN_BOOK = 387, E_ITEM_EMERALD = 388, E_ITEM_FLOWER_POT = 390, + E_ITEM_CARROT = 391, + E_ITEM_POTATO = 392, + E_ITEM_BAKED_POTATO = 393, + E_ITEM_POISONOUS_POTATO = 394, + // TODO: missing an item + E_ITEM_GOLDEN_CARROT = 396, + E_ITEM_HEAD = 397, + E_ITEM_CARROT_ON_STICK = 398, + // TODO: missing an item + 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, // 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! diff --git a/source/Items/ItemHandler.cpp b/source/Items/ItemHandler.cpp index 2b2d9268b..8411ad688 100644 --- a/source/Items/ItemHandler.cpp +++ b/source/Items/ItemHandler.cpp @@ -344,6 +344,7 @@ char cItemHandler::GetMaxStackSize(void) bool cItemHandler::IsTool() { + // TODO: Rewrite this to list all tools specifically return (m_ItemType >= 256 && m_ItemType <= 259) || (m_ItemType == 261) @@ -359,27 +360,46 @@ bool cItemHandler::IsTool() -bool cItemHandler::IsFood() +bool cItemHandler::IsFood(void) { - return - (m_ItemType == 260) - || (m_ItemType == 282) - || (m_ItemType == 297) - || (m_ItemType >= 319 && m_ItemType <= 320) - || (m_ItemType == 335) - || (m_ItemType >= 349 && m_ItemType <= 350) - || (m_ItemType == 357) - || (m_ItemType == 360) - || (m_ItemType >= 363 && m_ItemType <= 366); + switch (m_ItemType) + { + case E_ITEM_RED_APPLE: + case E_ITEM_GOLDEN_APPLE: + case E_ITEM_MUSHROOM_SOUP: + case E_ITEM_BREAD: + case E_ITEM_RAW_PORKCHOP: + case E_ITEM_COOKED_PORKCHOP: + case E_ITEM_MILK: + case E_ITEM_RAW_FISH: + case E_ITEM_COOKED_FISH: + case E_ITEM_COOKIE: + case E_ITEM_MELON_SLICE: + case E_ITEM_RAW_BEEF: + case E_ITEM_STEAK: + case E_ITEM_RAW_CHICKEN: + case E_ITEM_COOKED_CHICKEN: + case E_ITEM_ROTTEN_FLESH: + case E_ITEM_SPIDER_EYE: + case E_ITEM_CARROT: + case E_ITEM_POTATO: + case E_ITEM_BAKED_POTATO: + case E_ITEM_POISONOUS_POTATO: + { + return true; + } + } // switch (m_ItemType) + return false; } -bool cItemHandler::IsPlaceable() +bool cItemHandler::IsPlaceable(void) { - return m_ItemType >= 1 && m_ItemType <= 136; + // We can place any block that has a corresponding E_BLOCK_TYPE: + return (m_ItemType >= 1) && (m_ItemType <= E_BLOCK_MAX_TYPE_ID); } @@ -417,9 +437,6 @@ bool cItemHandler::GetPlacementBlockTypeMeta( a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta ); - a_BlockType = (BLOCKTYPE) m_ItemType; - a_BlockMeta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x0f); // This keeps most textures. The few other items have to override this - return true; } -- cgit v1.2.3