* Returns null on error */ public SpecialBlockZone getSpecialZone(BlockPos pos) { if (Minecraft.getMinecraft().theWorld == null) return null; String location = SBInfo.getInstance().getLocation(); IslandZoneSubdivider subdivider = subdividers.get(location); if (subdivider == null) return SpecialBlockZone.NON_SPECIAL_ZONE; return subdivider.getSpecialZoneForBlock(location, pos); } @SubscribeEvent public void onBreakSound(OnBlockBreakSoundEffect event) { SpecialBlockZone specialZone = getSpecialZone(event.getPosition()); boolean hasMithrilSounds = NotEnoughUpdates.INSTANCE.config.mining.mithrilSounds; boolean hasCrystalSounds = NotEnoughUpdates.INSTANCE.config.mining.gemstoneSounds; if (specialZone != null) { CustomBlockSounds.CustomSoundEvent customSound = null; if (specialZone.hasMithril() && isBreakableMithril(event.getBlock()) && hasMithrilSounds && SBInfo.getInstance().getLocation().equals("mining_3")) { customSound = CustomBlockSounds.mithrilBreak; } if (specialZone.hasMithril() && isMithrilHollows(event.getBlock()) && hasMithrilSounds && SBInfo.getInstance().getLocation().equals("crystal_hollows")) { customSound = CustomBlockSounds.mithrilBreak; } if (specialZone.hasTitanium() && isTitanium(event.getBlock()) && hasMithrilSounds) { customSound = CustomBlockSounds.titaniumBreak; } if (specialZone.hasGemstones() && isGemstone(event.getBlock(), EnumDyeColor.RED) && hasCrystalSounds) { customSound = CustomBlockSounds.gemstoneBreakRuby; } if (specialZone.hasGemstones() && isGemstone(event.getBlock(), EnumDyeColor.YELLOW) && hasCrystalSounds) { customSound = CustomBlockSounds.gemstoneBreakTopaz; } if (specialZone.hasGemstones() && isGemstone(event.getBlock(), EnumDyeColor.PINK) && hasCrystalSounds) { customSound = CustomBlockSounds.gemstoneBreakJasper; } if (specialZone.hasGemstones() && isGemstone(event.getBlock(), EnumDyeColor.LIGHT_BLUE) && hasCrystalSounds) { customSound = CustomBlockSounds.gemstoneBreakSapphire; } if (specialZone.hasGemstones() && isGemstone(event.getBlock(), EnumDyeColor.ORANGE) && hasCrystalSounds) { customSound = CustomBlockSounds.gemstoneBreakAmber; } if (specialZone.hasGemstones() && isGemstone(event.getBlock(), EnumDyeColor.PURPLE) && hasCrystalSounds) { customSound = CustomBlockSounds.gemstoneBreakAmethyst; } if (specialZone.hasGemstones() && isGemstone(event.getBlock(), EnumDyeColor.LIME) && hasCrystalSounds) { customSound = CustomBlockSounds.gemstoneBreakJade; } if (customSound != null) { if (customSound.shouldReplace()) { event.setSound(customSound.replaceSoundEvent(event.getSound())); } else { event.setCanceled(true); } } } } public static boolean isTitanium(IBlockState state) { return state.getBlock() == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH; } public static boolean isMithril(IBlockState state) { return isBreakableMithril(state) || state.getBlock() == Blocks.bedrock; } public static boolean isBreakableMithril(IBlockState state) { return (state.getBlock() == Blocks.stained_hardened_clay && state.getValue(BlockColored.COLOR) == EnumDyeColor.CYAN) || (state.getBlock() == Blocks.wool && state.getValue(BlockColored.COLOR) == EnumDyeColor.GRAY) || (state.getBlock() == Blocks.wool && state.getValue(BlockColored.COLOR) == EnumDyeColor.LIGHT_BLUE) || state.getBlock() == Blocks.prismarine; } public static boolean isMithrilHollows(IBlockState state) { return state.getBlock() == Blocks.prismarine || (state.getBlock() == Blocks.wool && state.getValue(BlockColored.COLOR) == EnumDyeColor.LIGHT_BLUE); } public static boolean isGemstone(IBlockState state, EnumDyeColor color) { return ((state.getBlock() == Blocks.stained_glass || state.getBlock() == Blocks.stained_glass_pane) && state.getValue(BlockColored.COLOR) == color); } @SubscribeEvent public void onLocationChange(LocationChangeEvent event) { WorldClient world = Minecraft.getMinecraft().theWorld; String location = event.newLocation; if (world == null) return; if (location == null) return; switch (location.intern()) { case "crystal_hollows": case "mining_3": //if has custom biome, do chunk update or something EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; if (player == null) return; world.markBlocksDirtyVertical((int) player.posX, (int) player.posX, (int) player.posZ, (int) player.posZ); } } }