From 69fd86ef5c4d23aa9287bd6d09378bfc85dca100 Mon Sep 17 00:00:00 2001 From: Gugle Date: Sat, 13 Apr 2024 06:34:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=B7=E5=87=BB=E9=93=81=E5=9D=97=E8=BD=AC?= =?UTF-8?q?=E5=8C=96=E7=A9=BA=E5=BF=83=E7=A3=81=E9=93=81=E5=9D=97=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E8=8C=83=E5=9B=B4=E8=BD=AC=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../anvilcraft/config/AnvilCraftConfig.java | 5 +++++ .../event/LightningEventListener.java | 20 +++++++++++++------ .../resources/assets/anvilcraft/lang/lzh.json | 2 ++ .../assets/anvilcraft/lang/zh_cn.json | 2 ++ .../assets/anvilcraft/lang/zh_hk.json | 2 ++ .../assets/anvilcraft/lang/zh_tw.json | 2 ++ .../assets/anvilcraft/lang/en_ud.json | 2 ++ .../assets/anvilcraft/lang/en_us.json | 2 ++ .../assets/anvilcraft/lang/en_ud.json | 2 ++ .../assets/anvilcraft/lang/en_us.json | 2 ++ gradle.properties | 2 +- 11 files changed, 36 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/dev/dubhe/anvilcraft/config/AnvilCraftConfig.java b/common/src/main/java/dev/dubhe/anvilcraft/config/AnvilCraftConfig.java index 475b38b7b..0da0ad353 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/config/AnvilCraftConfig.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/config/AnvilCraftConfig.java @@ -21,6 +21,11 @@ public class AnvilCraftConfig implements ConfigData { @ConfigEntry.BoundedDiscrete(max = 16, min = 1) public int lightningStrikeDepth = 2; + @Comment("Maximum radius a lightning strike can reach") + @ConfigEntry.Gui.Tooltip + @ConfigEntry.BoundedDiscrete(max = 8, min = 0) + public int lightningStrikeRadius = 1; + @Comment("Maximum distance a magnet attracts") @ConfigEntry.Gui.Tooltip @ConfigEntry.BoundedDiscrete(max = 16, min = 1) diff --git a/common/src/main/java/dev/dubhe/anvilcraft/event/LightningEventListener.java b/common/src/main/java/dev/dubhe/anvilcraft/event/LightningEventListener.java index 830e1ccb7..576113573 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/event/LightningEventListener.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/event/LightningEventListener.java @@ -21,13 +21,21 @@ public void onLightingStrike(@NotNull LightningStrikeEvent event) { BlockState state = event.getLevel().getBlockState(pos); if (state.is(Blocks.LIGHTNING_ROD)) pos = pos.below(); int depth = AnvilCraft.config.lightningStrikeDepth; - for (int i = 0; i < depth; i++) { - state = event.getLevel().getBlockState(pos); - if (state.is(Blocks.IRON_BLOCK)) { - BlockState state1 = ModBlocks.HOLLOW_MAGNET_BLOCK.get().defaultBlockState(); - event.getLevel().setBlockAndUpdate(pos, state1); + int radius = AnvilCraft.config.lightningStrikeRadius; + for (int x = -radius; x <= radius; x++) { + for (int z = -radius; z <= radius; z++) { + for (int y = 0; y < depth; y++) { + BlockPos offset = pos.offset(x, -y, z); + state = event.getLevel().getBlockState(offset); + if ( + !state.is(Blocks.IRON_BLOCK) + && !state.is(ModBlocks.FERRITE_CORE_MAGNET_BLOCK.get()) + && !state.is(ModBlocks.MAGNET_BLOCK.get()) + ) continue; + BlockState state1 = ModBlocks.HOLLOW_MAGNET_BLOCK.get().defaultBlockState(); + event.getLevel().setBlockAndUpdate(offset, state1); + } } - pos = pos.below(); } } } diff --git a/common/src/main/resources/assets/anvilcraft/lang/lzh.json b/common/src/main/resources/assets/anvilcraft/lang/lzh.json index fe46bc975..8f0564be8 100644 --- a/common/src/main/resources/assets/anvilcraft/lang/lzh.json +++ b/common/src/main/resources/assets/anvilcraft/lang/lzh.json @@ -105,6 +105,8 @@ "text.autoconfig.anvilcraft.option.geodeRadius.@Tooltip": "晶穴索之極距", "text.autoconfig.anvilcraft.option.lightningStrikeDepth": "雷擊之深", "text.autoconfig.anvilcraft.option.lightningStrikeDepth.@Tooltip": "雷擊所至之極深", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius": "雷擊之域", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius.@Tooltip": "雷擊所至之極徑", "text.autoconfig.anvilcraft.option.magnetAttractsDistance": "礠石塊之限", "text.autoconfig.anvilcraft.option.magnetAttractsDistance.@Tooltip": "礠石塊引砧之極距", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius": "收執礠石之域", diff --git a/common/src/main/resources/assets/anvilcraft/lang/zh_cn.json b/common/src/main/resources/assets/anvilcraft/lang/zh_cn.json index a40e2eb81..b73854aca 100644 --- a/common/src/main/resources/assets/anvilcraft/lang/zh_cn.json +++ b/common/src/main/resources/assets/anvilcraft/lang/zh_cn.json @@ -105,6 +105,8 @@ "text.autoconfig.anvilcraft.option.geodeRadius.@Tooltip": "使用晶洞搜索紫晶洞的最大半径", "text.autoconfig.anvilcraft.option.lightningStrikeDepth": "雷击深度", "text.autoconfig.anvilcraft.option.lightningStrikeDepth.@Tooltip": "雷击可以达到的最大深度", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius": "雷击半径", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius.@Tooltip": "雷击可以达到的最大半径", "text.autoconfig.anvilcraft.option.magnetAttractsDistance": "磁铁吸引距离", "text.autoconfig.anvilcraft.option.magnetAttractsDistance.@Tooltip": "磁铁吸引铁砧的最远距离", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius": "手持磁铁吸引半径", diff --git a/common/src/main/resources/assets/anvilcraft/lang/zh_hk.json b/common/src/main/resources/assets/anvilcraft/lang/zh_hk.json index 0eeb76c56..8ba74c355 100644 --- a/common/src/main/resources/assets/anvilcraft/lang/zh_hk.json +++ b/common/src/main/resources/assets/anvilcraft/lang/zh_hk.json @@ -105,6 +105,8 @@ "text.autoconfig.anvilcraft.option.geodeRadius.@Tooltip": "使用晶洞搜索紫晶洞的最大半徑", "text.autoconfig.anvilcraft.option.lightningStrikeDepth": "雷擊深度", "text.autoconfig.anvilcraft.option.lightningStrikeDepth.@Tooltip": "雷擊可以達到的最大深度", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius": "雷擊半徑", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius.@Tooltip": "雷擊可以達到的最大半徑", "text.autoconfig.anvilcraft.option.magnetAttractsDistance": "磁鐵吸引距離", "text.autoconfig.anvilcraft.option.magnetAttractsDistance.@Tooltip": "磁鐵吸引鐵砧的最遠距離", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius": "手持磁鐵吸引半徑", diff --git a/common/src/main/resources/assets/anvilcraft/lang/zh_tw.json b/common/src/main/resources/assets/anvilcraft/lang/zh_tw.json index 79007dacf..7dbfd7704 100644 --- a/common/src/main/resources/assets/anvilcraft/lang/zh_tw.json +++ b/common/src/main/resources/assets/anvilcraft/lang/zh_tw.json @@ -105,6 +105,8 @@ "text.autoconfig.anvilcraft.option.geodeRadius.@Tooltip": "使用晶洞搜索紫晶洞的最大半徑", "text.autoconfig.anvilcraft.option.lightningStrikeDepth": "雷擊深度", "text.autoconfig.anvilcraft.option.lightningStrikeDepth.@Tooltip": "雷擊可以達到的最大深度", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius": "雷擊半徑", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius.@Tooltip": "雷擊可以達到的最大半徑", "text.autoconfig.anvilcraft.option.magnetAttractsDistance": "磁鐵吸引距離", "text.autoconfig.anvilcraft.option.magnetAttractsDistance.@Tooltip": "磁鐵吸引鐵砧的最遠距離", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius": "手持磁鐵吸引半徑", diff --git a/fabric/src/generated/resources/assets/anvilcraft/lang/en_ud.json b/fabric/src/generated/resources/assets/anvilcraft/lang/en_ud.json index dd244e106..a70745cbd 100644 --- a/fabric/src/generated/resources/assets/anvilcraft/lang/en_ud.json +++ b/fabric/src/generated/resources/assets/anvilcraft/lang/en_ud.json @@ -105,6 +105,8 @@ "text.autoconfig.anvilcraft.option.geodeRadius.@Tooltip": "ǝpoǝb ǝɥʇ ɟo snıpɐɹ ɥɔɹɐǝs ɯnɯıxɐɯ ǝɥ⟘", "text.autoconfig.anvilcraft.option.lightningStrikeDepth": "ɥʇdǝᗡ ǝʞıɹʇS buıuʇɥbıꞀ", "text.autoconfig.anvilcraft.option.lightningStrikeDepth.@Tooltip": "ɥɔɐǝɹ uɐɔ ǝʞıɹʇs buıuʇɥbıן ɐ ɥʇdǝp ɯnɯıxɐW", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius": "snıpɐᴚ ǝʞıɹʇS buıuʇɥbıꞀ", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius.@Tooltip": "ɥɔɐǝɹ uɐɔ ǝʞıɹʇs buıuʇɥbıן ɐ snıpɐɹ ɯnɯıxɐW", "text.autoconfig.anvilcraft.option.magnetAttractsDistance": "ǝɔuɐʇsıᗡ sʇɔɐɹʇʇⱯ ʇǝubɐW", "text.autoconfig.anvilcraft.option.magnetAttractsDistance.@Tooltip": "sʇɔɐɹʇʇɐ ʇǝubɐɯ ɐ ǝɔuɐʇsıp ɯnɯıxɐW", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius": "snıpɐᴚ sʇɔɐɹʇʇⱯ ɯǝʇI ʇǝubɐW", diff --git a/fabric/src/generated/resources/assets/anvilcraft/lang/en_us.json b/fabric/src/generated/resources/assets/anvilcraft/lang/en_us.json index 539195969..2c16bbc13 100644 --- a/fabric/src/generated/resources/assets/anvilcraft/lang/en_us.json +++ b/fabric/src/generated/resources/assets/anvilcraft/lang/en_us.json @@ -105,6 +105,8 @@ "text.autoconfig.anvilcraft.option.geodeRadius.@Tooltip": "The maximum search radius of the geode", "text.autoconfig.anvilcraft.option.lightningStrikeDepth": "Lightning Strike Depth", "text.autoconfig.anvilcraft.option.lightningStrikeDepth.@Tooltip": "Maximum depth a lightning strike can reach", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius": "Lightning Strike Radius", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius.@Tooltip": "Maximum radius a lightning strike can reach", "text.autoconfig.anvilcraft.option.magnetAttractsDistance": "Magnet Attracts Distance", "text.autoconfig.anvilcraft.option.magnetAttractsDistance.@Tooltip": "Maximum distance a magnet attracts", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius": "Magnet Item Attracts Radius", diff --git a/forge/src/generated/resources/assets/anvilcraft/lang/en_ud.json b/forge/src/generated/resources/assets/anvilcraft/lang/en_ud.json index dd244e106..a70745cbd 100644 --- a/forge/src/generated/resources/assets/anvilcraft/lang/en_ud.json +++ b/forge/src/generated/resources/assets/anvilcraft/lang/en_ud.json @@ -105,6 +105,8 @@ "text.autoconfig.anvilcraft.option.geodeRadius.@Tooltip": "ǝpoǝb ǝɥʇ ɟo snıpɐɹ ɥɔɹɐǝs ɯnɯıxɐɯ ǝɥ⟘", "text.autoconfig.anvilcraft.option.lightningStrikeDepth": "ɥʇdǝᗡ ǝʞıɹʇS buıuʇɥbıꞀ", "text.autoconfig.anvilcraft.option.lightningStrikeDepth.@Tooltip": "ɥɔɐǝɹ uɐɔ ǝʞıɹʇs buıuʇɥbıן ɐ ɥʇdǝp ɯnɯıxɐW", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius": "snıpɐᴚ ǝʞıɹʇS buıuʇɥbıꞀ", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius.@Tooltip": "ɥɔɐǝɹ uɐɔ ǝʞıɹʇs buıuʇɥbıן ɐ snıpɐɹ ɯnɯıxɐW", "text.autoconfig.anvilcraft.option.magnetAttractsDistance": "ǝɔuɐʇsıᗡ sʇɔɐɹʇʇⱯ ʇǝubɐW", "text.autoconfig.anvilcraft.option.magnetAttractsDistance.@Tooltip": "sʇɔɐɹʇʇɐ ʇǝubɐɯ ɐ ǝɔuɐʇsıp ɯnɯıxɐW", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius": "snıpɐᴚ sʇɔɐɹʇʇⱯ ɯǝʇI ʇǝubɐW", diff --git a/forge/src/generated/resources/assets/anvilcraft/lang/en_us.json b/forge/src/generated/resources/assets/anvilcraft/lang/en_us.json index 539195969..2c16bbc13 100644 --- a/forge/src/generated/resources/assets/anvilcraft/lang/en_us.json +++ b/forge/src/generated/resources/assets/anvilcraft/lang/en_us.json @@ -105,6 +105,8 @@ "text.autoconfig.anvilcraft.option.geodeRadius.@Tooltip": "The maximum search radius of the geode", "text.autoconfig.anvilcraft.option.lightningStrikeDepth": "Lightning Strike Depth", "text.autoconfig.anvilcraft.option.lightningStrikeDepth.@Tooltip": "Maximum depth a lightning strike can reach", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius": "Lightning Strike Radius", + "text.autoconfig.anvilcraft.option.lightningStrikeRadius.@Tooltip": "Maximum radius a lightning strike can reach", "text.autoconfig.anvilcraft.option.magnetAttractsDistance": "Magnet Attracts Distance", "text.autoconfig.anvilcraft.option.magnetAttractsDistance.@Tooltip": "Maximum distance a magnet attracts", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius": "Magnet Item Attracts Radius", diff --git a/gradle.properties b/gradle.properties index e6c238b1c..cf1f4babb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ mod_id = anvilcraft mod_name = AnvilCraft mod_description = ... mod_license = LGPL-3.0 license -mod_version = 1.2.1 +mod_version = 1.2.2 mod_url = https://github.com/ maven_group=dev.dubhe