From 0f8c24e04d60aa1642a5fe7346941ccd7697977e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 17 Jul 2014 22:26:53 +0100 Subject: Fixed issues relating to saplings and leaves - Removed cBlockInfo::RequiresSpecialTool * Fixes #1195 * Fixes #1201 --- src/Items/ItemHandler.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/Items') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 85406c826..604cce729 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -328,12 +328,9 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const if (a_Player->IsGameModeSurvival()) { - if (!BlockRequiresSpecialTool(Block) || CanHarvestBlock(Block)) - { - cChunkInterface ChunkInterface(a_World->GetChunkMap()); - cBlockInServerPluginInterface PluginInterface(*a_World); - Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ); - } + cChunkInterface ChunkInterface(a_World->GetChunkMap()); + cBlockInServerPluginInterface PluginInterface(*a_World); + Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block)); } a_Player->UseEquippedItem(); -- cgit v1.2.3 From eeacb6f2223f88a64ce877458c58fa60194e45a6 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 02:19:30 +0200 Subject: Added a extra wall sign handler. Fixes #1119 --- src/Items/ItemSign.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Items') diff --git a/src/Items/ItemSign.h b/src/Items/ItemSign.h index 235a4fa93..0fa0fa0be 100644 --- a/src/Items/ItemSign.h +++ b/src/Items/ItemSign.h @@ -3,7 +3,8 @@ #include "ItemHandler.h" #include "../World.h" -#include "../Blocks/BlockSign.h" +#include "../Blocks/BlockSignPost.h" +#include "../Blocks/BlockWallSign.h" @@ -34,12 +35,12 @@ public: { if (a_BlockFace == BLOCK_FACE_TOP) { - a_BlockMeta = cBlockSignHandler::RotationToMetaData(a_Player->GetYaw()); + a_BlockMeta = cBlockSignPostHandler::RotationToMetaData(a_Player->GetYaw()); a_BlockType = E_BLOCK_SIGN_POST; } else { - a_BlockMeta = cBlockSignHandler::DirectionToMetaData(a_BlockFace); + a_BlockMeta = cBlockWallSignHandler::DirectionToMetaData(a_BlockFace); a_BlockType = E_BLOCK_WALLSIGN; } return true; -- cgit v1.2.3 From 465743757a4847b860d932a20c3a7570aec6bec5 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 23:59:33 -0700 Subject: Items/CMakeLists.txt: Replaced glob with list of files --- src/Items/CMakeLists.txt | 52 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) (limited to 'src/Items') diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt index a6fe6ea70..0c15a6944 100644 --- a/src/Items/CMakeLists.txt +++ b/src/Items/CMakeLists.txt @@ -4,9 +4,51 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + ItemHandler.cpp) -add_library(Items ${SOURCE}) +SET (HDRS + ItemArmor.h + ItemBed.h + ItemBoat.h + ItemBow.h + ItemBrewingStand.h + ItemBucket.h + ItemCake.h + ItemCauldron.h + ItemCloth.h + ItemComparator.h + ItemDoor.h + ItemDye.h + ItemEmptyMap.h + ItemFishingRod.h + ItemFlowerPot.h + ItemFood.h + ItemHandler.h + ItemHoe.h + ItemItemFrame.h + ItemLeaves.h + ItemLighter.h + ItemLilypad.h + ItemMap.h + ItemMilk.h + ItemMinecart.h + ItemMobHead.h + ItemNetherWart.h + ItemPainting.h + ItemPickaxe.h + ItemPotion.h + ItemRedstoneDust.h + ItemRedstoneRepeater.h + ItemSapling.h + ItemSeeds.h + ItemShears.h + ItemShovel.h + ItemSign.h + ItemSpawnEgg.h + ItemString.h + ItemSugarcane.h + ItemSword.h + ItemThrowable.h) + +add_library(Items ${SRCS} ${HDRS}) -- cgit v1.2.3 From 725d1fd1e2995b1720673c280fea1125ac338b3c Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 13:26:43 -0700 Subject: Subdirs: Only add_library if not using MSVC --- src/Items/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Items') diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt index 0c15a6944..12a467672 100644 --- a/src/Items/CMakeLists.txt +++ b/src/Items/CMakeLists.txt @@ -51,4 +51,6 @@ SET (HDRS ItemSword.h ItemThrowable.h) -add_library(Items ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Items ${SRCS} ${HDRS}) +endif() -- cgit v1.2.3 From f5bcfdc58c7b5d69abbb222787bb2229c0b54088 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 02:51:39 -0700 Subject: Splash potions: Renamed PotionParticleType to PotionColor for clarity --- src/Items/ItemPotion.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Items') diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index f3afbf99b..f16d89b39 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -17,8 +17,8 @@ public: } - /** Returns the potion particle type (used by the client for visuals), based on the potion's damage value */ - static int GetPotionParticleType(short a_ItemDamage) + /** Returns the potion color (used by the client for visuals), based on the potion's damage value */ + static int GetPotionColor(short a_ItemDamage) { // Lowest six bits return (a_ItemDamage & 0x3f); @@ -156,7 +156,7 @@ public: cSplashPotionEntity * Projectile = new cSplashPotionEntity( a_Player, Pos.x, Pos.y, Pos.z, Speed, GetEntityEffectType(PotionDamage), cEntityEffect(GetEntityEffectDuration(PotionDamage), - GetEntityEffectIntensity(PotionDamage)), GetPotionParticleType(PotionDamage) + GetEntityEffectIntensity(PotionDamage)), GetPotionColor(PotionDamage) ); if (Projectile == NULL) { -- cgit v1.2.3 From 00c524519ef6c7ceaf4ac91307617cfd65d7cf21 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 14:53:41 +0200 Subject: Fixed style: spaces after commas. --- src/Items/ItemBucket.h | 2 +- src/Items/ItemShovel.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Items') diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 6d7926fa4..a17c4838b 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -117,7 +117,7 @@ public: return false; } cItem Item(E_ITEM_BUCKET, 1); - if (!a_Player->GetInventory().AddItem(Item,true,true)) + if (!a_Player->GetInventory().AddItem(Item, true, true)) { return false; } diff --git a/src/Items/ItemShovel.h b/src/Items/ItemShovel.h index 333ba46e8..78cfe26fe 100644 --- a/src/Items/ItemShovel.h +++ b/src/Items/ItemShovel.h @@ -28,7 +28,7 @@ public: { cChunkInterface ChunkInterface(a_World->GetChunkMap()); cBlockInServerPluginInterface PluginInterface(*a_World); - BlockHandler(Block)->DropBlock(ChunkInterface,*a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ); + BlockHandler(Block)->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ); a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); a_Player->UseEquippedItem(); -- cgit v1.2.3 From 6be79575fd50e37ac275bd0cb9d16f9e51e8a225 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Jul 2014 23:10:31 +0200 Subject: Style: Normalized spaces after if, for and while. --- src/Items/ItemHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Items') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 178bc2fca..0a8638f3a 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -263,7 +263,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) void cItemHandler::Deinit() { - for(int i = 0; i < 2267; i++) + for (int i = 0; i < 2267; i++) { delete m_ItemHandler[i]; m_ItemHandler[i] = NULL; -- cgit v1.2.3 From 93d29555e58df172bafba530afbc593c16ec66a3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 15:19:48 +0200 Subject: Style: Normalized to no spaces before closing parenthesis. --- src/Items/ItemFood.h | 2 +- src/Items/ItemHandler.cpp | 2 +- src/Items/ItemPickaxe.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Items') diff --git a/src/Items/ItemFood.h b/src/Items/ItemFood.h index 961cf482d..ff1d7991b 100644 --- a/src/Items/ItemFood.h +++ b/src/Items/ItemFood.h @@ -26,7 +26,7 @@ public: virtual FoodInfo GetFoodInfo(void) override { - switch(m_ItemType) + switch (m_ItemType) { // Please keep alpha-sorted. case E_ITEM_BAKED_POTATO: return FoodInfo(6, 7.2); diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 0a8638f3a..bf1d4e4cb 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -94,7 +94,7 @@ cItemHandler * cItemHandler::GetItemHandler(int a_ItemType) cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) { - switch(a_ItemType) + switch (a_ItemType) { default: return new cItemHandler(a_ItemType); diff --git a/src/Items/ItemPickaxe.h b/src/Items/ItemPickaxe.h index 82bec52d4..647d59b5c 100644 --- a/src/Items/ItemPickaxe.h +++ b/src/Items/ItemPickaxe.h @@ -17,7 +17,7 @@ public: char PickaxeLevel() { - switch(m_ItemType) + switch (m_ItemType) { case E_ITEM_WOODEN_PICKAXE: return 1; case E_ITEM_GOLD_PICKAXE: return 1; @@ -31,7 +31,7 @@ public: virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override { - switch(a_BlockType) + switch (a_BlockType) { case E_BLOCK_OBSIDIAN: { -- cgit v1.2.3 From 3a6002de5b13c1cd56d904892e5af6123978225d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 24 Jul 2014 21:38:25 +0100 Subject: Fixed block drops * Fixes #1242 (the issue addressed within) --- src/Items/ItemHandler.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++---- src/Items/ItemSword.h | 1 - 2 files changed, 43 insertions(+), 5 deletions(-) (limited to 'src/Items') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 1671a8145..23dbb4348 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -330,7 +330,7 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const { cChunkInterface ChunkInterface(a_World->GetChunkMap()); cBlockInServerPluginInterface PluginInterface(*a_World); - Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block)); + Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block), a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0); } a_Player->UseEquippedItem(); @@ -511,9 +511,48 @@ bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType) bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) { - UNUSED(a_BlockType); - - return false; + switch (a_BlockType) + { + case E_BLOCK_ANVIL: + case E_BLOCK_ENCHANTMENT_TABLE: + case E_BLOCK_FURNACE: + case E_BLOCK_LIT_FURNACE: + case E_BLOCK_COAL_ORE: + case E_BLOCK_STONE: + case E_BLOCK_COBBLESTONE: + case E_BLOCK_END_STONE: + case E_BLOCK_MOSSY_COBBLESTONE: + case E_BLOCK_SANDSTONE_STAIRS: + case E_BLOCK_SANDSTONE: + case E_BLOCK_STONE_BRICKS: + case E_BLOCK_NETHER_BRICK: + case E_BLOCK_NETHERRACK: + case E_BLOCK_STONE_SLAB: + case E_BLOCK_DOUBLE_STONE_SLAB: + case E_BLOCK_STONE_PRESSURE_PLATE: + case E_BLOCK_BRICK: + case E_BLOCK_COBBLESTONE_STAIRS: + case E_BLOCK_COBBLESTONE_WALL: + case E_BLOCK_STONE_BRICK_STAIRS: + case E_BLOCK_NETHER_BRICK_STAIRS: + case E_BLOCK_CAULDRON: + case E_BLOCK_OBSIDIAN: + case E_BLOCK_DIAMOND_BLOCK: + case E_BLOCK_DIAMOND_ORE: + case E_BLOCK_GOLD_BLOCK: + case E_BLOCK_GOLD_ORE: + case E_BLOCK_REDSTONE_ORE: + case E_BLOCK_REDSTONE_ORE_GLOWING: + case E_BLOCK_EMERALD_ORE: + case E_BLOCK_IRON_BLOCK: + case E_BLOCK_IRON_ORE: + case E_BLOCK_LAPIS_ORE: + case E_BLOCK_LAPIS_BLOCK: + { + return false; + } + default: return true; + } } diff --git a/src/Items/ItemSword.h b/src/Items/ItemSword.h index 44feb2d83..368b8724e 100644 --- a/src/Items/ItemSword.h +++ b/src/Items/ItemSword.h @@ -16,7 +16,6 @@ public: cItemSwordHandler(int a_ItemType) : cItemHandler(a_ItemType) { - } virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override -- cgit v1.2.3