From 93adbdce9a769b42baeb70f9ead5c7c6a35834b5 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 12 Sep 2020 19:57:44 +0100 Subject: Use tracing for explosions (#4845) * TNT: Implement tracing algorithm + Add intensity tracing * Fix iterating over all players to SendExplosion, even those not in range * Implemented TNT entity interaction * Fixed misaligned destruction tracing * Finalise TNT algorithm - Remove BlockArea and just use chunks Using SetBlock makes it so that we can update everything properly, and does appear to be faster. * BlockInfo learns about explosion attentuation * Rename Explodinator parameters * TNT: pull block destruction into common function Co-authored-by: Alexander Harkness --- src/BlockInfo.cpp | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) (limited to 'src/BlockInfo.cpp') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index f096ccc80..a967b9acf 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -436,6 +436,127 @@ bool cBlockInfo::IsSnowable(BLOCKTYPE a_BlockType) +float cBlockInfo::GetExplosionAbsorption(const BLOCKTYPE Block) +{ + switch (Block) + { + case E_BLOCK_BEDROCK: + case E_BLOCK_COMMAND_BLOCK: + case E_BLOCK_END_GATEWAY: + case E_BLOCK_END_PORTAL: + case E_BLOCK_END_PORTAL_FRAME: return 3600000; + case E_BLOCK_ANVIL: + case E_BLOCK_ENCHANTMENT_TABLE: + case E_BLOCK_OBSIDIAN: return 1200; + case E_BLOCK_ENDER_CHEST: return 600; + case E_BLOCK_LAVA: + case E_BLOCK_STATIONARY_LAVA: + case E_BLOCK_WATER: + case E_BLOCK_STATIONARY_WATER: return 100; + case E_BLOCK_DRAGON_EGG: + case E_BLOCK_END_STONE: + case E_BLOCK_END_BRICKS: return 9; + case E_BLOCK_STONE: + case E_BLOCK_BLOCK_OF_COAL: + case E_BLOCK_DIAMOND_BLOCK: + case E_BLOCK_EMERALD_BLOCK: + case E_BLOCK_GOLD_BLOCK: + case E_BLOCK_IRON_BLOCK: + case E_BLOCK_BLOCK_OF_REDSTONE: + case E_BLOCK_BRICK: + case E_BLOCK_BRICK_STAIRS: + case E_BLOCK_COBBLESTONE: + case E_BLOCK_COBBLESTONE_STAIRS: + case E_BLOCK_IRON_BARS: + case E_BLOCK_JUKEBOX: + case E_BLOCK_MOSSY_COBBLESTONE: + case E_BLOCK_NETHER_BRICK: + case E_BLOCK_NETHER_BRICK_FENCE: + case E_BLOCK_NETHER_BRICK_STAIRS: + case E_BLOCK_PRISMARINE_BLOCK: + case E_BLOCK_STONE_BRICKS: + case E_BLOCK_STONE_BRICK_STAIRS: + case E_BLOCK_COBBLESTONE_WALL: return 6; + case E_BLOCK_IRON_DOOR: + case E_BLOCK_IRON_TRAPDOOR: + case E_BLOCK_MOB_SPAWNER: return 5; + case E_BLOCK_HOPPER: return 4.8f; + case E_BLOCK_TERRACOTTA: return 4.2f; + case E_BLOCK_COBWEB: return 4; + case E_BLOCK_DISPENSER: + case E_BLOCK_DROPPER: + case E_BLOCK_FURNACE: + case E_BLOCK_OBSERVER: return 3.5f; + case E_BLOCK_BEACON: + case E_BLOCK_COAL_ORE: + case E_BLOCK_COCOA_POD: + case E_BLOCK_DIAMOND_ORE: + case E_BLOCK_EMERALD_ORE: + case E_BLOCK_GOLD_ORE: + case E_BLOCK_IRON_ORE: + case E_BLOCK_LAPIS_BLOCK: + case E_BLOCK_LAPIS_ORE: + case E_BLOCK_NETHER_QUARTZ_ORE: + case E_BLOCK_PLANKS: + case E_BLOCK_REDSTONE_ORE: + case E_BLOCK_FENCE: + case E_BLOCK_FENCE_GATE: + case E_BLOCK_WOODEN_DOOR: + case E_BLOCK_WOODEN_SLAB: + case E_BLOCK_WOODEN_STAIRS: + case E_BLOCK_TRAPDOOR: return 3; + case E_BLOCK_CHEST: + case E_BLOCK_WORKBENCH: + case E_BLOCK_TRAPPED_CHEST: return 2.5f; + case E_BLOCK_BONE_BLOCK: + case E_BLOCK_CAULDRON: + case E_BLOCK_LOG: return 2; + case E_BLOCK_CONCRETE: return 1.8f; + case E_BLOCK_BOOKCASE: return 1.5f; + case E_BLOCK_STANDING_BANNER: + case E_BLOCK_WALL_BANNER: + case E_BLOCK_JACK_O_LANTERN: + case E_BLOCK_MELON: + case E_BLOCK_HEAD: + case E_BLOCK_NETHER_WART_BLOCK: + case E_BLOCK_PUMPKIN: + case E_BLOCK_SIGN_POST: + case E_BLOCK_WALLSIGN: return 1; + case E_BLOCK_QUARTZ_BLOCK: + case E_BLOCK_QUARTZ_STAIRS: + case E_BLOCK_RED_SANDSTONE: + case E_BLOCK_RED_SANDSTONE_STAIRS: + case E_BLOCK_SANDSTONE: + case E_BLOCK_SANDSTONE_STAIRS: + case E_BLOCK_WOOL: return 0.8f; + case E_BLOCK_SILVERFISH_EGG: return 0.75f; + case E_BLOCK_ACTIVATOR_RAIL: + case E_BLOCK_DETECTOR_RAIL: + case E_BLOCK_POWERED_RAIL: + case E_BLOCK_RAIL: return 0.7f; + case E_BLOCK_GRASS_PATH: + case E_BLOCK_CLAY: + case E_BLOCK_FARMLAND: + case E_BLOCK_GRASS: + case E_BLOCK_GRAVEL: + case E_BLOCK_SPONGE: return 0.6f; + case E_BLOCK_BREWING_STAND: + case E_BLOCK_STONE_BUTTON: + case E_BLOCK_WOODEN_BUTTON: + case E_BLOCK_CAKE: + case E_BLOCK_CONCRETE_POWDER: + case E_BLOCK_DIRT: + case E_BLOCK_FROSTED_ICE: + case E_BLOCK_HAY_BALE: + case E_BLOCK_ICE: return 0.5f; + default: return 0; + } +} + + + + + void cBlockInfo::sHandlerDeleter::operator () (cBlockHandler * a_Handler) { delete a_Handler; -- cgit v1.2.3