2012-10-07 06:08:57 -04:00
|
|
|
|
2012-07-15 16:36:34 -04:00
|
|
|
#include "Globals.h"
|
2012-09-23 18:09:57 -04:00
|
|
|
#include "BlockHandler.h"
|
|
|
|
#include "../Item.h"
|
|
|
|
#include "../World.h"
|
2013-01-26 21:00:33 -05:00
|
|
|
#include "../Root.h"
|
|
|
|
#include "../PluginManager.h"
|
2012-09-11 08:01:34 -04:00
|
|
|
#include "BlockSand.h"
|
|
|
|
#include "BlockGravel.h"
|
2012-07-15 16:36:34 -04:00
|
|
|
#include "BlockDoor.h"
|
|
|
|
#include "BlockFire.h"
|
|
|
|
#include "BlockRedstone.h"
|
|
|
|
#include "BlockRedstoneTorch.h"
|
|
|
|
#include "BlockRedstoneRepeater.h"
|
|
|
|
#include "BlockPiston.h"
|
|
|
|
#include "BlockWorkbench.h"
|
|
|
|
#include "BlockEntity.h"
|
|
|
|
#include "BlockVine.h"
|
|
|
|
#include "BlockTallGrass.h"
|
|
|
|
#include "BlockSnow.h"
|
|
|
|
#include "BlockCloth.h"
|
|
|
|
#include "BlockSlab.h"
|
|
|
|
#include "BlockDirt.h"
|
|
|
|
#include "BlockTorch.h"
|
|
|
|
#include "BlockWood.h"
|
|
|
|
#include "BlockLeaves.h"
|
|
|
|
#include "BlockSapling.h"
|
|
|
|
#include "BlockFluid.h"
|
|
|
|
#include "BlockChest.h"
|
|
|
|
#include "BlockFurnace.h"
|
2013-05-26 10:39:04 -04:00
|
|
|
#include "BlockDropSpenser.h"
|
2012-07-15 16:36:34 -04:00
|
|
|
#include "BlockStairs.h"
|
|
|
|
#include "BlockLadder.h"
|
2012-12-16 00:52:45 -05:00
|
|
|
#include "BlockLever.h"
|
2012-07-15 16:36:34 -04:00
|
|
|
#include "BlockSign.h"
|
|
|
|
#include "BlockCrops.h"
|
|
|
|
#include "BlockSugarcane.h"
|
|
|
|
#include "BlockFlower.h"
|
|
|
|
#include "BlockMushroom.h"
|
|
|
|
#include "BlockCactus.h"
|
|
|
|
#include "BlockStems.h"
|
|
|
|
#include "BlockGlowstone.h"
|
|
|
|
#include "BlockStone.h"
|
|
|
|
#include "BlockMelon.h"
|
|
|
|
#include "BlockIce.h"
|
2012-07-16 09:30:33 -04:00
|
|
|
#include "BlockOre.h"
|
2012-08-26 13:50:42 -04:00
|
|
|
#include "BlockNote.h"
|
2012-09-29 09:41:47 -04:00
|
|
|
#include "BlockBed.h"
|
2012-10-07 06:08:57 -04:00
|
|
|
#include "BlockFarmland.h"
|
2012-11-24 04:50:38 -05:00
|
|
|
#include "BlockMycelium.h"
|
2012-11-25 08:50:20 -05:00
|
|
|
#include "BlockRail.h"
|
2012-11-26 05:03:34 -05:00
|
|
|
#include "BlockGlass.h"
|
2012-11-27 14:55:23 -05:00
|
|
|
#include "BlockEnderchest.h"
|
2012-12-19 04:29:53 -05:00
|
|
|
#include "BlockFenceGate.h"
|
2012-12-26 20:01:16 -05:00
|
|
|
#include "BlockFlowerPot.h"
|
2012-12-29 06:49:00 -05:00
|
|
|
#include "BlockCauldron.h"
|
|
|
|
#include "BlockBrewingStand.h"
|
2013-04-06 14:20:06 -04:00
|
|
|
#include "BlockCobWeb.h"
|
2013-04-17 22:42:45 -04:00
|
|
|
#include "BlockTNT.h"
|
2013-06-09 11:16:07 -04:00
|
|
|
#include "BlockDeadBush.h"
|
2013-06-12 04:22:34 -04:00
|
|
|
#include "BlockHopper.h"
|
2012-07-15 16:36:34 -04:00
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-07 06:08:57 -04:00
|
|
|
bool cBlockHandler::m_HandlerInitialized = false;
|
|
|
|
cBlockHandler * cBlockHandler::m_BlockHandler[256];
|
2012-07-15 16:36:34 -04:00
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-07 06:08:57 -04:00
|
|
|
cBlockHandler * cBlockHandler::GetBlockHandler(BLOCKTYPE a_BlockType)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2012-09-04 11:07:08 -04:00
|
|
|
if (!m_HandlerInitialized)
|
|
|
|
{
|
2012-10-07 06:08:57 -04:00
|
|
|
// We have to initialize
|
2012-07-15 16:36:34 -04:00
|
|
|
memset(m_BlockHandler, 0, sizeof(m_BlockHandler));
|
|
|
|
m_HandlerInitialized = true;
|
|
|
|
}
|
2012-10-03 04:52:11 -04:00
|
|
|
if (m_BlockHandler[a_BlockType] != NULL)
|
2012-09-04 11:07:08 -04:00
|
|
|
{
|
2012-10-03 04:52:11 -04:00
|
|
|
return m_BlockHandler[a_BlockType];
|
2012-09-04 11:07:08 -04:00
|
|
|
}
|
2012-07-15 16:36:34 -04:00
|
|
|
|
2012-10-03 04:52:11 -04:00
|
|
|
return m_BlockHandler[a_BlockType] = CreateBlockHandler(a_BlockType);
|
2012-07-15 16:36:34 -04:00
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-07 06:08:57 -04:00
|
|
|
cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2012-10-03 04:52:11 -04:00
|
|
|
switch(a_BlockType)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2012-10-07 06:08:57 -04:00
|
|
|
// Block handlers, alphabetically sorted:
|
|
|
|
case E_BLOCK_BED: return new cBlockBedHandler (a_BlockType);
|
|
|
|
case E_BLOCK_BIRCH_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
2012-12-29 06:49:00 -05:00
|
|
|
case E_BLOCK_BREWING_STAND: return new cBlockBrewingStandHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
|
|
|
case E_BLOCK_BROWN_MUSHROOM: return new cBlockMushroomHandler (a_BlockType);
|
|
|
|
case E_BLOCK_CACTUS: return new cBlockCactusHandler (a_BlockType);
|
2013-04-05 09:45:00 -04:00
|
|
|
case E_BLOCK_CARROTS: return new cBlockCropsHandler (a_BlockType);
|
2012-12-29 06:49:00 -05:00
|
|
|
case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType);
|
|
|
|
case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType);
|
|
|
|
case E_BLOCK_COBBLESTONE: return new cBlockStoneHandler (a_BlockType);
|
|
|
|
case E_BLOCK_COBBLESTONE_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
2013-04-06 14:20:06 -04:00
|
|
|
case E_BLOCK_COBWEB: return new cBlockCobWebHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_CROPS: return new cBlockCropsHandler (a_BlockType);
|
2013-06-12 04:22:34 -04:00
|
|
|
case E_BLOCK_DEAD_BUSH: return new cBlockDeadBushHandler (a_BlockType);
|
|
|
|
case E_BLOCK_DETECTOR_RAIL: return new cBlockRailHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_DIAMOND_ORE: return new cBlockOreHandler (a_BlockType);
|
|
|
|
case E_BLOCK_DIRT: return new cBlockDirtHandler (a_BlockType);
|
2013-05-26 10:39:04 -04:00
|
|
|
case E_BLOCK_DISPENSER: return new cBlockDropSpenserHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_DOUBLE_STONE_SLAB: return new cBlockSlabHandler (a_BlockType);
|
|
|
|
case E_BLOCK_DOUBLE_WOODEN_SLAB: return new cBlockSlabHandler (a_BlockType);
|
2013-05-26 10:39:04 -04:00
|
|
|
case E_BLOCK_DROPPER: return new cBlockDropSpenserHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType);
|
2012-11-27 14:55:23 -05:00
|
|
|
case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler;
|
2012-12-19 04:29:53 -05:00
|
|
|
case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType);
|
2012-12-26 20:01:16 -05:00
|
|
|
case E_BLOCK_FLOWER_POT: return new cBlockFlowerPotHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
|
|
|
|
case E_BLOCK_GLOWSTONE: return new cBlockGlowstoneHandler (a_BlockType);
|
|
|
|
case E_BLOCK_GOLD_ORE: return new cBlockOreHandler (a_BlockType);
|
2012-11-26 05:03:34 -05:00
|
|
|
case E_BLOCK_GLASS: return new cBlockGlassHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_GRASS: return new cBlockDirtHandler (a_BlockType);
|
|
|
|
case E_BLOCK_GRAVEL: return new cBlockGravelHandler (a_BlockType);
|
2013-06-12 04:22:34 -04:00
|
|
|
case E_BLOCK_HOPPER: return new cBlockHopperHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_ICE: return new cBlockIceHandler (a_BlockType);
|
|
|
|
case E_BLOCK_IRON_DOOR: return new cBlockDoorHandler (a_BlockType);
|
|
|
|
case E_BLOCK_IRON_ORE: return new cBlockOreHandler (a_BlockType);
|
2012-10-21 03:46:28 -04:00
|
|
|
case E_BLOCK_JUKEBOX: return new cBlockEntityHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_JUNGLE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
|
|
|
case E_BLOCK_LADDER: return new cBlockLadderHandler (a_BlockType);
|
2012-12-16 00:52:45 -05:00
|
|
|
case E_BLOCK_LEVER: return new cBlockLeverHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_LAPIS_ORE: return new cBlockOreHandler (a_BlockType);
|
|
|
|
case E_BLOCK_LAVA: return new cBlockFluidHandler (a_BlockType);
|
|
|
|
case E_BLOCK_LEAVES: return new cBlockLeavesHandler (a_BlockType);
|
|
|
|
case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
|
|
|
|
case E_BLOCK_LOG: return new cBlockWoodHandler (a_BlockType);
|
|
|
|
case E_BLOCK_MELON: return new cBlockMelonHandler (a_BlockType);
|
|
|
|
case E_BLOCK_MELON_STEM: return new cBlockStemsHandler (a_BlockType);
|
2012-11-24 04:50:38 -05:00
|
|
|
case E_BLOCK_MYCELIUM: return new cBlockMyceliumHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_NETHER_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
|
|
|
case E_BLOCK_NOTE_BLOCK: return new cBlockNoteHandler (a_BlockType);
|
|
|
|
case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType);
|
|
|
|
case E_BLOCK_PLANKS: return new cBlockWoodHandler (a_BlockType);
|
|
|
|
case E_BLOCK_PUMPKIN_STEM: return new cBlockStemsHandler (a_BlockType);
|
2012-11-25 08:50:20 -05:00
|
|
|
case E_BLOCK_RAIL: return new cBlockRailHandler (a_BlockType);
|
2013-04-05 09:45:00 -04:00
|
|
|
case E_BLOCK_POTATOES: return new cBlockCropsHandler (a_BlockType);
|
2012-11-25 08:50:20 -05:00
|
|
|
case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_REDSTONE_ORE: return new cBlockOreHandler (a_BlockType);
|
|
|
|
case E_BLOCK_REDSTONE_ORE_GLOWING: return new cBlockOreHandler (a_BlockType);
|
|
|
|
case E_BLOCK_REDSTONE_REPEATER_OFF: return new cBlockRedstoneRepeaterHandler(a_BlockType);
|
|
|
|
case E_BLOCK_REDSTONE_REPEATER_ON: return new cBlockRedstoneRepeaterHandler(a_BlockType);
|
|
|
|
case E_BLOCK_REDSTONE_TORCH_OFF: return new cBlockRedstoneTorchHandler (a_BlockType);
|
|
|
|
case E_BLOCK_REDSTONE_TORCH_ON: return new cBlockRedstoneTorchHandler (a_BlockType);
|
|
|
|
case E_BLOCK_REDSTONE_WIRE: return new cBlockRedstoneHandler (a_BlockType);
|
|
|
|
case E_BLOCK_RED_MUSHROOM: return new cBlockMushroomHandler (a_BlockType);
|
|
|
|
case E_BLOCK_RED_ROSE: return new cBlockFlowerHandler (a_BlockType);
|
|
|
|
case E_BLOCK_SAND: return new cBlockSandHandler (a_BlockType);
|
2013-02-16 06:12:56 -05:00
|
|
|
case E_BLOCK_SANDSTONE_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_SAPLING: return new cBlockSaplingHandler (a_BlockType);
|
|
|
|
case E_BLOCK_SIGN_POST: return new cBlockSignHandler (a_BlockType);
|
|
|
|
case E_BLOCK_SNOW: return new cBlockSnowHandler (a_BlockType);
|
|
|
|
case E_BLOCK_SPRUCE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
|
|
|
case E_BLOCK_STATIONARY_LAVA: return new cBlockFluidHandler (a_BlockType);
|
|
|
|
case E_BLOCK_STATIONARY_WATER: return new cBlockFluidHandler (a_BlockType);
|
|
|
|
case E_BLOCK_STICKY_PISTON: return new cBlockPistonHandler (a_BlockType);
|
|
|
|
case E_BLOCK_STONE: return new cBlockStoneHandler (a_BlockType);
|
|
|
|
case E_BLOCK_STONE_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
|
|
|
case E_BLOCK_STONE_SLAB: return new cBlockSlabHandler (a_BlockType);
|
|
|
|
case E_BLOCK_SUGARCANE: return new cBlockSugarcaneHandler (a_BlockType);
|
|
|
|
case E_BLOCK_TALL_GRASS: return new cBlockTallGrassHandler (a_BlockType);
|
2013-04-17 22:42:45 -04:00
|
|
|
case E_BLOCK_TNT: return new cBlockTNTHandler (a_BlockType);
|
2012-10-07 06:08:57 -04:00
|
|
|
case E_BLOCK_TORCH: return new cBlockTorchHandler (a_BlockType);
|
|
|
|
case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType);
|
|
|
|
case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType);
|
|
|
|
case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType);
|
|
|
|
case E_BLOCK_WOODEN_DOOR: return new cBlockDoorHandler (a_BlockType);
|
|
|
|
case E_BLOCK_WOODEN_SLAB: return new cBlockSlabHandler (a_BlockType);
|
|
|
|
case E_BLOCK_WOODEN_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
|
|
|
case E_BLOCK_WOOL: return new cBlockClothHandler (a_BlockType);
|
|
|
|
case E_BLOCK_WORKBENCH: return new cBlockWorkbenchHandler (a_BlockType);
|
|
|
|
case E_BLOCK_YELLOW_FLOWER: return new cBlockFlowerHandler (a_BlockType);
|
|
|
|
|
|
|
|
default: return new cBlockHandler(a_BlockType);
|
2012-07-15 16:36:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-15 16:36:34 -04:00
|
|
|
void cBlockHandler::Deinit()
|
|
|
|
{
|
2012-10-07 06:08:57 -04:00
|
|
|
for (int i = 0; i < 256; i++)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
delete m_BlockHandler[i];
|
|
|
|
}
|
2012-10-07 06:08:57 -04:00
|
|
|
memset(m_BlockHandler, 0, sizeof(m_BlockHandler)); // Don't leave any dangling pointers around, just in case
|
2012-09-04 11:07:08 -04:00
|
|
|
m_HandlerInitialized = false;
|
2012-07-15 16:36:34 -04:00
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-03 04:52:11 -04:00
|
|
|
cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockType)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2012-10-03 04:52:11 -04:00
|
|
|
m_BlockType = a_BlockType;
|
2012-07-15 16:36:34 -04:00
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
bool cBlockHandler::GetPlacementBlockTypeMeta(
|
|
|
|
cWorld * a_World, cPlayer * a_Player,
|
|
|
|
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
|
|
|
|
int a_CursorX, int a_CursorY, int a_CursorZ,
|
|
|
|
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// By default, all blocks can be placed and the meta is copied over from the item's damage value:
|
|
|
|
a_BlockType = m_BlockType;
|
|
|
|
a_BlockMeta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x0f);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-07 06:08:57 -04:00
|
|
|
void cBlockHandler::OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
void cBlockHandler::OnPlacedByPlayer(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-03 04:52:11 -04:00
|
|
|
void cBlockHandler::OnDestroyedByPlayer(cWorld *a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
void cBlockHandler::OnPlaced(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
// Notify the neighbors
|
2012-10-03 04:52:11 -04:00
|
|
|
NeighborChanged(a_World, a_BlockX - 1, a_BlockY, a_BlockZ);
|
|
|
|
NeighborChanged(a_World, a_BlockX + 1, a_BlockY, a_BlockZ);
|
|
|
|
NeighborChanged(a_World, a_BlockX, a_BlockY - 1, a_BlockZ);
|
|
|
|
NeighborChanged(a_World, a_BlockX, a_BlockY + 1, a_BlockZ);
|
|
|
|
NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ - 1);
|
|
|
|
NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ + 1);
|
2012-07-15 16:36:34 -04:00
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-03 04:52:11 -04:00
|
|
|
void cBlockHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
// Notify the neighbors
|
2012-10-03 04:52:11 -04:00
|
|
|
NeighborChanged(a_World, a_BlockX - 1, a_BlockY, a_BlockZ);
|
|
|
|
NeighborChanged(a_World, a_BlockX + 1, a_BlockY, a_BlockZ);
|
|
|
|
NeighborChanged(a_World, a_BlockX, a_BlockY - 1, a_BlockZ);
|
|
|
|
NeighborChanged(a_World, a_BlockX, a_BlockY + 1, a_BlockZ);
|
|
|
|
NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ - 1);
|
|
|
|
NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ + 1);
|
2012-07-15 16:36:34 -04:00
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-03 04:52:11 -04:00
|
|
|
void cBlockHandler::NeighborChanged(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2013-04-27 09:23:20 -04:00
|
|
|
if ((a_BlockY >= 0) && (a_BlockY < cChunkDef::Height))
|
|
|
|
{
|
|
|
|
GetBlockHandler(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ))->OnNeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ);
|
|
|
|
}
|
2012-07-15 16:36:34 -04:00
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-03 04:52:11 -04:00
|
|
|
void cBlockHandler::OnNeighborChanged(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-03 04:52:11 -04:00
|
|
|
void cBlockHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
2012-08-19 06:44:19 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
void cBlockHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2012-10-01 17:08:15 -04:00
|
|
|
// Setting the meta to a_BlockMeta keeps most textures. The few other blocks have to override this.
|
2012-10-03 04:52:11 -04:00
|
|
|
a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta));
|
2012-07-15 16:36:34 -04:00
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-26 21:00:33 -05:00
|
|
|
void cBlockHandler::DropBlock(cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2012-10-01 17:08:15 -04:00
|
|
|
cItems Pickups;
|
2012-10-03 04:52:11 -04:00
|
|
|
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
2012-10-01 17:08:15 -04:00
|
|
|
ConvertToPickups(Pickups, Meta);
|
2013-01-26 21:00:33 -05:00
|
|
|
|
|
|
|
// Allow plugins to modify the pickups:
|
|
|
|
cRoot::Get()->GetPluginManager()->CallHookBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups);
|
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
if (!Pickups.empty())
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2012-10-03 04:52:11 -04:00
|
|
|
a_World->SpawnItemPickups(Pickups, a_BlockX, a_BlockY, a_BlockZ);
|
2012-07-15 16:36:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
const char * cBlockHandler::GetStepSound()
|
|
|
|
{
|
2012-09-11 08:01:34 -04:00
|
|
|
return "step.stone";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-15 16:18:11 -04:00
|
|
|
bool cBlockHandler::CanBeAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cChunk & a_Chunk)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-15 16:36:34 -04:00
|
|
|
bool cBlockHandler::IsUseable()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
bool cBlockHandler::IsClickedThrough(void)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
bool cBlockHandler::DoesIgnoreBuildCollision(void)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2012-10-03 04:52:11 -04:00
|
|
|
return (m_BlockType == E_BLOCK_AIR);
|
2012-07-15 16:36:34 -04:00
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
bool cBlockHandler::DoesAllowBlockOnTop(void)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
bool cBlockHandler::CanBePlacedOnSide(void)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-04 11:07:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
bool cBlockHandler::DoesDropOnUnsuitable(void)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
return true;
|
2012-09-04 11:07:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-14 14:30:16 -04:00
|
|
|
|
2013-03-15 16:18:11 -04:00
|
|
|
void cBlockHandler::Check(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk)
|
2012-10-14 14:30:16 -04:00
|
|
|
{
|
2013-03-15 16:18:11 -04:00
|
|
|
if (!CanBeAt(a_RelX, a_RelY, a_RelZ, a_Chunk))
|
2012-10-14 14:30:16 -04:00
|
|
|
{
|
|
|
|
if (DoesDropOnUnsuitable())
|
|
|
|
{
|
2013-03-15 16:18:11 -04:00
|
|
|
int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
|
|
|
|
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
|
|
|
|
DropBlock(a_Chunk.GetWorld(), NULL, BlockX, a_RelY, BlockZ);
|
2012-10-14 14:30:16 -04:00
|
|
|
}
|
|
|
|
|
2013-03-15 16:18:11 -04:00
|
|
|
a_Chunk.SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
|
2012-10-14 14:30:16 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-02-28 02:42:45 -05:00
|
|
|
// Wake up the simulators for this block:
|
2013-03-15 16:18:11 -04:00
|
|
|
int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
|
|
|
|
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
|
|
|
|
a_Chunk.GetWorld()->GetSimulatorManager()->WakeUp(BlockX, a_RelY, BlockZ, &a_Chunk);
|
2012-10-14 14:30:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|