From 01c01bac37a56bf0d6301eee91483250bf76391d Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 20 Feb 2014 17:45:18 +0100 Subject: Add 'Meta < 3' to Cauldron --- src/Blocks/BlockCauldron.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h index 09d5c3cbb..3e8abf4c9 100644 --- a/src/Blocks/BlockCauldron.h +++ b/src/Blocks/BlockCauldron.h @@ -28,15 +28,18 @@ public: { case E_ITEM_WATER_BUCKET: { - a_ChunkInterface->SetBlockMeta( a_BlockX, a_BlockY, a_BlockZ, 3 ); - a_Player->GetInventory().RemoveOneEquippedItem(); - cItem NewItem(E_ITEM_BUCKET, 1); - a_Player->GetInventory().AddItem(NewItem); + if (Meta < 3) + { + a_ChunkInterface->SetBlockMeta( a_BlockX, a_BlockY, a_BlockZ, 3 ); + a_Player->GetInventory().RemoveOneEquippedItem(); + cItem NewItem(E_ITEM_BUCKET, 1); + a_Player->GetInventory().AddItem(NewItem); + } break; } case E_ITEM_GLASS_BOTTLE: { - if( Meta > 0 ) + if (Meta > 0) { a_ChunkInterface->SetBlockMeta( a_BlockX, a_BlockY, a_BlockZ, --Meta); a_Player->GetInventory().RemoveOneEquippedItem(); -- cgit v1.2.3 From 4b7891f2903998892287b4a98d5f69e0bb4ce58c Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 20 Feb 2014 17:56:35 +0100 Subject: Add Hay Bale to Burnable --- src/Simulator/FireSimulator.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp index d7c5ab3b4..b77fa1658 100644 --- a/src/Simulator/FireSimulator.cpp +++ b/src/Simulator/FireSimulator.cpp @@ -169,6 +169,7 @@ bool cFireSimulator::IsFuel(BLOCKTYPE a_BlockType) case E_BLOCK_FENCE: case E_BLOCK_TNT: case E_BLOCK_VINES: + case E_BLOCK_HAY_BALE: { return true; } -- cgit v1.2.3 From 69961fc4df08efe3689a643814e8bf0edb325eba Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 20 Feb 2014 19:07:32 +0100 Subject: Add Light weighted pressure plates --- src/BlockID.cpp | 4 ++++ src/Simulator/IncrementalRedstoneSimulator.cpp | 28 +++++++++++++++++--------- src/Simulator/SandSimulator.cpp | 2 ++ 3 files changed, 24 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/BlockID.cpp b/src/BlockID.cpp index c38db0bfe..ff1c54e3f 100644 --- a/src/BlockID.cpp +++ b/src/BlockID.cpp @@ -644,9 +644,11 @@ public: g_BlockPistonBreakable[E_BLOCK_DEAD_BUSH] = true; g_BlockPistonBreakable[E_BLOCK_FIRE] = true; g_BlockPistonBreakable[E_BLOCK_FLOWER] = true; + g_BlockPistonBreakable[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE] = true; g_BlockPistonBreakable[E_BLOCK_INACTIVE_COMPARATOR] = true; g_BlockPistonBreakable[E_BLOCK_IRON_DOOR] = true; g_BlockPistonBreakable[E_BLOCK_JACK_O_LANTERN] = true; + g_BlockPistonBreakable[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE] = true; g_BlockPistonBreakable[E_BLOCK_LADDER] = true; g_BlockPistonBreakable[E_BLOCK_LAVA] = true; g_BlockPistonBreakable[E_BLOCK_LEVER] = true; @@ -727,10 +729,12 @@ public: g_BlockRequiresSpecialTool[E_BLOCK_END_STONE] = true; g_BlockRequiresSpecialTool[E_BLOCK_GOLD_BLOCK] = true; g_BlockRequiresSpecialTool[E_BLOCK_GOLD_ORE] = true; + g_BlockRequiresSpecialTool[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE] = true; g_BlockRequiresSpecialTool[E_BLOCK_IRON_BLOCK] = true; g_BlockRequiresSpecialTool[E_BLOCK_IRON_ORE] = true; g_BlockRequiresSpecialTool[E_BLOCK_LAPIS_BLOCK] = true; g_BlockRequiresSpecialTool[E_BLOCK_LAPIS_ORE] = true; + g_BlockRequiresSpecialTool[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE] = true; g_BlockRequiresSpecialTool[E_BLOCK_MOSSY_COBBLESTONE] = true; g_BlockRequiresSpecialTool[E_BLOCK_NETHERRACK] = true; g_BlockRequiresSpecialTool[E_BLOCK_NETHER_BRICK] = true; diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 60dabaf84..ca4bcca04 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -6,10 +6,13 @@ #include "../BlockEntities/NoteEntity.h" #include "../BlockEntities/CommandBlockEntity.h" #include "../Entities/TNTEntity.h" +#include "../Entities/Pickup.h" #include "../Blocks/BlockTorch.h" #include "../Blocks/BlockDoor.h" #include "../Piston.h" +#include + @@ -87,7 +90,8 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, ((Block == E_BLOCK_LEVER) && !IsLeverOn(Meta)) || ((Block == E_BLOCK_DETECTOR_RAIL) && (Meta & 0x08) == 0) || (((Block == E_BLOCK_STONE_BUTTON) || (Block == E_BLOCK_WOODEN_BUTTON)) && (!IsButtonOn(Meta))) || - (((Block == E_BLOCK_STONE_PRESSURE_PLATE) || (Block == E_BLOCK_WOODEN_PRESSURE_PLATE)) && (Meta == 0)) + (((Block == E_BLOCK_STONE_PRESSURE_PLATE) || (Block == E_BLOCK_WOODEN_PRESSURE_PLATE)) && (Meta == 0)) || + (((Block == E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE) || (Block == E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE)) && (Meta == 0)) ) { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); @@ -313,6 +317,8 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int } case E_BLOCK_WOODEN_PRESSURE_PLATE: case E_BLOCK_STONE_PRESSURE_PLATE: + case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: + case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: { HandlePressurePlate(a_X, dataitr->y, a_Z, dataitr->Data); break; @@ -333,13 +339,13 @@ void cIncrementalRedstoneSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_Blo ((a_BlockX % cChunkDef::Width) >= 14) || ((a_BlockZ % cChunkDef::Width) <= 1) || ((a_BlockZ % cChunkDef::Width) >= 14) - ) // Are we on a chunk boundary? ± 2 because of LinkedPowered blocks + ) // Are we on a chunk boundary? \B1 2 because of LinkedPowered blocks { // On a chunk boundary, alert all four sides (i.e. at least one neighbouring chunk) AddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk); // Pass the original coordinates, because when adding things to our simulator lists, we get the chunk that they are in, and therefore any updates need to preseve their position - // RedstoneAddBlock to pass both the neighbouring chunk and the chunk which the coordiantes are in and ± 2 in GetNeighbour() to accomodate for LinkedPowered blocks being 2 away from chunk boundaries + // RedstoneAddBlock to pass both the neighbouring chunk and the chunk which the coordiantes are in and \B1 2 in GetNeighbour() to accomodate for LinkedPowered blocks being 2 away from chunk boundaries RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX - 2, a_BlockZ), a_Chunk); RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX + 2, a_BlockZ), a_Chunk); RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX, a_BlockZ - 2), a_Chunk); @@ -1039,13 +1045,15 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc } break; } + case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: + case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: case E_BLOCK_WOODEN_PRESSURE_PLATE: { - class cWoodenPressurePlateCallback : + class cPressurePlateCallback : public cEntityCallback { public: - cWoodenPressurePlateCallback(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) : + cPressurePlateCallback(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) : m_Entity(NULL), m_World(a_World), m_X(a_BlockX), @@ -1063,7 +1071,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc if (Distance <= 0.7) { m_Entity = a_Entity; - return true; // Break out, we only need to know for wooden plates that at least one entity is on top + return true; // Break out, we only need to know for plates that at least one entity is on top } return false; } @@ -1082,13 +1090,13 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc int m_Z; } ; - cWoodenPressurePlateCallback WoodenPressurePlateCallback(a_BlockX, a_BlockY, a_BlockZ, &m_World); - m_World.ForEachEntity(WoodenPressurePlateCallback); + cPressurePlateCallback PressurePlateCallback(a_BlockX, a_BlockY, a_BlockZ, &m_World); + m_World.ForEachEntity(PressurePlateCallback); - if (WoodenPressurePlateCallback.FoundEntity()) + if (PressurePlateCallback.FoundEntity()) { m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 0x1); - SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_WOODEN_PRESSURE_PLATE); + SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_MyType); } else { diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp index 87fb83357..f305ba61a 100644 --- a/src/Simulator/SandSimulator.cpp +++ b/src/Simulator/SandSimulator.cpp @@ -158,8 +158,10 @@ bool cSandSimulator::CanContinueFallThrough(BLOCKTYPE a_BlockType) case E_BLOCK_DETECTOR_RAIL: case E_BLOCK_FIRE: case E_BLOCK_FLOWER_POT: + case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: case E_BLOCK_LAVA: case E_BLOCK_LEVER: + case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: case E_BLOCK_MINECART_TRACKS: case E_BLOCK_MELON_STEM: case E_BLOCK_POWERED_RAIL: -- cgit v1.2.3 From 4dd39f8cd6e8f0894989e4270e0501dab7ae8f4d Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 20 Feb 2014 19:21:04 +0100 Subject: Add Pressure Plate Sound --- src/Simulator/IncrementalRedstoneSimulator.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index ca4bcca04..b6c573a62 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -1093,13 +1093,22 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc cPressurePlateCallback PressurePlateCallback(a_BlockX, a_BlockY, a_BlockZ, &m_World); m_World.ForEachEntity(PressurePlateCallback); + NIBBLETYPE Meta = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); if (PressurePlateCallback.FoundEntity()) { + if (Meta == 0x0) + { + m_World.BroadcastSoundEffect("random.click", (int) ((a_BlockX + 0.5) * 8.0), (int) ((a_BlockY + 0.1) * 8.0), (int) ((a_BlockZ + 0.5) * 8.0), 0.3F, 0.5F); + } m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 0x1); SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_MyType); } else { + if (Meta == 0x1) + { + m_World.BroadcastSoundEffect("random.click", (int) ((a_BlockX + 0.5) * 8.0), (int) ((a_BlockY + 0.1) * 8.0), (int) ((a_BlockZ + 0.5) * 8.0), 0.3F, 0.6F); + } m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 0x0); m_World.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ); } -- cgit v1.2.3 From 5e7f2ba6d6dba6b931bd54389cddd3077b3a9d93 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 20 Feb 2014 20:41:53 +0100 Subject: Add Wolf Heal with Food --- src/Mobs/Wolf.cpp | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp index 2736c3dd1..0d3619166 100644 --- a/src/Mobs/Wolf.cpp +++ b/src/Mobs/Wolf.cpp @@ -4,6 +4,7 @@ #include "Wolf.h" #include "../World.h" #include "../Entities/Player.h" +#include "../Items/ItemHandler.h" @@ -86,23 +87,44 @@ void cWolf::OnRightClicked(cPlayer & a_Player) } else if (IsTame()) { - if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog? + switch (a_Player.GetEquippedItem().m_ItemType) { - if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE) + case E_ITEM_RAW_BEEF: + case E_ITEM_STEAK: + case E_ITEM_RAW_PORKCHOP: + case E_ITEM_COOKED_PORKCHOP: + case E_ITEM_RAW_CHICKEN: + case E_ITEM_COOKED_CHICKEN: + case E_ITEM_ROTTEN_FLESH: { - SetCollarColor(15 - a_Player.GetEquippedItem().m_ItemDamage); - if (!a_Player.IsGameModeCreative()) + if (m_Health < m_MaxHealth) { - a_Player.GetInventory().RemoveOneEquippedItem(); + Heal(ItemHandler(a_Player.GetEquippedItem().m_ItemType)->GetFoodInfo().FoodLevel); + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } } - } - else if (IsSitting()) + break; + } + case E_ITEM_DYE: { - SetIsSitting(false); + if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog? + { + SetCollarColor(15 - a_Player.GetEquippedItem().m_ItemDamage); + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + break; } - else + default: { - SetIsSitting(true); + if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog? + { + SetIsSitting(!IsSitting()); + } } } } @@ -136,6 +158,8 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk) case E_ITEM_RAW_CHICKEN: case E_ITEM_COOKED_CHICKEN: case E_ITEM_ROTTEN_FLESH: + case E_ITEM_RAW_PORKCHOP: + case E_ITEM_COOKED_PORKCHOP: { if (!IsBegging()) { -- cgit v1.2.3 From 10169220123b19f0ebcfd7330bb52adaf06f4ec0 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 20 Feb 2014 20:58:23 +0100 Subject: Fix Cauldron --- src/Blocks/BlockCauldron.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h index 3e8abf4c9..2e1032d2b 100644 --- a/src/Blocks/BlockCauldron.h +++ b/src/Blocks/BlockCauldron.h @@ -21,19 +21,22 @@ public: a_Pickups.push_back(cItem(E_ITEM_CAULDRON, 1, 0)); } - void OnUse(cChunkInterface * a_ChunkInterface, cWorldInterface * a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { - char Meta = a_ChunkInterface->GetBlockMeta( a_BlockX, a_BlockY, a_BlockZ ); - switch( a_Player->GetEquippedItem().m_ItemType ) + char Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); + switch (a_Player->GetEquippedItem().m_ItemType) { case E_ITEM_WATER_BUCKET: { if (Meta < 3) { - a_ChunkInterface->SetBlockMeta( a_BlockX, a_BlockY, a_BlockZ, 3 ); - a_Player->GetInventory().RemoveOneEquippedItem(); - cItem NewItem(E_ITEM_BUCKET, 1); - a_Player->GetInventory().AddItem(NewItem); + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 3); + if (!a_Player->IsGameModeCreative()) + { + a_Player->GetInventory().RemoveOneEquippedItem(); + cItem NewItem(E_ITEM_BUCKET, 1); + a_Player->GetInventory().AddItem(NewItem); + } } break; } @@ -41,7 +44,7 @@ public: { if (Meta > 0) { - a_ChunkInterface->SetBlockMeta( a_BlockX, a_BlockY, a_BlockZ, --Meta); + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, --Meta); a_Player->GetInventory().RemoveOneEquippedItem(); cItem NewItem(E_ITEM_POTIONS, 1, 0); a_Player->GetInventory().AddItem(NewItem); -- cgit v1.2.3 From d47f421e2db330ce431167843c84dbc61f04ea19 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 20 Feb 2014 21:00:16 +0100 Subject: Remove typeinfo import in IncrementalRedstoneSimulator --- src/Simulator/IncrementalRedstoneSimulator.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index b6c573a62..4459f9c89 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -11,8 +11,6 @@ #include "../Blocks/BlockDoor.h" #include "../Piston.h" -#include - -- cgit v1.2.3 From 337c4e5cd4e666c34efeb6767fdf1357aa6d3bca Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 20 Feb 2014 22:02:14 +0100 Subject: Bad UTF-8 o.O --- src/Simulator/IncrementalRedstoneSimulator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 4459f9c89..1637ac02a 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -337,13 +337,13 @@ void cIncrementalRedstoneSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_Blo ((a_BlockX % cChunkDef::Width) >= 14) || ((a_BlockZ % cChunkDef::Width) <= 1) || ((a_BlockZ % cChunkDef::Width) >= 14) - ) // Are we on a chunk boundary? \B1 2 because of LinkedPowered blocks + ) // Are we on a chunk boundary? ± 2 because of LinkedPowered blocks { // On a chunk boundary, alert all four sides (i.e. at least one neighbouring chunk) AddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk); // Pass the original coordinates, because when adding things to our simulator lists, we get the chunk that they are in, and therefore any updates need to preseve their position - // RedstoneAddBlock to pass both the neighbouring chunk and the chunk which the coordiantes are in and \B1 2 in GetNeighbour() to accomodate for LinkedPowered blocks being 2 away from chunk boundaries + // RedstoneAddBlock to pass both the neighbouring chunk and the chunk which the coordiantes are in and ± 2 in GetNeighbour() to accomodate for LinkedPowered blocks being 2 away from chunk boundaries RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX - 2, a_BlockZ), a_Chunk); RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX + 2, a_BlockZ), a_Chunk); RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX, a_BlockZ - 2), a_Chunk); -- cgit v1.2.3