From d2d0ffee21d10aace8caa20a002daa1c887c1f39 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 4 Aug 2014 19:43:33 -0700 Subject: Fixed unsigned long comparison to size_t --- src/Items/ItemHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 1c1e3b5b9..bceedaf69 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -66,7 +66,7 @@ cItemHandler * cItemHandler::m_ItemHandler[2268]; cItemHandler * cItemHandler::GetItemHandler(int a_ItemType) { - if ((a_ItemType < 0) || ((unsigned long)a_ItemType >= ARRAYCOUNT(m_ItemHandler))) + if ((a_ItemType < 0) || ((size_t)a_ItemType >= ARRAYCOUNT(m_ItemHandler))) { // Either nothing (-1), or bad value, both cases should return the air handler if (a_ItemType < -1) -- cgit v1.2.3 From a92cff20ea59b68827a6f579d0ba9ccb40276d6b Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 5 Aug 2014 13:47:10 +0200 Subject: Added Clamp() function to the lua api. --- src/Bindings/ManualBindings.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 042ffb19e..b41cd94bc 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -82,6 +82,33 @@ static int lua_do_error(lua_State* L, const char * a_pFormat, ...) // Lua bound functions with special return types +static int tolua_Clamp(lua_State * tolua_S) +{ + cLuaState LuaState(tolua_S); + int NumArgs = lua_gettop(LuaState); + if (NumArgs != 3) + { + return lua_do_error(LuaState, "Error in function call '#funcname#': Requires 3 arguments, got %i", NumArgs); + } + + if (!lua_isnumber(LuaState, 1) || !lua_isnumber(LuaState, 2) || !lua_isnumber(LuaState, 3)) + { + return lua_do_error(LuaState, "Error in function call '#funcname#': Expected a number for parameters #1, #2 and #3"); + } + + int Min = (int)tolua_tonumber(LuaState, 1, 0); + int Number = (int)tolua_tonumber(LuaState, 2, 0); + int Max = (int)tolua_tonumber(LuaState, 3, 0); + + int Result = std::min(std::max(Min, Number), Max); + LuaState.Push(Result); + return 1; +} + + + + + static int tolua_StringSplit(lua_State * tolua_S) { cLuaState LuaState(tolua_S); @@ -3103,6 +3130,7 @@ static int tolua_cCompositeChat_UnderlineUrls(lua_State * tolua_S) void ManualBindings::Bind(lua_State * tolua_S) { tolua_beginmodule(tolua_S, NULL); + tolua_function(tolua_S, "Clamp", tolua_Clamp); tolua_function(tolua_S, "StringSplit", tolua_StringSplit); tolua_function(tolua_S, "StringSplitAndTrim", tolua_StringSplitAndTrim); tolua_function(tolua_S, "LOG", tolua_LOG); -- cgit v1.2.3 From 43de9af8786243c90832b78f8c19ec92fb218392 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 5 Aug 2014 13:54:04 +0200 Subject: Added api documentation for Clamp() --- MCServer/Plugins/APIDump/APIDesc.lua | 5 +++-- src/Bindings/ManualBindings.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index ad3b24ca5..64ba80c5f 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2760,15 +2760,16 @@ end Functions = { AddFaceDirection = {Params = "BlockX, BlockY, BlockZ, BlockFace, [IsInverse]", Return = "BlockX, BlockY, BlockZ", Notes = "Returns the coords of a block adjacent to the specified block through the specified {{Globals#BlockFaces|face}}"}, - BlockFaceToString = { Params = "{{Globals#BlockFaces|eBlockFace}}", Return = "string", Notes = "Returns the string representation of the {{Globals#BlockFaces|eBlockFace}} constant. Uses the axis-direction-based names, such as BLOCK_FACE_XP." }, + BlockFaceToString = {Params = "{{Globals#BlockFaces|eBlockFace}}", Return = "string", Notes = "Returns the string representation of the {{Globals#BlockFaces|eBlockFace}} constant. Uses the axis-direction-based names, such as BLOCK_FACE_XP." }, BlockStringToType = {Params = "BlockTypeString", Return = "BLOCKTYPE", Notes = "Returns the block type parsed from the given string"}, + Clamp = {Params = "Number, Min, Max", Return = "number", Notes = "Clamp the number to the specified range."}, ClickActionToString = {Params = "{{Globals#ClickAction|ClickAction}}", Return = "string", Notes = "Returns a string description of the ClickAction enumerated value"}, DamageTypeToString = {Params = "{{Globals#DamageType|DamageType}}", Return = "string", Notes = "Converts the {{Globals#DamageType|DamageType}} enumerated value to a string representation "}, EscapeString = {Params = "string", Return = "string", Notes = "Returns a copy of the string with all quotes and backslashes escaped by a backslash"}, GetChar = {Params = "String, Pos", Return = "string", Notes = "Returns one character from the string, specified by position "}, GetIniItemSet = { Params = "IniFile, SectionName, KeyName, DefaultValue", Return = "{{cItem}}", Notes = "Returns the item that has been read from the specified INI file value. If the value is not present in the INI file, the DefaultValue is stored in the file and parsed as the result. Returns empty item if the value cannot be parsed. " }, GetTime = {Return = "number", Notes = "Returns the current OS time, as a unix time stamp (number of seconds since Jan 1, 1970)"}, - IsBiomeNoDownfall = { Params = "Biome", Return = "bool", Notes = "Returns true if the biome is 'dry', that is, there is no precipitation during rains and storms." }, + IsBiomeNoDownfall = {Params = "Biome", Return = "bool", Notes = "Returns true if the biome is 'dry', that is, there is no precipitation during rains and storms." }, IsValidBlock = {Params = "BlockType", Return = "bool", Notes = "Returns true if BlockType is a known block type"}, IsValidItem = {Params = "ItemType", Return = "bool", Notes = "Returns true if ItemType is a known item type"}, ItemToFullString = {Params = "{{cItem|cItem}}", Return = "string", Notes = "Returns the string representation of the item, in the format 'ItemTypeText:ItemDamage * Count'"}, diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index b41cd94bc..81065a7e1 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -96,8 +96,8 @@ static int tolua_Clamp(lua_State * tolua_S) return lua_do_error(LuaState, "Error in function call '#funcname#': Expected a number for parameters #1, #2 and #3"); } - int Min = (int)tolua_tonumber(LuaState, 1, 0); - int Number = (int)tolua_tonumber(LuaState, 2, 0); + int Number = (int)tolua_tonumber(LuaState, 1, 0); + int Min = (int)tolua_tonumber(LuaState, 2, 0); int Max = (int)tolua_tonumber(LuaState, 3, 0); int Result = std::min(std::max(Min, Number), Max); -- cgit v1.2.3 From 5f04488a97b5cdd705368937d977827ef4465d4a Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 5 Aug 2014 18:39:18 +0200 Subject: Made lua clamp() compatible with all number types. --- src/Bindings/ManualBindings.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 81065a7e1..9ba1501c5 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -96,11 +96,11 @@ static int tolua_Clamp(lua_State * tolua_S) return lua_do_error(LuaState, "Error in function call '#funcname#': Expected a number for parameters #1, #2 and #3"); } - int Number = (int)tolua_tonumber(LuaState, 1, 0); - int Min = (int)tolua_tonumber(LuaState, 2, 0); - int Max = (int)tolua_tonumber(LuaState, 3, 0); + lua_Number Number = tolua_tonumber(LuaState, 1, 0); + lua_Number Min = tolua_tonumber(LuaState, 2, 0); + lua_Number Max = tolua_tonumber(LuaState, 3, 0); - int Result = std::min(std::max(Min, Number), Max); + lua_Number Result = Clamp(Number, Min, Max); LuaState.Push(Result); return 1; } -- cgit v1.2.3 From 06942871dde1388284a4fe222040720de3923b03 Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 5 Aug 2014 21:48:23 +0100 Subject: Refactored Redstone simulator not to depend on TNTEntity or DropSpenserENtity Directly --- src/BlockEntities/DropSpenserEntity.h | 7 +++--- src/BlockEntities/RedstonePoweredEntity.h | 9 +++++++ src/Chunk.cpp | 34 ++++++++++++++++++++++++++ src/Chunk.h | 6 ++++- src/Simulator/IncrementalRedstoneSimulator.cpp | 9 +++---- 5 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 src/BlockEntities/RedstonePoweredEntity.h diff --git a/src/BlockEntities/DropSpenserEntity.h b/src/BlockEntities/DropSpenserEntity.h index 9f58d0b07..dabe9a27b 100644 --- a/src/BlockEntities/DropSpenserEntity.h +++ b/src/BlockEntities/DropSpenserEntity.h @@ -11,7 +11,7 @@ #pragma once #include "BlockEntityWithItems.h" - +#include "RedstonePoweredEntity.h" @@ -30,7 +30,8 @@ class cServer; // tolua_begin class cDropSpenserEntity : - public cBlockEntityWithItems + public cBlockEntityWithItems, + public cRedstonePoweredEntity { typedef cBlockEntityWithItems super; @@ -65,7 +66,7 @@ public: void Activate(void); /// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate - void SetRedstonePower(bool a_IsPowered); + virtual void SetRedstonePower(bool a_IsPowered) override; // tolua_end diff --git a/src/BlockEntities/RedstonePoweredEntity.h b/src/BlockEntities/RedstonePoweredEntity.h new file mode 100644 index 000000000..aebba771f --- /dev/null +++ b/src/BlockEntities/RedstonePoweredEntity.h @@ -0,0 +1,9 @@ + + +// Interface class representing a blockEntity that responds to redstone +class cRedstonePoweredEntity +{ +public: +/// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate + virtual void SetRedstonePower(bool a_IsPowered) = 0; +}; diff --git a/src/Chunk.cpp b/src/Chunk.cpp index cd7dc698c..9e06f58ec 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -2127,6 +2127,40 @@ bool cChunk::DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBloc +bool cChunk::DoWithRedstonePoweredEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cRedstonePoweredCallback & a_Callback) +{ + // The blockentity list is locked by the parent chunkmap's CS + for (cBlockEntityList::iterator itr = m_BlockEntities.begin(), itr2 = itr; itr != m_BlockEntities.end(); itr = itr2) + { + ++itr2; + if (((*itr)->GetPosX() != a_BlockX) || ((*itr)->GetPosY() != a_BlockY) || ((*itr)->GetPosZ() != a_BlockZ)) + { + continue; + } + switch ((*itr)->GetBlockType()) + { + case E_BLOCK_DROPPER: + case E_BLOCK_DISPENSER: + break; + default: + // There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out + return false; + } + + if (a_Callback.Item((cRedstonePoweredEntity *)*itr)) + { + return false; + } + return true; + } // for itr - m_BlockEntitites[] + + // Not found: + return false; +} + + + + bool cChunk::DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconCallback & a_Callback) { // The blockentity list is locked by the parent chunkmap's CS diff --git a/src/Chunk.h b/src/Chunk.h index 5cde3f08f..813a8b13f 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -43,6 +43,7 @@ class cBlockArea; class cFluidSimulatorData; class cMobCensus; class cMobSpawner; +class cRedstonePoweredEntity; typedef std::list cClientHandleList; typedef cItemCallback cEntityCallback; @@ -54,6 +55,7 @@ typedef cItemCallback cNoteBlockCallback; typedef cItemCallback cCommandBlockCallback; typedef cItemCallback cMobHeadCallback; typedef cItemCallback cFlowerPotCallback; +typedef cItemCallback cRedstonePoweredCallback; @@ -237,7 +239,9 @@ public: /** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, true if found */ bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback); // Lua-acessible - + + /** Calls the callback for the redstone powered entity at the specified coords; returns false if there's no redstone powered entity at those coords, true if found */ + bool DoWithRedstonePoweredEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cRedstonePoweredCallback & a_Callback); /** Calls the callback for the beacon at the specified coords; returns false if there's no beacon at those coords, true if found */ bool DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconCallback & a_Callback); // Lua-acessible diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index c1a2fcaae..5b2439db1 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -3,11 +3,10 @@ #include "IncrementalRedstoneSimulator.h" #include "BoundingBox.h" -#include "../BlockEntities/DropSpenserEntity.h" +#include "../BlockEntities/RedstonePoweredEntity.h" #include "../BlockEntities/NoteEntity.h" #include "../BlockEntities/ChestEntity.h" #include "../BlockEntities/CommandBlockEntity.h" -#include "../Entities/TNTEntity.h" #include "../Entities/Pickup.h" #include "../Blocks/BlockTorch.h" #include "../Blocks/BlockDoor.h" @@ -842,13 +841,13 @@ void cIncrementalRedstoneSimulator::HandlePiston(int a_RelBlockX, int a_RelBlock void cIncrementalRedstoneSimulator::HandleDropSpenser(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { class cSetPowerToDropSpenser : - public cDropSpenserCallback + public cRedstonePoweredCallback { bool m_IsPowered; public: cSetPowerToDropSpenser(bool a_IsPowered) : m_IsPowered(a_IsPowered) {} - virtual bool Item(cDropSpenserEntity * a_DropSpenser) override + virtual bool Item(cRedstonePoweredEntity * a_DropSpenser) override { a_DropSpenser->SetRedstonePower(m_IsPowered); return false; @@ -857,7 +856,7 @@ void cIncrementalRedstoneSimulator::HandleDropSpenser(int a_RelBlockX, int a_Rel int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; - m_Chunk->DoWithDropSpenserAt(BlockX, a_RelBlockY, BlockZ, DrSpSP); + m_Chunk->DoWithRedstonePoweredEntityAt(BlockX, a_RelBlockY, BlockZ, DrSpSP); } -- cgit v1.2.3 From 9272bd627c732771b81e6dcf6b8465404917a9d6 Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 5 Aug 2014 22:54:36 +0100 Subject: Removed dependecy of redstone simulator on NoteBlock --- src/BlockEntities/NoteEntity.h | 10 +++++++++- src/BlockEntities/RedstonePoweredEntity.h | 4 ++++ src/Chunk.cpp | 1 + src/Simulator/IncrementalRedstoneSimulator.cpp | 17 ++++++----------- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h index e8497da3e..f9db6cbe6 100644 --- a/src/BlockEntities/NoteEntity.h +++ b/src/BlockEntities/NoteEntity.h @@ -2,6 +2,7 @@ #pragma once #include "BlockEntity.h" +#include "RedstonePoweredEntity.h" namespace Json @@ -29,7 +30,8 @@ enum ENUM_NOTE_INSTRUMENTS // tolua_begin class cNoteEntity : - public cBlockEntity + public cBlockEntity, + public cRedstonePoweredEntity { typedef cBlockEntity super; public: @@ -38,6 +40,7 @@ public: /// Creates a new note entity. a_World may be NULL cNoteEntity(int a_X, int a_Y, int a_Z, cWorld * a_World); + virtual ~cNoteEntity() {} bool LoadFromJson(const Json::Value & a_Value); virtual void SaveToJson(Json::Value & a_Value) override; @@ -53,6 +56,11 @@ public: virtual void UsedBy(cPlayer * a_Player) override; virtual void SendTo(cClientHandle &) override {} + + virtual void SetRedstonePower(bool a_Value) + { + if (a_Value) MakeSound(); + } static const char * GetClassStatic(void) { return "cNoteEntity"; } diff --git a/src/BlockEntities/RedstonePoweredEntity.h b/src/BlockEntities/RedstonePoweredEntity.h index aebba771f..7d6904442 100644 --- a/src/BlockEntities/RedstonePoweredEntity.h +++ b/src/BlockEntities/RedstonePoweredEntity.h @@ -1,9 +1,13 @@ +#pragma once // Interface class representing a blockEntity that responds to redstone class cRedstonePoweredEntity { public: + + virtual ~cRedstonePoweredEntity() {}; + /// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate virtual void SetRedstonePower(bool a_IsPowered) = 0; }; diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 9e06f58ec..1e8d0e6f0 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -2141,6 +2141,7 @@ bool cChunk::DoWithRedstonePoweredEntityAt(int a_BlockX, int a_BlockY, int a_Blo { case E_BLOCK_DROPPER: case E_BLOCK_DISPENSER: + case E_BLOCK_NOTE_BLOCK: break; default: // There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 5b2439db1..7b3a2c2fa 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -4,7 +4,6 @@ #include "IncrementalRedstoneSimulator.h" #include "BoundingBox.h" #include "../BlockEntities/RedstonePoweredEntity.h" -#include "../BlockEntities/NoteEntity.h" #include "../BlockEntities/ChestEntity.h" #include "../BlockEntities/CommandBlockEntity.h" #include "../Entities/Pickup.h" @@ -1033,25 +1032,21 @@ void cIncrementalRedstoneSimulator::HandleNoteBlock(int a_RelBlockX, int a_RelBl if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true)) { class cSetPowerToNoteBlock : - public cNoteBlockCallback + public cRedstonePoweredCallback { - bool m_IsPowered; public: - cSetPowerToNoteBlock(bool a_IsPowered) : m_IsPowered(a_IsPowered) {} + cSetPowerToNoteBlock() {} - virtual bool Item(cNoteEntity * a_NoteBlock) override + virtual bool Item(cRedstonePoweredEntity * a_NoteBlock) override { - if (m_IsPowered) - { - a_NoteBlock->MakeSound(); - } + a_NoteBlock->SetRedstonePower(true); return false; } - } NoteBlockSP(m_bAreCoordsPowered); + } NoteBlockSP; int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; - m_Chunk->DoWithNoteBlockAt(BlockX, a_RelBlockY, BlockZ, NoteBlockSP); + m_Chunk->DoWithRedstonePoweredEntityAt(BlockX, a_RelBlockY, BlockZ, NoteBlockSP); SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true); } } -- cgit v1.2.3 From ff7171fc5a567590dd52d4213439778f0dfcce53 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 6 Aug 2014 14:04:25 +0200 Subject: Resending fire to the client when the interact cancelled. --- src/ClientHandle.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 72257028a..3e046f38d 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -920,6 +920,10 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB ) { m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + if (cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))->IsClickedThrough()) + { + m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); + } return; } @@ -928,6 +932,10 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB { // A plugin doesn't agree with the action, replace the block on the client and quit: m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + if (cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))->IsClickedThrough()) + { + m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); + } return; } -- cgit v1.2.3 From a0ba7426c6bc2059d5db6d248ef8e582e40ce4b3 Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 6 Aug 2014 13:17:05 +0100 Subject: Fixed multiple inhertance being output by tolua --- src/BlockEntities/DropSpenserEntity.h | 10 ++++++---- src/BlockEntities/NoteEntity.h | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/BlockEntities/DropSpenserEntity.h b/src/BlockEntities/DropSpenserEntity.h index dabe9a27b..be56447aa 100644 --- a/src/BlockEntities/DropSpenserEntity.h +++ b/src/BlockEntities/DropSpenserEntity.h @@ -30,8 +30,10 @@ class cServer; // tolua_begin class cDropSpenserEntity : - public cBlockEntityWithItems, - public cRedstonePoweredEntity + public cBlockEntityWithItems + // tolua_end + , public cRedstonePoweredEntity + // tolua_begin { typedef cBlockEntityWithItems super; @@ -65,10 +67,10 @@ public: /// Sets the dropspenser to dropspense an item in the next tick void Activate(void); + // tolua_end + /// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate virtual void SetRedstonePower(bool a_IsPowered) override; - - // tolua_end protected: bool m_ShouldDropSpense; ///< If true, the dropspenser will dropspense an item in the next tick diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h index f9db6cbe6..dd201e0a9 100644 --- a/src/BlockEntities/NoteEntity.h +++ b/src/BlockEntities/NoteEntity.h @@ -30,8 +30,10 @@ enum ENUM_NOTE_INSTRUMENTS // tolua_begin class cNoteEntity : - public cBlockEntity, - public cRedstonePoweredEntity + public cBlockEntity + // tolua_end + , public cRedstonePoweredEntity + // tolua_begin { typedef cBlockEntity super; public: -- cgit v1.2.3 From 6acddd0cad25078ae2c67e7a0eb353e9d4d100e2 Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 6 Aug 2014 13:19:22 +0100 Subject: Fixed style issues --- src/BlockEntities/NoteEntity.h | 5 ++++- src/BlockEntities/RedstonePoweredEntity.h | 2 +- src/Chunk.cpp | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h index dd201e0a9..f538de060 100644 --- a/src/BlockEntities/NoteEntity.h +++ b/src/BlockEntities/NoteEntity.h @@ -61,7 +61,10 @@ public: virtual void SetRedstonePower(bool a_Value) { - if (a_Value) MakeSound(); + if (a_Value) + { + MakeSound(); + } } static const char * GetClassStatic(void) { return "cNoteEntity"; } diff --git a/src/BlockEntities/RedstonePoweredEntity.h b/src/BlockEntities/RedstonePoweredEntity.h index 7d6904442..f11df4fc4 100644 --- a/src/BlockEntities/RedstonePoweredEntity.h +++ b/src/BlockEntities/RedstonePoweredEntity.h @@ -8,6 +8,6 @@ public: virtual ~cRedstonePoweredEntity() {}; -/// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate + /// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate virtual void SetRedstonePower(bool a_IsPowered) = 0; }; diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 1e8d0e6f0..a79a485a6 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -2142,10 +2142,10 @@ bool cChunk::DoWithRedstonePoweredEntityAt(int a_BlockX, int a_BlockY, int a_Blo case E_BLOCK_DROPPER: case E_BLOCK_DISPENSER: case E_BLOCK_NOTE_BLOCK: - break; + break; default: - // There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out - return false; + // There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out + return false; } if (a_Callback.Item((cRedstonePoweredEntity *)*itr)) -- cgit v1.2.3 From beab61bbfeca0280bce941c4175837109282c828 Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 6 Aug 2014 14:16:36 -0700 Subject: On destroy ender crystal, create bedrock and fire --- src/Entities/EnderCrystal.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Entities/EnderCrystal.cpp b/src/Entities/EnderCrystal.cpp index bf86a6c42..c17bb608e 100644 --- a/src/Entities/EnderCrystal.cpp +++ b/src/Entities/EnderCrystal.cpp @@ -32,9 +32,6 @@ void cEnderCrystal::SpawnOn(cClientHandle & a_ClientHandle) void cEnderCrystal::Tick(float a_Dt, cChunk & a_Chunk) { UNUSED(a_Dt); - - a_Chunk.SetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT, E_BLOCK_FIRE, 0); - // No further processing (physics e.t.c.) is needed } @@ -49,6 +46,9 @@ void cEnderCrystal::KilledBy(TakeDamageInfo & a_TDI) m_World->DoExplosionAt(6.0, GetPosX(), GetPosY(), GetPosZ(), true, esEnderCrystal, this); Destroy(); + + m_World->SetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT, E_BLOCK_BEDROCK, 0); + m_World->SetBlock(POSX_TOINT, POSY_TOINT + 1, POSZ_TOINT, E_BLOCK_FIRE, 0); } -- cgit v1.2.3 From 0c622522ea52ed07aa12a25827b498acd290b531 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 7 Aug 2014 01:08:31 +0200 Subject: Removed debug message. --- src/Bindings/ManualBindings.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 9ba1501c5..8e6156d97 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -507,7 +507,6 @@ static int tolua_DoWithXYZ(lua_State* tolua_S) int ItemX = ((int)tolua_tonumber(tolua_S, 2, 0)); int ItemY = ((int)tolua_tonumber(tolua_S, 3, 0)); int ItemZ = ((int)tolua_tonumber(tolua_S, 4, 0)); - LOG("x %i y %i z %i", ItemX, ItemY, ItemZ); if (!lua_isfunction( tolua_S, 5)) { return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a function for parameter #4"); -- cgit v1.2.3 From a73c85d7eb8181b3792f19675c29f43bd8c0b738 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 7 Aug 2014 02:42:42 +0200 Subject: Fixed nether wart digging. Fixes #1265 --- src/BlockInfo.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 4bc3fbbdc..a59229f87 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -294,6 +294,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_OneHitDig = true; a_Info[E_BLOCK_LILY_PAD ].m_OneHitDig = true; a_Info[E_BLOCK_MELON_STEM ].m_OneHitDig = true; + a_Info[E_BLOCK_NETHER_WART ].m_OneHitDig = true; a_Info[E_BLOCK_POTATOES ].m_OneHitDig = true; a_Info[E_BLOCK_PUMPKIN_STEM ].m_OneHitDig = true; a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_OneHitDig = true; -- cgit v1.2.3