From 8ca150b7009119fbf46f9b6c6376b63d19f836de Mon Sep 17 00:00:00 2001 From: "luksor111@gmail.com" Date: Tue, 27 Nov 2012 19:55:23 +0000 Subject: Added initial adventure mode support Added missing Emerald crafting recipe You get more fall damage when jumping Torch no longer protects players from fall damage Fixed Ender Chest drops git-svn-id: http://mc-server.googlecode.com/svn/trunk@1070 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- MCServer/crafting.txt | 1 + VC2008/MCServer.vcproj | 4 ++++ source/Blocks/BlockEnderchest.h | 28 ++++++++++++++++++++++++++++ source/Blocks/BlockHandler.cpp | 2 ++ source/Blocks/BlockMycelium.h | 2 -- source/Defines.h | 7 ++++--- source/Player.cpp | 8 ++++++-- source/Player.h | 1 + 8 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 source/Blocks/BlockEnderchest.h diff --git a/MCServer/crafting.txt b/MCServer/crafting.txt index 14bbd5eed..541e5781d 100644 --- a/MCServer/crafting.txt +++ b/MCServer/crafting.txt @@ -277,6 +277,7 @@ IronIngot, 9 = IronBlock, * GoldIngot, 9 = GoldBlock, * Diamond, 9 = DiamondBlock, * LapisLazuli, 9 = LapisBlock, * +Emerald, 9 = EmeraldBlock, * Painting = Stick, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | Wool, 2:2 ItemFrame = Stick, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | Leather, 2:2 diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index 9f9132cb4..6646bc148 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -1794,6 +1794,10 @@ RelativePath="..\source\blocks\BlockDoor.h" > + + diff --git a/source/Blocks/BlockEnderchest.h b/source/Blocks/BlockEnderchest.h new file mode 100644 index 000000000..b40deb1f7 --- /dev/null +++ b/source/Blocks/BlockEnderchest.h @@ -0,0 +1,28 @@ + +#pragma once + +#include "BlockHandler.h" + + + + + +class cBlockEnderchestHandler : + public cBlockHandler +{ +public: + cBlockEnderchestHandler(BLOCKTYPE a_BlockType) + : cBlockHandler(a_BlockType) + { + } + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + //todo: Drop Ender Chest if using silk touch pickaxe + a_Pickups.push_back(cItem(E_BLOCK_OBSIDIAN, 8, 0)); + } +} ; + + + + diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp index 3f63de89f..3fb96f6a0 100644 --- a/source/Blocks/BlockHandler.cpp +++ b/source/Blocks/BlockHandler.cpp @@ -47,6 +47,7 @@ #include "BlockMycelium.h" #include "BlockRail.h" #include "BlockGlass.h" +#include "BlockEnderchest.h" @@ -100,6 +101,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_DOUBLE_STONE_SLAB: return new cBlockSlabHandler (a_BlockType); case E_BLOCK_DOUBLE_WOODEN_SLAB: return new cBlockSlabHandler (a_BlockType); case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType); + case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType); case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler; case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType); case E_BLOCK_FURNACE: return new cBlockFurnaceHandler (a_BlockType); diff --git a/source/Blocks/BlockMycelium.h b/source/Blocks/BlockMycelium.h index 57b45dfe1..8e1f577e1 100644 --- a/source/Blocks/BlockMycelium.h +++ b/source/Blocks/BlockMycelium.h @@ -2,8 +2,6 @@ #pragma once #include "BlockHandler.h" -#include "../MersenneTwister.h" -#include "../World.h" diff --git a/source/Defines.h b/source/Defines.h index 18d495a53..4f3bb46eb 100644 --- a/source/Defines.h +++ b/source/Defines.h @@ -354,9 +354,10 @@ inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockType) //tolua_begin enum eGameMode { - eGameMode_NotSet = -1, - eGameMode_Survival = 0, - eGameMode_Creative = 1 + eGameMode_NotSet = -1, + eGameMode_Survival = 0, + eGameMode_Creative = 1, + eGameMode_Adventure = 2 }; diff --git a/source/Player.cpp b/source/Player.cpp index cd4c6d11c..fea438146 100644 --- a/source/Player.cpp +++ b/source/Player.cpp @@ -96,6 +96,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) a_PlayerName.c_str(), m_Pos.x, m_Pos.y, m_Pos.z ); } + m_LastJumpHeight = (float)(m_Pos.y); m_LastGroundHeight = (float)(m_Pos.y); m_Stance = m_Pos.y + 1.62; } @@ -273,6 +274,7 @@ void cPlayer::SetTouchGround(bool a_bTouchGround) if (!m_bTouchGround) { + if(m_Pos.y > m_LastJumpHeight) m_LastJumpHeight = m_Pos.y; cWorld* World = GetWorld(); char BlockID = World->GetBlock( float2int(m_Pos.x), float2int(m_Pos.y), float2int(m_Pos.z) ); if( BlockID != E_BLOCK_AIR ) @@ -280,7 +282,7 @@ void cPlayer::SetTouchGround(bool a_bTouchGround) // LOGD("TouchGround set to true by server"); m_bTouchGround = true; } - if( BlockID == E_BLOCK_WATER || BlockID == E_BLOCK_STATIONARY_WATER || BlockID == E_BLOCK_LADDER || BlockID == E_BLOCK_TORCH ) + if( BlockID == E_BLOCK_WATER || BlockID == E_BLOCK_STATIONARY_WATER || BlockID == E_BLOCK_LADDER || BlockID == E_BLOCK_VINES ) { // LOGD("Water / Ladder / Torch"); m_LastGroundHeight = (float)m_Pos.y; @@ -291,6 +293,8 @@ void cPlayer::SetTouchGround(bool a_bTouchGround) { float Dist = (float)(m_LastGroundHeight - m_Pos.y); int Damage = (int)(Dist - 3.f); + if(m_LastJumpHeight > m_LastGroundHeight) Damage++; + m_LastJumpHeight = m_Pos.y; if (Damage > 0) { TakeDamage(Damage, 0); @@ -493,7 +497,7 @@ void cPlayer::SetLastBlockActionCnt( int a_LastBlockActionCnt ) void cPlayer::SetGameMode(eGameMode a_GameMode) { - if ((a_GameMode >= 2) || (a_GameMode < 0)) + if ((a_GameMode >= 3) || (a_GameMode < 0)) { LOGWARNING("%s: Setting invalid gamemode: %d", GetName().c_str(), a_GameMode); return; diff --git a/source/Player.h b/source/Player.h index 4800ed759..d24850a19 100644 --- a/source/Player.h +++ b/source/Player.h @@ -145,6 +145,7 @@ protected: float m_FoodExhaustionLevel; char m_FoodTickTimer; + float m_LastJumpHeight; float m_LastGroundHeight; bool m_bTouchGround; double m_Stance; -- cgit v1.2.3