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) { cItems Pickups; NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); if (a_CanDrop) { if ((a_Digger != nullptr) && (a_Digger->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0)) { switch (m_BlockType) { case E_BLOCK_ACACIA_DOOR: case E_BLOCK_ACTIVE_COMPARATOR: case E_BLOCK_BED: case E_BLOCK_BIRCH_DOOR: case E_BLOCK_BREWING_STAND: case E_BLOCK_CAKE: case E_BLOCK_CARROTS: case E_BLOCK_CAULDRON: case E_BLOCK_COCOA_POD: case E_BLOCK_CROPS: case E_BLOCK_DARK_OAK_DOOR: case E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB: case E_BLOCK_DOUBLE_STONE_SLAB: case E_BLOCK_DOUBLE_WOODEN_SLAB: case E_BLOCK_FIRE: case E_BLOCK_FARMLAND: 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: case E_BLOCK_MELON_STEM: case E_BLOCK_MOB_SPAWNER: case E_BLOCK_NETHER_WART: case E_BLOCK_OAK_DOOR: case E_BLOCK_PISTON_EXTENSION: case E_BLOCK_POTATOES: case E_BLOCK_PUMPKIN_STEM: 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: case E_BLOCK_SNOW: case E_BLOCK_SPRUCE_DOOR: case E_BLOCK_STANDING_BANNER: case E_BLOCK_SUGARCANE: case E_BLOCK_TALL_GRASS: case E_BLOCK_TRIPWIRE: case E_BLOCK_WALL_BANNER: case E_BLOCK_WALLSIGN: { // Silktouch can't be used for these blocks ConvertToPickups(Pickups, Meta); break; } default: Pickups.Add(m_BlockType, 1, Meta); break; } } else { ConvertToPickups(Pickups, Meta); } } // Allow plugins to modify the pickups: a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups); if (!Pickups.empty()) { MTRand r1; // Mid-block position first double MicroX, MicroY, MicroZ; MicroX = a_BlockX + 0.5; MicroY = a_BlockY + 0.5; MicroZ = a_BlockZ + 0.5; // Add random offset second MicroX += r1.rand(1) - 0.5; MicroZ += r1.rand(1) - 0.5; a_WorldInterface.SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ); } }
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) { cItems Pickups; NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); if (a_CanDrop) { if ((a_Digger != nullptr) && (a_Digger->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0)) { switch (m_BlockType) { case E_BLOCK_CAKE: case E_BLOCK_CARROTS: case E_BLOCK_COCOA_POD: case E_BLOCK_DOUBLE_STONE_SLAB: case E_BLOCK_DOUBLE_WOODEN_SLAB: case E_BLOCK_FIRE: case E_BLOCK_FARMLAND: case E_BLOCK_MELON_STEM: case E_BLOCK_MOB_SPAWNER: case E_BLOCK_NETHER_WART: case E_BLOCK_POTATOES: case E_BLOCK_PUMPKIN_STEM: case E_BLOCK_SNOW: case E_BLOCK_SUGARCANE: case E_BLOCK_TALL_GRASS: case E_BLOCK_CROPS: { // Silktouch can't be used for these blocks ConvertToPickups(Pickups, Meta); break; } default: Pickups.Add(m_BlockType, 1, Meta); break; } } else { ConvertToPickups(Pickups, Meta); } } // Allow plugins to modify the pickups: a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups); if (!Pickups.empty()) { MTRand r1; // Mid-block position first double MicroX, MicroY, MicroZ; MicroX = a_BlockX + 0.5; MicroY = a_BlockY + 0.5; MicroZ = a_BlockZ + 0.5; // Add random offset second MicroX += r1.rand(1) - 0.5; MicroZ += r1.rand(1) - 0.5; a_WorldInterface.SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ); } }