From e4b2ca67d74e8b7671017bea4ed2af57d3e05fbc Mon Sep 17 00:00:00 2001 From: expvintl <16302731+expvintl@users.noreply.github.com> Date: Mon, 2 Sep 2024 02:22:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9ci=E5=90=8D=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/{ci_build_1.21.yml => ci_build.yml} | 0 .idea/runConfigurations/Minecraft_Server.xml | 2 +- .../mctools/commands/CAutoToolCommand.java | 14 +++++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) rename .github/workflows/{ci_build_1.21.yml => ci_build.yml} (100%) diff --git a/.github/workflows/ci_build_1.21.yml b/.github/workflows/ci_build.yml similarity index 100% rename from .github/workflows/ci_build_1.21.yml rename to .github/workflows/ci_build.yml diff --git a/.idea/runConfigurations/Minecraft_Server.xml b/.idea/runConfigurations/Minecraft_Server.xml index aff153d..c1b3bf6 100644 --- a/.idea/runConfigurations/Minecraft_Server.xml +++ b/.idea/runConfigurations/Minecraft_Server.xml @@ -12,5 +12,5 @@ - + \ No newline at end of file diff --git a/src/main/java/com/expvintl/mctools/commands/CAutoToolCommand.java b/src/main/java/com/expvintl/mctools/commands/CAutoToolCommand.java index 97b4bfc..3e6deb4 100644 --- a/src/main/java/com/expvintl/mctools/commands/CAutoToolCommand.java +++ b/src/main/java/com/expvintl/mctools/commands/CAutoToolCommand.java @@ -19,6 +19,7 @@ import net.minecraft.block.BambooShootBlock; import net.minecraft.block.BlockState; import net.minecraft.client.MinecraftClient; import net.minecraft.component.DataComponentTypes; +import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; @@ -66,7 +67,7 @@ public class CAutoToolCommand { float bestScore=-1; int slot=-1; for(int i=0;i<9;i++) { - float score=getWeaponScore(event.player,event.target,i); + float score=getWeaponScore(event.player,i); if(score<0) continue; //选出最好分数的工具 if(score>bestScore){ @@ -135,13 +136,16 @@ public class CAutoToolCommand { score+=Utils.GetEnchantLevel(Enchantments.EFFICIENCY,item); //经验修补 score+=Utils.GetEnchantLevel(Enchantments.MENDING,item); - if (item.getItem() instanceof SwordItem item1 && (state.getBlock() instanceof BambooBlock|| state.getBlock() instanceof BambooShootBlock)) - //根据挖掘等级加分 - score += 90 + (item1.getComponents().get(DataComponentTypes.TOOL).getSpeed(state) * 10); + if (item.getItem() instanceof SwordItem item1 && (state.getBlock() instanceof BambooBlock|| state.getBlock() instanceof BambooShootBlock)) { + if((item1.getComponents().get(DataComponentTypes.TOOL)!=null)){ + //根据挖掘等级加分 + score += 90 + (item1.getComponents().get(DataComponentTypes.TOOL).getSpeed(state) * 10); + } + } } return score; } - public float getWeaponScore(PlayerEntity player,Entity target,int slot) { + public float getWeaponScore(PlayerEntity player,int slot) { float damageScore = 0; ItemStack item = player.getInventory().getStack(slot); //剑优先