diff options
Diffstat (limited to 'src/Blocks')
-rw-r--r-- | src/Blocks/BlockBed.cpp | 9 | ||||
-rw-r--r-- | src/Blocks/BlockBed.h | 8 | ||||
-rw-r--r-- | src/Blocks/BlockBigFlower.h | 2 | ||||
-rw-r--r-- | src/Blocks/BlockDirt.h | 4 | ||||
-rw-r--r-- | src/Blocks/BlockDoor.cpp | 1 | ||||
-rw-r--r-- | src/Blocks/BlockDoor.h | 1 | ||||
-rw-r--r-- | src/Blocks/BlockHandler.cpp | 19 | ||||
-rw-r--r-- | src/Blocks/BlockHandler.h | 8 | ||||
-rw-r--r-- | src/Blocks/BlockMobHead.h | 4 | ||||
-rw-r--r-- | src/Blocks/BlockPiston.cpp | 1 | ||||
-rw-r--r-- | src/Blocks/BlockPiston.h | 3 | ||||
-rw-r--r-- | src/Blocks/BlockPortal.h | 2 | ||||
-rw-r--r-- | src/Blocks/BlockPumpkin.h | 6 | ||||
-rw-r--r-- | src/Blocks/BlockRedstoneRepeater.h | 2 | ||||
-rw-r--r-- | src/Blocks/BlockSeaLantern.h | 30 | ||||
-rw-r--r-- | src/Blocks/BlockSlab.h | 5 | ||||
-rw-r--r-- | src/Blocks/BlockVine.h | 2 | ||||
-rw-r--r-- | src/Blocks/ChunkInterface.cpp | 133 | ||||
-rw-r--r-- | src/Blocks/ChunkInterface.h | 66 | ||||
-rw-r--r-- | src/Blocks/GetHandlerCompileTimeTemplate.h | 91 | ||||
-rw-r--r-- | src/Blocks/WorldInterface.h | 7 |
21 files changed, 327 insertions, 77 deletions
diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index cd1cc2a5f..3b6328b38 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -4,6 +4,15 @@ +#include "BroadcastInterface.h" +#include "ChunkInterface.h" +#include "Entities/../World.h" +#include "Entities/Player.h" +#include "WorldInterface.h" + + + + void cBlockBedHandler::OnPlacedByPlayer( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h index bf9d9c01d..9fd45644b 100644 --- a/src/Blocks/BlockBed.h +++ b/src/Blocks/BlockBed.h @@ -2,12 +2,14 @@ #pragma once #include "BlockHandler.h" -#include "ChunkInterface.h" -#include "WorldInterface.h" #include "MetaRotator.h" -#include "../Entities/Player.h" +#include "Item.h" +class cChunkInterface; +class cPlayer; +class cWorldInterface; + diff --git a/src/Blocks/BlockBigFlower.h b/src/Blocks/BlockBigFlower.h index 89ffc864d..3577bdd40 100644 --- a/src/Blocks/BlockBigFlower.h +++ b/src/Blocks/BlockBigFlower.h @@ -2,7 +2,7 @@ #pragma once #include "BlockHandler.h" - +#include "ChunkInterface.h" diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h index 23e5a3cde..60d81db72 100644 --- a/src/Blocks/BlockDirt.h +++ b/src/Blocks/BlockDirt.h @@ -3,8 +3,8 @@ #include "BlockHandler.h" #include "../FastRandom.h" - - +#include "Root.h" +#include "Bindings/PluginManager.h" diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp index 1a277f071..96345a2df 100644 --- a/src/Blocks/BlockDoor.cpp +++ b/src/Blocks/BlockDoor.cpp @@ -1,7 +1,6 @@ #include "Globals.h" #include "BlockDoor.h" -#include "../Item.h" #include "../Entities/Player.h" diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index 69e30d9c8..b2f9e4dcd 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -5,6 +5,7 @@ #include "../Entities/Player.h" #include "Chunk.h" #include "MetaRotator.h" +#include "ChunkInterface.h" diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 30b303cfd..7bfff0545 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -3,8 +3,6 @@ #include "BlockHandler.h" #include "../Item.h" #include "../World.h" -#include "../Root.h" -#include "../Bindings/PluginManager.h" #include "../Chunk.h" #include "BlockAnvil.h" #include "BlockBed.h" @@ -68,6 +66,7 @@ #include "BlockTripwireHook.h" #include "BlockSand.h" #include "BlockSapling.h" +#include "BlockSeaLantern.h" #include "BlockSideways.h" #include "BlockSignPost.h" #include "BlockSlab.h" @@ -84,6 +83,8 @@ #include "BlockWorkbench.h" +#include "BlockPluginInterface.h" + @@ -177,12 +178,16 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) switch (a_BlockType) { // Block handlers, alphabetically sorted: + case E_BLOCK_ACACIA_DOOR: return new cBlockDoorHandler (a_BlockType); + case E_BLOCK_ACACIA_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType); case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_ACTIVATOR_RAIL: return new cBlockRailHandler (a_BlockType); case E_BLOCK_ANVIL: return new cBlockAnvilHandler (a_BlockType); case E_BLOCK_BEACON: return new cBlockEntityHandler (a_BlockType); case E_BLOCK_BED: return new cBlockBedHandler (a_BlockType); case E_BLOCK_BIG_FLOWER: return new cBlockBigFlowerHandler (a_BlockType); + case E_BLOCK_BIRCH_DOOR: return new cBlockDoorHandler (a_BlockType); + case E_BLOCK_BIRCH_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType); case E_BLOCK_BIRCH_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_BREWING_STAND: return new cBlockBrewingStandHandler (a_BlockType); case E_BLOCK_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType); @@ -200,12 +205,15 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_COBBLESTONE_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_COBWEB: return new cBlockCobWebHandler (a_BlockType); case E_BLOCK_CROPS: return new cBlockCropsHandler (a_BlockType); + case E_BLOCK_DARK_OAK_DOOR: return new cBlockDoorHandler (a_BlockType); + case E_BLOCK_DARK_OAK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType); case E_BLOCK_DARK_OAK_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_DEAD_BUSH: return new cBlockDeadBushHandler (a_BlockType); case E_BLOCK_DETECTOR_RAIL: return new cBlockRailHandler (a_BlockType); case E_BLOCK_DIAMOND_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_DIRT: return new cBlockDirtHandler (a_BlockType); case E_BLOCK_DISPENSER: return new cBlockDropSpenserHandler (a_BlockType); + case E_BLOCK_DOUBLE_NEW_STONE_SLAB: return new cBlockDoubleSlabHandler (a_BlockType); case E_BLOCK_DOUBLE_STONE_SLAB: return new cBlockDoubleSlabHandler (a_BlockType); case E_BLOCK_DOUBLE_WOODEN_SLAB: return new cBlockDoubleSlabHandler (a_BlockType); case E_BLOCK_DROPPER: return new cBlockDropSpenserHandler (a_BlockType); @@ -231,8 +239,11 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_INACTIVE_COMPARATOR: return new cBlockComparatorHandler (a_BlockType); case E_BLOCK_IRON_DOOR: return new cBlockDoorHandler (a_BlockType); case E_BLOCK_IRON_ORE: return new cBlockOreHandler (a_BlockType); + case E_BLOCK_IRON_TRAPDOOR: return new cBlockTrapdoorHandler (a_BlockType); case E_BLOCK_JACK_O_LANTERN: return new cBlockPumpkinHandler (a_BlockType); case E_BLOCK_JUKEBOX: return new cBlockEntityHandler (a_BlockType); + case E_BLOCK_JUNGLE_DOOR: return new cBlockDoorHandler (a_BlockType); + case E_BLOCK_JUNGLE_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType); case E_BLOCK_JUNGLE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_LADDER: return new cBlockLadderHandler (a_BlockType); case E_BLOCK_LEVER: return new cBlockLeverHandler (a_BlockType); @@ -253,6 +264,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_NETHER_QUARTZ_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_NEW_LEAVES: return new cBlockLeavesHandler (a_BlockType); case E_BLOCK_NEW_LOG: return new cBlockSidewaysHandler (a_BlockType); + case E_BLOCK_NEW_STONE_SLAB: return new cBlockSlabHandler (a_BlockType); case E_BLOCK_NOTE_BLOCK: return new cBlockEntityHandler (a_BlockType); case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType); case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler; @@ -264,6 +276,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_QUARTZ_BLOCK: return new cBlockQuartzHandler (a_BlockType); case E_BLOCK_QUARTZ_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_RAIL: return new cBlockRailHandler (a_BlockType); + case E_BLOCK_RED_SANDSTONE_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_REDSTONE_LAMP_ON: return new cBlockRedstoneLampHandler (a_BlockType); case E_BLOCK_REDSTONE_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_REDSTONE_ORE_GLOWING: return new cBlockOreHandler (a_BlockType); @@ -277,8 +290,10 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_SAND: return new cBlockSandHandler (a_BlockType); case E_BLOCK_SANDSTONE_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_SAPLING: return new cBlockSaplingHandler (a_BlockType); + case E_BLOCK_SEA_LANTERN: return new cBlockSeaLanternHandler (a_BlockType); case E_BLOCK_SIGN_POST: return new cBlockSignPostHandler (a_BlockType); case E_BLOCK_SNOW: return new cBlockSnowHandler (a_BlockType); + case E_BLOCK_SPRUCE_DOOR: return new cBlockDoorHandler (a_BlockType); case E_BLOCK_SPRUCE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_STAINED_GLASS: return new cBlockGlassHandler (a_BlockType); case E_BLOCK_STAINED_GLASS_PANE: return new cBlockGlassHandler (a_BlockType); diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 3a8115da0..83de836cb 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -2,10 +2,6 @@ #pragma once #include "../Defines.h" -#include "../Item.h" -#include "WorldInterface.h" -#include "ChunkInterface.h" -#include "BlockPluginInterface.h" @@ -14,6 +10,10 @@ // fwd: class cPlayer; class cChunk; +class cBlockPluginInterface; +class cChunkInterface; +class cWorldInterface; +class cItems; diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index b51155802..e21e42334 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -151,7 +151,7 @@ public: a_ChunkInterface.SetBlock(a_BlockX - 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); // Spawn the wither: - a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither); + a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtWither); // Award Achievement a_WorldInterface.ForEachPlayer(PlayerCallback); @@ -181,7 +181,7 @@ public: a_ChunkInterface.SetBlock(a_BlockX, a_BlockY, a_BlockZ - 1, E_BLOCK_AIR, 0); // Spawn the wither: - a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither); + a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtWither); // Award Achievement a_WorldInterface.ForEachPlayer(PlayerCallback); diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index 0169fb266..34d11f675 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -5,6 +5,7 @@ #include "../World.h" #include "../Entities/Player.h" #include "BlockInServerPluginInterface.h" +#include "ChunkInterface.h" diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h index 0bec603e3..3a3fc7224 100644 --- a/src/Blocks/BlockPiston.h +++ b/src/Blocks/BlockPiston.h @@ -4,7 +4,7 @@ #include "BlockHandler.h" - +class cWorld; class cBlockPistonHandler : @@ -94,6 +94,7 @@ private: switch (a_BlockType) { case E_BLOCK_ANVIL: + case E_BLOCK_BARRIER: case E_BLOCK_BEACON: case E_BLOCK_BEDROCK: case E_BLOCK_BREWING_STAND: diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index 8fac2a126..97ba26ee3 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -50,7 +50,7 @@ public: int PosX = a_Chunk.GetPosX() * cChunkDef::Width + a_RelX; int PosZ = a_Chunk.GetPosZ() * cChunkDef::Width + a_RelZ; - a_WorldInterface.SpawnMob(PosX, a_RelY, PosZ, cMonster::mtZombiePigman); + a_WorldInterface.SpawnMob(PosX, a_RelY, PosZ, mtZombiePigman); } virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h index 15ac80fd7..275d1422a 100644 --- a/src/Blocks/BlockPumpkin.h +++ b/src/Blocks/BlockPumpkin.h @@ -36,7 +36,7 @@ public: a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_AIR, 0); a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0); - a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtSnowGolem); + a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtSnowGolem); return; } @@ -61,7 +61,7 @@ public: a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0); // Spawn the golem: - a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtIronGolem); + a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtIronGolem); } else if ( (a_ChunkInterface.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ + 1) == E_BLOCK_IRON_BLOCK) && @@ -76,7 +76,7 @@ public: a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0); // Spawn the golem: - a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtIronGolem); + a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtIronGolem); } } diff --git a/src/Blocks/BlockRedstoneRepeater.h b/src/Blocks/BlockRedstoneRepeater.h index 3e5259c56..1eb67f714 100644 --- a/src/Blocks/BlockRedstoneRepeater.h +++ b/src/Blocks/BlockRedstoneRepeater.h @@ -4,7 +4,7 @@ #include "BlockHandler.h" #include "Chunk.h" #include "MetaRotator.h" - +#include "ChunkInterface.h" diff --git a/src/Blocks/BlockSeaLantern.h b/src/Blocks/BlockSeaLantern.h new file mode 100644 index 000000000..a9259d1d6 --- /dev/null +++ b/src/Blocks/BlockSeaLantern.h @@ -0,0 +1,30 @@ + +#pragma once + +#include "BlockHandler.h" + + + + + +class cBlockSeaLanternHandler : + public cBlockHandler +{ +public: + cBlockSeaLanternHandler(BLOCKTYPE a_BlockType) + : cBlockHandler(a_BlockType) + { + } + + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + // Reset meta to 0 + cFastRandom Random; + a_Pickups.push_back(cItem(E_ITEM_PRISMARINE_CRYSTALS, (char)(2 + Random.NextInt(2)), 0)); + } +} ; + + + + diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 0ad30bb2b..ffe2414f7 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -12,6 +12,7 @@ #include "BlockHandler.h" #include "../Items/ItemHandler.h" #include "Root.h" +#include "ChunkInterface.h" @@ -96,7 +97,7 @@ public: /// Returns true if the specified blocktype is one of the slabs handled by this handler static bool IsAnySlabType(BLOCKTYPE a_BlockType) { - return ((a_BlockType == E_BLOCK_WOODEN_SLAB) || (a_BlockType == E_BLOCK_STONE_SLAB)); + return ((a_BlockType == E_BLOCK_WOODEN_SLAB) || (a_BlockType == E_BLOCK_STONE_SLAB) || (a_BlockType == E_BLOCK_NEW_STONE_SLAB)); } @@ -119,6 +120,7 @@ public: { case E_BLOCK_STONE_SLAB: return E_BLOCK_DOUBLE_STONE_SLAB; case E_BLOCK_WOODEN_SLAB: return E_BLOCK_DOUBLE_WOODEN_SLAB; + case E_BLOCK_NEW_STONE_SLAB: return E_BLOCK_DOUBLE_NEW_STONE_SLAB; } ASSERT(!"Unhandled slab type!"); return E_BLOCK_AIR; @@ -158,6 +160,7 @@ public: { case E_BLOCK_DOUBLE_STONE_SLAB: return E_BLOCK_STONE_SLAB; case E_BLOCK_DOUBLE_WOODEN_SLAB: return E_BLOCK_WOODEN_SLAB; + case E_BLOCK_DOUBLE_NEW_STONE_SLAB: return E_BLOCK_NEW_STONE_SLAB; } ASSERT(!"Unhandled double slab type!"); return a_BlockType; diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h index b61673cc5..06d84f2d4 100644 --- a/src/Blocks/BlockVine.h +++ b/src/Blocks/BlockVine.h @@ -2,7 +2,7 @@ #include "BlockHandler.h" #include "MetaRotator.h" - +#include "Bindings/PluginManager.h" diff --git a/src/Blocks/ChunkInterface.cpp b/src/Blocks/ChunkInterface.cpp index 540581ae7..e22a1410e 100644 --- a/src/Blocks/ChunkInterface.cpp +++ b/src/Blocks/ChunkInterface.cpp @@ -2,7 +2,139 @@ #include "Globals.h" #include "ChunkInterface.h" +#include "ChunkMap.h" #include "BlockHandler.h" +#include "WorldInterface.h" + + + + + + +BLOCKTYPE cChunkInterface::GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ) +{ + return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ); +} + + + + + +BLOCKTYPE cChunkInterface::GetBlock(const Vector3i & a_Pos) +{ + return GetBlock(a_Pos.x, a_Pos.y, a_Pos.z); +} + + + + + +NIBBLETYPE cChunkInterface::GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ) +{ + return m_ChunkMap->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); +} + + + + + + +bool cChunkInterface::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) +{ + return m_ChunkMap->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); +} + + + + + + +/** Sets the block at the specified coords to the specified value. +Full processing, incl. updating neighbors, is performed. +*/ +void cChunkInterface::SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) +{ + m_ChunkMap->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); +} + + + + + + +void cChunkInterface::SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData) +{ + m_ChunkMap->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_MetaData); +} + + + + + + +void cChunkInterface::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay, BLOCKTYPE a_PreviousBlockType, cWorldInterface & a_WorldInterface) +{ + m_ChunkMap->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_WorldInterface.GetWorldAge() + a_TickDelay, a_PreviousBlockType); +} + + + + + + +/** Sets the block at the specified coords to the specified value. +The replacement doesn't trigger block updates. +The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block) +*/ +void cChunkInterface::FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) +{ + m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); +} + + + + + + +void cChunkInterface::FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) +{ + FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta); +} + + + + + + +void cChunkInterface::UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) +{ + m_ChunkMap->UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ); +} + + + + + + +bool cChunkInterface::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) +{ + return m_ChunkMap->ForEachChunkInRect(a_MinChunkX, a_MaxChunkX, a_MinChunkZ, a_MaxChunkZ, a_Callback); +} + + + + + + +bool cChunkInterface::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) +{ + return m_ChunkMap->WriteBlockArea(a_Area, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes); +} + + + + + bool cChunkInterface::DigBlock(cWorldInterface & a_WorldInterface, int a_X, int a_Y, int a_Z) { @@ -10,3 +142,4 @@ bool cChunkInterface::DigBlock(cWorldInterface & a_WorldInterface, int a_X, int Handler->OnDestroyed(*this, a_WorldInterface, a_X, a_Y, a_Z); return m_ChunkMap->DigBlock(a_X, a_Y, a_Z); } + diff --git a/src/Blocks/ChunkInterface.h b/src/Blocks/ChunkInterface.h index d5f1f1273..2f0cfea11 100644 --- a/src/Blocks/ChunkInterface.h +++ b/src/Blocks/ChunkInterface.h @@ -1,13 +1,13 @@ #pragma once -#include "../ChunkMap.h" #include "../ForEachChunkProvider.h" -#include "WorldInterface.h" - +class cChunkMap; +class cWorldInterface; +class cPlayer; class cChunkInterface: public cForEachChunkProvider @@ -16,70 +16,34 @@ public: cChunkInterface(cChunkMap * a_ChunkMap) : m_ChunkMap(a_ChunkMap) {} - BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ) - { - return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ); - } - BLOCKTYPE GetBlock(const Vector3i & a_Pos) - { - return GetBlock(a_Pos.x, a_Pos.y, a_Pos.z); - } - NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ) - { - return m_ChunkMap->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - } + BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ); + BLOCKTYPE GetBlock(const Vector3i & a_Pos); + NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ); - bool GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) - { - return m_ChunkMap->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); - } + bool GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta); /** Sets the block at the specified coords to the specified value. Full processing, incl. updating neighbors, is performed. */ - void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) - { - m_ChunkMap->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); - } + void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); - void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData) - { - m_ChunkMap->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_MetaData); - } + void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData); - void QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay, BLOCKTYPE a_PreviousBlockType, cWorldInterface & a_WorldInterface) - { - m_ChunkMap->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_WorldInterface.GetWorldAge() + a_TickDelay, a_PreviousBlockType); - } + void QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay, BLOCKTYPE a_PreviousBlockType, cWorldInterface & a_WorldInterface); /** Sets the block at the specified coords to the specified value. The replacement doesn't trigger block updates. The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block) */ - void FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) - { - m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); - } + void FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); - void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) - { - FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta); - } + void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); - void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) - { - m_ChunkMap->UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ); - } + void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ); - virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override - { - return m_ChunkMap->ForEachChunkInRect(a_MinChunkX, a_MaxChunkX, a_MinChunkZ, a_MaxChunkZ, a_Callback); - } + virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override; - virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override - { - return m_ChunkMap->WriteBlockArea(a_Area, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes); - } + virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override; bool DigBlock(cWorldInterface & a_WorldInterface, int a_X, int a_Y, int a_Z); diff --git a/src/Blocks/GetHandlerCompileTimeTemplate.h b/src/Blocks/GetHandlerCompileTimeTemplate.h new file mode 100644 index 000000000..3466b5426 --- /dev/null +++ b/src/Blocks/GetHandlerCompileTimeTemplate.h @@ -0,0 +1,91 @@ + +#pragma once + +class cBlockTorchHandler; +class cBlockLeverHandler; +class cBlockButtonHandler; +class cBlockTripwireHookHandler; +class cBlockDoorHandler; +class cBlockPistonHandler; + + + + + + +template<BLOCKTYPE T> +class GetHandlerCompileTime; + + + + + + + +template<> +class GetHandlerCompileTime<E_BLOCK_TORCH> +{ +public: + typedef cBlockTorchHandler type; +}; + + + + + + +template<> +class GetHandlerCompileTime<E_BLOCK_LEVER> +{ +public: + typedef cBlockLeverHandler type; +}; + + + + + + +template<> +class GetHandlerCompileTime<E_BLOCK_STONE_BUTTON> +{ +public: + typedef cBlockButtonHandler type; +}; + + + + + + +template<> +class GetHandlerCompileTime<E_BLOCK_TRIPWIRE_HOOK> +{ +public: + typedef cBlockTripwireHookHandler type; +}; + + + + + + +template<> +class GetHandlerCompileTime<E_BLOCK_WOODEN_DOOR> +{ +public: + typedef cBlockDoorHandler type; +}; + + + + + + +template<> +class GetHandlerCompileTime<E_BLOCK_PISTON> +{ +public: + typedef cBlockPistonHandler type; +}; + diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h index 889ef1d87..106c314e7 100644 --- a/src/Blocks/WorldInterface.h +++ b/src/Blocks/WorldInterface.h @@ -2,14 +2,15 @@ #pragma once #include "BroadcastInterface.h" -#include "../Mobs/Monster.h" +#include "../Mobs/MonsterTypes.h" class cItems; typedef cItemCallback<cBlockEntity> cBlockEntityCallback; - +class cMonster; +class cPlayer; class cWorldInterface @@ -33,7 +34,7 @@ public: virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false) = 0; /** Spawns a mob of the specified type. Returns the mob's EntityID if recognized and spawned, <0 otherwise */ - virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eType a_MonsterType) = 0; + virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType) = 0; /** Spawns an experience orb at the given location with the given reward. It returns the UniqueID of the spawned experience orb. */ virtual int SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) = 0; |