2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
#include "BlockHandler.h"
|
|
|
|
#include "../Item.h"
|
|
|
|
#include "../World.h"
|
2014-02-01 09:01:13 -05:00
|
|
|
#include "../Chunk.h"
|
2014-10-15 13:01:55 -04:00
|
|
|
#include "BlockPluginInterface.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-12-01 12:10:37 -05:00
|
|
|
#include "BlockCocoaPod.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"
|
2013-07-29 07:13:03 -04:00
|
|
|
#include "BlockLever.h"
|
|
|
|
#include "BlockMelon.h"
|
2014-09-12 10:41:23 -04:00
|
|
|
#include "BlockMobSpawner.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockMushroom.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
#include "BlockMycelium.h"
|
2015-08-19 12:45:53 -04:00
|
|
|
#include "BlockNetherrack.h"
|
2013-12-18 12:33:18 -05:00
|
|
|
#include "BlockNetherWart.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#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-06-16 18:40:35 -04:00
|
|
|
#include "BlockPressurePlate.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"
|
2014-06-28 15:44:34 -04:00
|
|
|
#include "BlockTripwire.h"
|
|
|
|
#include "BlockTripwireHook.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockSand.h"
|
|
|
|
#include "BlockSapling.h"
|
2014-09-12 11:01:03 -04:00
|
|
|
#include "BlockSeaLantern.h"
|
2014-02-03 14:08:38 -05:00
|
|
|
#include "BlockSideways.h"
|
2014-07-17 20:19:30 -04:00
|
|
|
#include "BlockSignPost.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockSlab.h"
|
2015-11-01 14:36:54 -05:00
|
|
|
#include "BlockSlime.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#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"
|
2014-07-17 20:19:30 -04:00
|
|
|
#include "BlockWallSign.h"
|
2013-08-05 04:43:43 -04:00
|
|
|
#include "BlockWorkbench.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
2014-09-26 13:13:19 -04:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-06-23 01:23:54 -04:00
|
|
|
/*
|
|
|
|
// Tests the meta rotation and mirroring.
|
|
|
|
// Note that the cMetaRotator needs to have its assert paths disabled for this test to work!
|
|
|
|
static class cBlockHandlerRotationTester
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cBlockHandlerRotationTester(void)
|
|
|
|
{
|
|
|
|
printf("Performing block handlers test...\n");
|
|
|
|
for (BLOCKTYPE Type = 0; Type < E_BLOCK_MAX_TYPE_ID; Type++)
|
|
|
|
{
|
|
|
|
cBlockHandler * Handler = cBlockInfo::GetHandler(Type);
|
2014-10-20 16:55:07 -04:00
|
|
|
if (Handler == nullptr)
|
2014-06-23 01:23:54 -04:00
|
|
|
{
|
2014-10-20 16:55:07 -04:00
|
|
|
printf("nullptr handler for block type %d!\n", Type);
|
2014-06-23 01:23:54 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
AString BlockName = ItemTypeToString(Type);
|
|
|
|
for (NIBBLETYPE Meta = 0; Meta < 16; Meta++)
|
|
|
|
{
|
|
|
|
// Test the CW / CCW rotations:
|
|
|
|
NIBBLETYPE TestMeta;
|
|
|
|
TestMeta = Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaRotateCW(Meta))));
|
|
|
|
if (TestMeta != Meta)
|
|
|
|
{
|
|
|
|
// 4 CW rotations should produce no change in the meta
|
|
|
|
printf("Handler for blocktype %d (%s) fails CW 4-rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
|
|
|
|
}
|
|
|
|
TestMeta = Handler->MetaRotateCCW(Handler->MetaRotateCCW(Handler->MetaRotateCCW(Handler->MetaRotateCCW(Meta))));
|
|
|
|
if (TestMeta != Meta)
|
|
|
|
{
|
|
|
|
// 4 CCW rotations should produce no change in the meta
|
|
|
|
printf("Handler for blocktype %d (%s) fails CCW 4-rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
|
|
|
|
}
|
|
|
|
TestMeta = Handler->MetaRotateCCW(Handler->MetaRotateCW(Meta));
|
|
|
|
if (TestMeta != Meta)
|
|
|
|
{
|
|
|
|
// CCW rotation of a CW rotation should produce no change in the meta
|
|
|
|
printf("Handler for blocktype %d (%s) fails CCW(CW) rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
|
|
|
|
}
|
|
|
|
TestMeta = Handler->MetaRotateCW(Handler->MetaRotateCCW(Meta));
|
|
|
|
if (TestMeta != Meta)
|
|
|
|
{
|
|
|
|
// CW rotation of a CCW rotation should produce no change in the meta
|
|
|
|
printf("Handler for blocktype %d (%s) fails CW(CCW) rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
|
|
|
|
}
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2014-06-23 01:23:54 -04:00
|
|
|
// Test the mirroring:
|
|
|
|
TestMeta = Handler->MetaMirrorXY(Handler->MetaMirrorXY(Meta));
|
|
|
|
if (TestMeta != Meta)
|
|
|
|
{
|
|
|
|
// Double-mirroring should produce the same meta:
|
|
|
|
printf("Handler for blocktype %d (%s) fails XY mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
|
|
|
|
}
|
|
|
|
TestMeta = Handler->MetaMirrorXZ(Handler->MetaMirrorXZ(Meta));
|
|
|
|
if (TestMeta != Meta)
|
|
|
|
{
|
|
|
|
// Double-mirroring should produce the same meta:
|
|
|
|
printf("Handler for blocktype %d (%s) fails XZ mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
|
|
|
|
}
|
|
|
|
TestMeta = Handler->MetaMirrorYZ(Handler->MetaMirrorYZ(Meta));
|
|
|
|
if (TestMeta != Meta)
|
|
|
|
{
|
|
|
|
// Double-mirroring should produce the same meta:
|
|
|
|
printf("Handler for blocktype %d (%s) fails YZ mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
|
|
|
|
}
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2014-06-23 01:23:54 -04:00
|
|
|
// Test mirror-rotating:
|
|
|
|
TestMeta = Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaMirrorXY(Handler->MetaMirrorYZ(Meta))));
|
|
|
|
if (TestMeta != Meta)
|
|
|
|
{
|
|
|
|
// 2 CW rotations should be the same as XY, YZ mirroring:
|
|
|
|
printf("Handler for blocktype %d (%s) fails rotation-mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // for Type
|
|
|
|
printf("Block handlers test complete.\n");
|
|
|
|
}
|
|
|
|
} g_BlockHandlerRotationTester;
|
|
|
|
//*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
|
|
|
|
{
|
2014-07-21 09:19:48 -04:00
|
|
|
switch (a_BlockType)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2014-07-17 16:50:58 -04:00
|
|
|
// Block handlers, alphabetically sorted:
|
2014-09-11 09:39:37 -04:00
|
|
|
case E_BLOCK_ACACIA_DOOR: return new cBlockDoorHandler (a_BlockType);
|
|
|
|
case E_BLOCK_ACACIA_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
|
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);
|
2014-07-30 15:59:35 -04:00
|
|
|
case E_BLOCK_BEACON: return new cBlockEntityHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_BED: return new cBlockBedHandler (a_BlockType);
|
2017-02-14 05:13:55 -05:00
|
|
|
case E_BLOCK_BEETROOTS: return new cBlockCropsHandler<4> (a_BlockType); // 4 stages of growth
|
2014-03-28 17:22:29 -04:00
|
|
|
case E_BLOCK_BIG_FLOWER: return new cBlockBigFlowerHandler (a_BlockType);
|
2014-09-10 15:15:06 -04:00
|
|
|
case E_BLOCK_BIRCH_DOOR: return new cBlockDoorHandler (a_BlockType);
|
|
|
|
case E_BLOCK_BIRCH_FENCE_GATE: return new cBlockFenceGateHandler (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);
|
2017-02-14 05:13:55 -05:00
|
|
|
case E_BLOCK_CARROTS: return new cBlockCropsHandler<8> (a_BlockType); // 8 stages of growth
|
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);
|
2017-02-14 05:13:55 -05:00
|
|
|
case E_BLOCK_CHAIN_COMMAND_BLOCK: return new cBlockCommandBlockHandler (a_BlockType);
|
2014-07-12 17:06:25 -04:00
|
|
|
case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType);
|
2015-04-26 18:06:29 -04:00
|
|
|
case E_BLOCK_CLAY: return new cBlockOreHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType);
|
2014-12-01 12:10:37 -05:00
|
|
|
case E_BLOCK_COCOA_POD: return new cBlockCocoaPodHandler (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);
|
2017-02-14 05:13:55 -05:00
|
|
|
case E_BLOCK_CROPS: return new cBlockCropsHandler<8> (a_BlockType); // 8 stages of growth
|
2014-09-10 15:15:06 -04:00
|
|
|
case E_BLOCK_DARK_OAK_DOOR: return new cBlockDoorHandler (a_BlockType);
|
|
|
|
case E_BLOCK_DARK_OAK_FENCE_GATE: return new cBlockFenceGateHandler (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);
|
2015-06-30 10:50:15 -04:00
|
|
|
case E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB: return new cBlockDoubleSlabHandler (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);
|
2014-07-14 16:57:44 -04:00
|
|
|
case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler (a_BlockType);
|
2017-02-14 05:13:55 -05:00
|
|
|
case E_BLOCK_FROSTED_ICE: return new cBlockIceHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType);
|
|
|
|
case E_BLOCK_FLOWER_POT: return new cBlockFlowerPotHandler (a_BlockType);
|
2014-07-12 17:06:25 -04:00
|
|
|
case E_BLOCK_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
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);
|
2014-06-16 17:05:29 -04:00
|
|
|
case E_BLOCK_GLASS_PANE: return new cBlockGlassHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_GRASS: return new cBlockDirtHandler (a_BlockType);
|
|
|
|
case E_BLOCK_GRAVEL: return new cBlockGravelHandler (a_BlockType);
|
2014-10-07 09:02:51 -04: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);
|
2014-06-16 18:40:35 -04:00
|
|
|
case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: return new cBlockPressurePlateHandler(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);
|
2014-09-10 15:15:06 -04:00
|
|
|
case E_BLOCK_IRON_TRAPDOOR: return new cBlockTrapdoorHandler (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);
|
2014-09-10 15:15:06 -04:00
|
|
|
case E_BLOCK_JUNGLE_DOOR: return new cBlockDoorHandler (a_BlockType);
|
|
|
|
case E_BLOCK_JUNGLE_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
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-06-16 18:40:35 -04:00
|
|
|
case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: return new cBlockPressurePlateHandler(a_BlockType);
|
2014-07-12 17:06:25 -04:00
|
|
|
case E_BLOCK_LILY_PAD: return new cBlockLilypadHandler (a_BlockType);
|
|
|
|
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);
|
2014-09-12 10:41:23 -04:00
|
|
|
case E_BLOCK_MOB_SPAWNER: return new cBlockMobSpawnerHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
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);
|
2015-08-19 12:45:53 -04:00
|
|
|
case E_BLOCK_NETHERRACK: return new cBlockNetherrack (a_BlockType);
|
2014-03-08 05:53:15 -05:00
|
|
|
case E_BLOCK_NETHER_QUARTZ_ORE: return new cBlockOreHandler (a_BlockType);
|
2014-08-19 16:14:37 -04:00
|
|
|
case E_BLOCK_NEW_LEAVES: return new cBlockLeavesHandler (a_BlockType);
|
2014-02-03 14:08:38 -05:00
|
|
|
case E_BLOCK_NEW_LOG: return new cBlockSidewaysHandler (a_BlockType);
|
2015-06-30 10:50:15 -04:00
|
|
|
case E_BLOCK_RED_SANDSTONE_SLAB: return new cBlockSlabHandler (a_BlockType);
|
2014-08-19 16:14:37 -04:00
|
|
|
case E_BLOCK_NOTE_BLOCK: return new cBlockEntityHandler (a_BlockType);
|
2017-02-14 05:13:55 -05:00
|
|
|
case E_BLOCK_OAK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
|
|
|
|
case E_BLOCK_PACKED_ICE: return new cBlockIceHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType);
|
2014-07-21 09:19:48 -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);
|
2017-02-14 05:13:55 -05:00
|
|
|
case E_BLOCK_POTATOES: return new cBlockCropsHandler<8> (a_BlockType); // 8 stages of growth
|
2013-12-04 13:48:42 -05:00
|
|
|
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);
|
2017-02-14 05:13:55 -05:00
|
|
|
case E_BLOCK_PURPUR_DOUBLE_SLAB: return new cBlockDoubleSlabHandler (a_BlockType);
|
|
|
|
case E_BLOCK_PURPUR_SLAB: return new cBlockSlabHandler (a_BlockType);
|
|
|
|
case E_BLOCK_PURPUR_STAIRS: return new cBlockStairsHandler (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);
|
2014-09-10 15:15:06 -04:00
|
|
|
case E_BLOCK_RED_SANDSTONE_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
2014-06-23 01:23:54 -04:00
|
|
|
case E_BLOCK_REDSTONE_LAMP_ON: return new cBlockRedstoneLampHandler (a_BlockType);
|
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);
|
2017-02-14 05:13:55 -05:00
|
|
|
case E_BLOCK_REPEATING_COMMAND_BLOCK: return new cBlockCommandBlockHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
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);
|
2014-09-12 11:01:03 -04:00
|
|
|
case E_BLOCK_SEA_LANTERN: return new cBlockSeaLanternHandler (a_BlockType);
|
2014-07-17 20:19:30 -04:00
|
|
|
case E_BLOCK_SIGN_POST: return new cBlockSignPostHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_SNOW: return new cBlockSnowHandler (a_BlockType);
|
2015-11-01 14:36:54 -05:00
|
|
|
case E_BLOCK_SLIME_BLOCK: return new cBlockSlimeHandler (a_BlockType);
|
2014-09-10 15:15:06 -04:00
|
|
|
case E_BLOCK_SPRUCE_DOOR: return new cBlockDoorHandler (a_BlockType);
|
2014-09-27 09:11:35 -04:00
|
|
|
case E_BLOCK_SPRUCE_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_SPRUCE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
2014-06-16 17:05:29 -04:00
|
|
|
case E_BLOCK_STAINED_GLASS: return new cBlockGlassHandler (a_BlockType);
|
|
|
|
case E_BLOCK_STAINED_GLASS_PANE: return new cBlockGlassHandler (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);
|
2014-06-16 18:40:35 -04:00
|
|
|
case E_BLOCK_STONE_PRESSURE_PLATE: return new cBlockPressurePlateHandler (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);
|
2014-07-12 17:06:25 -04:00
|
|
|
case E_BLOCK_TRAPPED_CHEST: return new cBlockChestHandler (a_BlockType);
|
2014-06-28 15:44:34 -04:00
|
|
|
case E_BLOCK_TRIPWIRE: return new cBlockTripwireHandler (a_BlockType);
|
|
|
|
case E_BLOCK_TRIPWIRE_HOOK: return new cBlockTripwireHookHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType);
|
2014-07-17 20:19:30 -04:00
|
|
|
case E_BLOCK_WALLSIGN: return new cBlockWallSignHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
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);
|
2015-06-30 10:50:15 -04:00
|
|
|
case E_BLOCK_OAK_DOOR: return new cBlockDoorHandler (a_BlockType);
|
2014-06-16 18:40:35 -04:00
|
|
|
case E_BLOCK_WOODEN_PRESSURE_PLATE: return new cBlockPressurePlateHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_BLOCK_WOODEN_SLAB: return new cBlockSlabHandler (a_BlockType);
|
2015-06-30 10:50:15 -04:00
|
|
|
case E_BLOCK_OAK_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
2013-07-29 07:13:03 -04:00
|
|
|
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);
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
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-07-17 16:50:58 -04: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;
|
2015-04-16 14:59:57 -04:00
|
|
|
a_BlockMeta = static_cast<NIBBLETYPE>(a_Player->GetEquippedItem().m_ItemDamage & 0x0f);
|
2013-07-29 07:13:03 -04:00
|
|
|
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-12-24 01:20:17 -05:00
|
|
|
void cBlockHandler::OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, const sSetBlock & a_BlockChange)
|
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
|
2015-07-01 04:40:16 -04:00
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX - 1, a_BlockY, a_BlockZ, BLOCK_FACE_XP);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX + 1, a_BlockY, a_BlockZ, BLOCK_FACE_XM);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_YP);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_YM);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ - 1, BLOCK_FACE_ZP);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ + 1, BLOCK_FACE_ZM);
|
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
|
2015-07-01 04:40:16 -04:00
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX - 1, a_BlockY, a_BlockZ, BLOCK_FACE_XP);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX + 1, a_BlockY, a_BlockZ, BLOCK_FACE_XM);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_YP);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_YM);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ - 1, BLOCK_FACE_ZP);
|
|
|
|
NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ + 1, BLOCK_FACE_ZM);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-07-01 04:40:16 -04:00
|
|
|
void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, int a_NeighborX, int a_NeighborY, int a_NeighborZ, eBlockFace a_WhichNeighbor)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2015-07-01 04:40:16 -04:00
|
|
|
if ((a_NeighborY >= 0) && (a_NeighborY < cChunkDef::Height))
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2015-07-01 04:40:16 -04:00
|
|
|
cBlockInfo::GetHandler(a_ChunkInterface.GetBlock(a_NeighborX, a_NeighborY, a_NeighborZ))->OnNeighborChanged(a_ChunkInterface, a_NeighborX, a_NeighborY, a_NeighborZ, a_WhichNeighbor);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-06-18 17:30:41 -04:00
|
|
|
|
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-09-13 17:49:27 -04: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, bool a_CanDrop)
|
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);
|
2014-07-17 17:26:53 -04:00
|
|
|
|
2014-07-24 16:38:25 -04:00
|
|
|
if (a_CanDrop)
|
2014-07-17 17:26:53 -04:00
|
|
|
{
|
2014-10-20 16:55:07 -04:00
|
|
|
if ((a_Digger != nullptr) && (a_Digger->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0))
|
2014-09-17 17:32:14 -04:00
|
|
|
{
|
2014-09-13 17:49:27 -04:00
|
|
|
switch (m_BlockType)
|
2014-08-19 10:47:33 -04:00
|
|
|
{
|
2016-01-03 09:27:02 -05:00
|
|
|
case E_BLOCK_ACACIA_DOOR:
|
|
|
|
case E_BLOCK_ACTIVE_COMPARATOR:
|
|
|
|
case E_BLOCK_BED:
|
2017-02-14 05:13:55 -05:00
|
|
|
case E_BLOCK_BEETROOTS:
|
2016-01-03 09:27:02 -05:00
|
|
|
case E_BLOCK_BIRCH_DOOR:
|
|
|
|
case E_BLOCK_BREWING_STAND:
|
2014-09-13 17:49:27 -04:00
|
|
|
case E_BLOCK_CAKE:
|
|
|
|
case E_BLOCK_CARROTS:
|
2016-01-03 09:27:02 -05:00
|
|
|
case E_BLOCK_CAULDRON:
|
2014-09-13 17:49:27 -04:00
|
|
|
case E_BLOCK_COCOA_POD:
|
2016-01-03 09:27:02 -05:00
|
|
|
case E_BLOCK_CROPS:
|
|
|
|
case E_BLOCK_DARK_OAK_DOOR:
|
2017-02-26 05:09:06 -05:00
|
|
|
case E_BLOCK_DEAD_BUSH:
|
2016-01-03 09:27:02 -05:00
|
|
|
case E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB:
|
2014-09-13 17:49:27 -04:00
|
|
|
case E_BLOCK_DOUBLE_STONE_SLAB:
|
|
|
|
case E_BLOCK_DOUBLE_WOODEN_SLAB:
|
|
|
|
case E_BLOCK_FIRE:
|
|
|
|
case E_BLOCK_FARMLAND:
|
2016-01-03 09:27:02 -05:00
|
|
|
case E_BLOCK_FLOWER_POT:
|
|
|
|
case E_BLOCK_HEAD:
|
|
|
|
case E_BLOCK_INACTIVE_COMPARATOR:
|
|
|
|
case E_BLOCK_INVERTED_DAYLIGHT_SENSOR:
|
|
|
|
case E_BLOCK_IRON_DOOR:
|
|
|
|
case E_BLOCK_JUNGLE_DOOR:
|
2014-09-13 17:49:27 -04:00
|
|
|
case E_BLOCK_MELON_STEM:
|
|
|
|
case E_BLOCK_MOB_SPAWNER:
|
|
|
|
case E_BLOCK_NETHER_WART:
|
2016-01-03 09:27:02 -05:00
|
|
|
case E_BLOCK_OAK_DOOR:
|
|
|
|
case E_BLOCK_PISTON_EXTENSION:
|
2014-09-13 17:49:27 -04:00
|
|
|
case E_BLOCK_POTATOES:
|
|
|
|
case E_BLOCK_PUMPKIN_STEM:
|
2017-02-14 05:13:55 -05:00
|
|
|
case E_BLOCK_PURPUR_DOUBLE_SLAB:
|
2016-01-03 09:27:02 -05:00
|
|
|
case E_BLOCK_REDSTONE_ORE_GLOWING:
|
|
|
|
case E_BLOCK_REDSTONE_REPEATER_OFF:
|
|
|
|
case E_BLOCK_REDSTONE_REPEATER_ON:
|
|
|
|
case E_BLOCK_REDSTONE_TORCH_OFF:
|
|
|
|
case E_BLOCK_REDSTONE_WIRE:
|
|
|
|
case E_BLOCK_SIGN_POST:
|
2014-09-13 17:49:27 -04:00
|
|
|
case E_BLOCK_SNOW:
|
2016-01-03 09:27:02 -05:00
|
|
|
case E_BLOCK_SPRUCE_DOOR:
|
|
|
|
case E_BLOCK_STANDING_BANNER:
|
2014-09-13 17:49:27 -04:00
|
|
|
case E_BLOCK_SUGARCANE:
|
|
|
|
case E_BLOCK_TALL_GRASS:
|
2016-01-03 09:27:02 -05:00
|
|
|
case E_BLOCK_TRIPWIRE:
|
|
|
|
case E_BLOCK_WALL_BANNER:
|
|
|
|
case E_BLOCK_WALLSIGN:
|
2014-08-19 11:57:32 -04:00
|
|
|
{
|
2014-09-13 17:49:27 -04:00
|
|
|
// Silktouch can't be used for these blocks
|
|
|
|
ConvertToPickups(Pickups, Meta);
|
|
|
|
break;
|
2014-08-19 11:57:32 -04:00
|
|
|
}
|
2014-09-13 17:49:27 -04:00
|
|
|
default: Pickups.Add(m_BlockType, 1, Meta); break;
|
2014-08-19 10:08:17 -04:00
|
|
|
}
|
2014-07-24 16:38:25 -04:00
|
|
|
}
|
2014-09-13 17:49:27 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ConvertToPickups(Pickups, Meta);
|
|
|
|
}
|
2014-07-17 17:26:53 -04:00
|
|
|
}
|
2014-08-19 10:08:17 -04:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
// 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);
|
2016-02-05 16:45:45 -05:00
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-11-10 08:02:07 -05:00
|
|
|
/* default functionality: only test for height, since we assume full voxels with varying height */
|
|
|
|
bool cBlockHandler::IsInsideBlock(const Vector3d & a_Position, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_BlockMeta)
|
|
|
|
{
|
|
|
|
return a_Position.y < cBlockInfo::GetBlockHeight(a_BlockType);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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-10-20 16:55:07 -04:00
|
|
|
DropBlock(a_ChunkInterface, *a_Chunk.GetWorld(), a_PluginInterface, nullptr, BlockX, a_RelY, BlockZ);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
2016-02-05 16:45:45 -05:00
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-06-30 10:50:15 -04:00
|
|
|
|
|
|
|
ColourID cBlockHandler::GetMapBaseColourID(NIBBLETYPE a_Meta)
|
|
|
|
{
|
|
|
|
// Zero for transparent
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|