2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
#include "BlockHandler.h"
|
|
|
|
#include "../Item.h"
|
|
|
|
#include "../World.h"
|
|
|
|
#include "../Root.h"
|
2013-12-08 06:17:54 -05:00
|
|
|
#include "../Bindings/PluginManager.h"
|
2014-02-01 09:01:13 -05:00
|
|
|
#include "../Chunk.h"
|
2014-03-16 12:42:23 -04:00
|
|
|
#include "BlockAnvil.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockBed.h"
|
2014-03-28 17:22:29 -04:00
|
|
|
#include "BlockBigFlower.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockBrewingStand.h"
|
2013-09-22 14:34:42 -04:00
|
|
|
#include "BlockButton.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockCactus.h"
|
2014-03-16 15:26:13 -04:00
|
|
|
#include "BlockCake.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockCarpet.h"
|
|
|
|
#include "BlockCauldron.h"
|
|
|
|
#include "BlockChest.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
#include "BlockCloth.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockCobWeb.h"
|
2014-01-18 19:54:38 -05:00
|
|
|
#include "BlockCommandBlock.h"
|
2013-09-18 13:27:21 -04:00
|
|
|
#include "BlockComparator.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockCrops.h"
|
|
|
|
#include "BlockDeadBush.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
#include "BlockDirt.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockDoor.h"
|
|
|
|
#include "BlockDropSpenser.h"
|
2014-01-20 12:22:08 -05:00
|
|
|
#include "BlockEnchantmentTable.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockEnderchest.h"
|
|
|
|
#include "BlockEntity.h"
|
|
|
|
#include "BlockFarmland.h"
|
|
|
|
#include "BlockFenceGate.h"
|
|
|
|
#include "BlockFire.h"
|
|
|
|
#include "BlockFlower.h"
|
|
|
|
#include "BlockFlowerPot.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
#include "BlockFluid.h"
|
|
|
|
#include "BlockFurnace.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockGlass.h"
|
|
|
|
#include "BlockGlowstone.h"
|
|
|
|
#include "BlockGravel.h"
|
2014-02-19 08:45:09 -05:00
|
|
|
#include "BlockMobHead.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockHopper.h"
|
|
|
|
#include "BlockIce.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
#include "BlockLadder.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockLeaves.h"
|
2014-03-23 18:32:45 -04:00
|
|
|
#include "BlockLilypad.h"
|
2014-02-19 10:58:31 -05:00
|
|
|
#include "BlockNewLeaves.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
#include "BlockLever.h"
|
|
|
|
#include "BlockMelon.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockMushroom.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
#include "BlockMycelium.h"
|
2013-12-18 12:33:18 -05:00
|
|
|
#include "BlockNetherWart.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockNote.h"
|
|
|
|
#include "BlockOre.h"
|
|
|
|
#include "BlockPiston.h"
|
2013-09-17 19:01:20 -04:00
|
|
|
#include "BlockPlanks.h"
|
2013-11-01 20:50:03 -04:00
|
|
|
#include "BlockPortal.h"
|
2013-09-10 17:09:31 -04:00
|
|
|
#include "BlockPumpkin.h"
|
2014-02-03 14:08:38 -05:00
|
|
|
#include "BlockQuartz.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
#include "BlockRail.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockRedstone.h"
|
2013-12-08 09:07:32 -05:00
|
|
|
#include "BlockRedstoneLamp.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockRedstoneRepeater.h"
|
|
|
|
#include "BlockRedstoneTorch.h"
|
2014-03-05 09:10:20 -05:00
|
|
|
#include "BlockTNT.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockSand.h"
|
|
|
|
#include "BlockSapling.h"
|
2014-02-03 14:08:38 -05:00
|
|
|
#include "BlockSideways.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockSign.h"
|
|
|
|
#include "BlockSlab.h"
|
|
|
|
#include "BlockSnow.h"
|
|
|
|
#include "BlockStairs.h"
|
|
|
|
#include "BlockStems.h"
|
|
|
|
#include "BlockStone.h"
|
|
|
|
#include "BlockSugarcane.h"
|
|
|
|
#include "BlockTallGrass.h"
|
|
|
|
#include "BlockTorch.h"
|
2013-11-29 17:27:08 -05:00
|
|
|
#include "BlockTrapdoor.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockVine.h"
|
|
|
|
#include "BlockWorkbench.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
|
|
|
|
{
|
|
|
|
switch(a_BlockType)
|
|
|
|
{
|
|
|
|
// Block handlers, alphabetically sorted:
|
2014-02-19 10:58:31 -05:00
|
|
|
case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
2013-08-20 15:15:46 -04:00
|
|
|
case E_BLOCK_ACTIVATOR_RAIL: return new cBlockRailHandler (a_BlockType);
|
2014-03-16 12:42:23 -04:00
|
|
|
case E_BLOCK_ANVIL: return new cBlockAnvilHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_BED: return new cBlockBedHandler (a_BlockType);
|
2014-03-28 17:22:29 -04:00
|
|
|
case E_BLOCK_BIG_FLOWER: return new cBlockBigFlowerHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
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);
|
|
|
|
case E_BLOCK_BROWN_MUSHROOM: return new cBlockMushroomHandler (a_BlockType);
|
|
|
|
case E_BLOCK_CACTUS: return new cBlockCactusHandler (a_BlockType);
|
2014-03-16 15:26:13 -04:00
|
|
|
case E_BLOCK_CAKE: return new cBlockCakeHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_CARROTS: return new cBlockCropsHandler (a_BlockType);
|
2013-08-20 17:47:10 -04:00
|
|
|
case E_BLOCK_CARPET: return new cBlockCarpetHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType);
|
|
|
|
case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType);
|
|
|
|
case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType);
|
2014-01-18 19:54:38 -05:00
|
|
|
case E_BLOCK_COMMAND_BLOCK: return new cBlockCommandBlockHandler (a_BlockType);
|
2013-09-18 13:27:21 -04:00
|
|
|
case E_BLOCK_ACTIVE_COMPARATOR: return new cBlockComparatorHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_COBBLESTONE: return new cBlockStoneHandler (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);
|
2014-02-19 10:58:31 -05:00
|
|
|
case E_BLOCK_DARK_OAK_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
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);
|
2013-08-23 14:38:39 -04:00
|
|
|
case E_BLOCK_DOUBLE_STONE_SLAB: return new cBlockDoubleSlabHandler (a_BlockType);
|
|
|
|
case E_BLOCK_DOUBLE_WOODEN_SLAB: return new cBlockDoubleSlabHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_DROPPER: return new cBlockDropSpenserHandler (a_BlockType);
|
|
|
|
case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType);
|
2014-01-20 12:22:08 -05:00
|
|
|
case E_BLOCK_ENCHANTMENT_TABLE: return new cBlockEnchantmentTableHandler(a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType);
|
2013-09-18 13:27:21 -04:00
|
|
|
case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler ( );
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
|
|
|
|
case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType);
|
|
|
|
case E_BLOCK_FLOWER_POT: return new cBlockFlowerPotHandler (a_BlockType);
|
|
|
|
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);
|
|
|
|
case E_BLOCK_GLASS: return new cBlockGlassHandler (a_BlockType);
|
|
|
|
case E_BLOCK_GRASS: return new cBlockDirtHandler (a_BlockType);
|
|
|
|
case E_BLOCK_GRAVEL: return new cBlockGravelHandler (a_BlockType);
|
2014-02-03 14:08:38 -05:00
|
|
|
case E_BLOCK_HAY_BALE: return new cBlockSidewaysHandler (a_BlockType);
|
2014-02-19 08:45:09 -05:00
|
|
|
case E_BLOCK_HEAD: return new cBlockMobHeadHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_HOPPER: return new cBlockHopperHandler (a_BlockType);
|
|
|
|
case E_BLOCK_ICE: return new cBlockIceHandler (a_BlockType);
|
2013-09-18 13:27:21 -04:00
|
|
|
case E_BLOCK_INACTIVE_COMPARATOR: return new cBlockComparatorHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_IRON_DOOR: return new cBlockDoorHandler (a_BlockType);
|
|
|
|
case E_BLOCK_IRON_ORE: return new cBlockOreHandler (a_BlockType);
|
2013-12-04 13:48:42 -05:00
|
|
|
case E_BLOCK_JACK_O_LANTERN: return new cBlockPumpkinHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_JUKEBOX: return new cBlockEntityHandler (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);
|
|
|
|
case E_BLOCK_LAPIS_ORE: return new cBlockOreHandler (a_BlockType);
|
2013-12-08 05:47:17 -05:00
|
|
|
case E_BLOCK_LAVA: return new cBlockLavaHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_LEAVES: return new cBlockLeavesHandler (a_BlockType);
|
2014-03-23 18:32:45 -04:00
|
|
|
case E_BLOCK_LILY_PAD: return new cBlockLilypadHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
|
2014-02-03 14:08:38 -05:00
|
|
|
case E_BLOCK_LOG: return new cBlockSidewaysHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_MELON: return new cBlockMelonHandler (a_BlockType);
|
|
|
|
case E_BLOCK_MELON_STEM: return new cBlockStemsHandler (a_BlockType);
|
|
|
|
case E_BLOCK_MYCELIUM: return new cBlockMyceliumHandler (a_BlockType);
|
|
|
|
case E_BLOCK_NETHER_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
2013-12-04 13:48:42 -05:00
|
|
|
case E_BLOCK_NETHER_PORTAL: return new cBlockPortalHandler (a_BlockType);
|
2013-12-18 12:33:18 -05:00
|
|
|
case E_BLOCK_NETHER_WART: return new cBlockNetherWartHandler (a_BlockType);
|
2014-03-08 05:53:15 -05:00
|
|
|
case E_BLOCK_NETHER_QUARTZ_ORE: return new cBlockOreHandler (a_BlockType);
|
2014-02-19 10:58:31 -05:00
|
|
|
case E_BLOCK_NEW_LEAVES: return new cBlockNewLeavesHandler (a_BlockType);
|
2014-02-03 14:08:38 -05:00
|
|
|
case E_BLOCK_NEW_LOG: return new cBlockSidewaysHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_NOTE_BLOCK: return new cBlockNoteHandler (a_BlockType);
|
|
|
|
case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType);
|
2013-09-18 13:27:21 -04:00
|
|
|
case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler ( );
|
2013-09-17 19:01:20 -04:00
|
|
|
case E_BLOCK_PLANKS: return new cBlockPlanksHandler (a_BlockType);
|
2013-12-04 13:48:42 -05:00
|
|
|
case E_BLOCK_POTATOES: return new cBlockCropsHandler (a_BlockType);
|
|
|
|
case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType);
|
2013-09-10 17:09:31 -04:00
|
|
|
case E_BLOCK_PUMPKIN: return new cBlockPumpkinHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_PUMPKIN_STEM: return new cBlockStemsHandler (a_BlockType);
|
2014-02-03 14:22:45 -05:00
|
|
|
case E_BLOCK_QUARTZ_BLOCK: return new cBlockQuartzHandler (a_BlockType);
|
2013-09-15 10:55:35 -04:00
|
|
|
case E_BLOCK_QUARTZ_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_RAIL: return new cBlockRailHandler (a_BlockType);
|
2013-12-08 09:07:32 -05:00
|
|
|
case E_BLOCK_REDSTONE_LAMP_ON: return new cBlockRedstoneLampHandler (a_BlockType); // We need this to change pickups to an off lamp; else 1.7+ clients crash
|
2013-07-29 07:13:03 -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);
|
2014-03-02 14:25:05 -05:00
|
|
|
case E_BLOCK_REDSTONE_WIRE: return new cBlockRedstoneHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
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);
|
|
|
|
case E_BLOCK_SANDSTONE_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
|
|
|
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);
|
2013-12-04 13:48:42 -05:00
|
|
|
case E_BLOCK_STATIONARY_LAVA: return new cBlockLavaHandler (a_BlockType);
|
2013-12-08 05:47:17 -05:00
|
|
|
case E_BLOCK_STATIONARY_WATER: return new cBlockFluidHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
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);
|
2013-09-22 14:34:42 -04:00
|
|
|
case E_BLOCK_STONE_BUTTON: return new cBlockButtonHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
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);
|
|
|
|
case E_BLOCK_TORCH: return new cBlockTorchHandler (a_BlockType);
|
2013-11-29 17:27:08 -05:00
|
|
|
case E_BLOCK_TRAPDOOR: return new cBlockTrapdoorHandler (a_BlockType);
|
2014-03-05 09:10:20 -05:00
|
|
|
case E_BLOCK_TNT: return new cBlockTNTHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
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);
|
2013-09-22 14:34:42 -04:00
|
|
|
case E_BLOCK_WOODEN_BUTTON: return new cBlockButtonHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockType)
|
|
|
|
{
|
|
|
|
m_BlockType = a_BlockType;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool cBlockHandler::GetPlacementBlockTypeMeta(
|
2014-02-01 08:06:32 -05:00
|
|
|
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
2014-02-04 13:59:05 -05:00
|
|
|
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
2013-07-29 07:13:03 -04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-02 09:49:37 -05:00
|
|
|
void cBlockHandler::OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-04 13:59:05 -05:00
|
|
|
void cBlockHandler::OnPlacedByPlayer(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, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-01 09:01:13 -05:00
|
|
|
void cBlockHandler::OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-01 08:06:32 -05:00
|
|
|
void cBlockHandler::OnPlaced(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
// Notify the neighbors
|
2014-01-26 09:20:39 -05:00
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX - 1, a_BlockY, a_BlockZ);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX + 1, a_BlockY, a_BlockZ);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ - 1);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ + 1);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-01 08:06:32 -05:00
|
|
|
void cBlockHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
// Notify the neighbors
|
2014-01-26 09:20:39 -05:00
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX - 1, a_BlockY, a_BlockZ);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX + 1, a_BlockY, a_BlockZ);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ - 1);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ + 1);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-01 08:06:32 -05:00
|
|
|
void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
if ((a_BlockY >= 0) && (a_BlockY < cChunkDef::Height))
|
|
|
|
{
|
2014-03-02 14:25:05 -05:00
|
|
|
cBlockInfo::GetHandler(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ))->OnNeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-01 08:06:32 -05:00
|
|
|
void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-01 11:35:48 -05:00
|
|
|
void cBlockHandler::OnDigging(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-04 13:59:05 -05:00
|
|
|
void cBlockHandler::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)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-05 09:10:20 -05:00
|
|
|
void cBlockHandler::OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta)
|
|
|
|
{
|
|
|
|
// Setting the meta to a_BlockMeta keeps most textures. The few other blocks have to override this.
|
|
|
|
a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-02 09:49:37 -05:00
|
|
|
void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
cItems Pickups;
|
2014-02-02 09:49:37 -05:00
|
|
|
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
2013-07-29 07:13:03 -04:00
|
|
|
ConvertToPickups(Pickups, Meta);
|
|
|
|
|
|
|
|
// Allow plugins to modify the pickups:
|
2014-02-02 09:49:37 -05:00
|
|
|
a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups);
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
if (!Pickups.empty())
|
|
|
|
{
|
2013-09-18 17:20:08 -04:00
|
|
|
MTRand r1;
|
|
|
|
|
|
|
|
// Mid-block position first
|
2013-09-19 16:46:39 -04:00
|
|
|
double MicroX, MicroY, MicroZ;
|
|
|
|
MicroX = a_BlockX + 0.5;
|
|
|
|
MicroY = a_BlockY + 0.5;
|
|
|
|
MicroZ = a_BlockZ + 0.5;
|
2013-09-18 17:20:08 -04:00
|
|
|
|
2013-12-10 16:24:02 -05:00
|
|
|
// Add random offset second
|
2013-12-09 18:43:06 -05:00
|
|
|
MicroX += r1.rand(1) - 0.5;
|
|
|
|
MicroZ += r1.rand(1) - 0.5;
|
2013-09-09 14:28:50 -04:00
|
|
|
|
2014-02-02 09:49:37 -05:00
|
|
|
a_WorldInterface.SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char * cBlockHandler::GetStepSound()
|
|
|
|
{
|
|
|
|
return "step.stone";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-01 08:06:32 -05:00
|
|
|
bool cBlockHandler::CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, const cChunk & a_Chunk)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool cBlockHandler::IsUseable()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool cBlockHandler::IsClickedThrough(void)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool cBlockHandler::DoesIgnoreBuildCollision(void)
|
|
|
|
{
|
|
|
|
return (m_BlockType == E_BLOCK_AIR);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool cBlockHandler::DoesDropOnUnsuitable(void)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-02 09:49:37 -05:00
|
|
|
void cBlockHandler::Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface, int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2014-01-31 18:17:41 -05:00
|
|
|
if (!CanBeAt(a_ChunkInterface, a_RelX, a_RelY, a_RelZ, a_Chunk))
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
if (DoesDropOnUnsuitable())
|
|
|
|
{
|
|
|
|
int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
|
|
|
|
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
|
2014-02-02 09:49:37 -05:00
|
|
|
DropBlock(a_ChunkInterface, *a_Chunk.GetWorld(), a_PluginInterface, NULL, BlockX, a_RelY, BlockZ);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
a_Chunk.SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Wake up the simulators for this block:
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|