From 81d4d8225ddf49f4644e5f1b32ebb0db9dc7af45 Mon Sep 17 00:00:00 2001 From: expvintl Date: Mon, 19 May 2025 16:38:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/runConfigurations/Minecraft_Server.xml | 2 +- .../java/com/expvintl/mctools/commands/CAutoToolCommand.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.idea/runConfigurations/Minecraft_Server.xml b/.idea/runConfigurations/Minecraft_Server.xml index f6b6460..0444d9c 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 4c24ed6..a8e4477 100644 --- a/src/main/java/com/expvintl/mctools/commands/CAutoToolCommand.java +++ b/src/main/java/com/expvintl/mctools/commands/CAutoToolCommand.java @@ -15,6 +15,7 @@ import com.mojang.brigadier.context.CommandContext; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.block.*; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; import net.minecraft.component.DataComponentTypes; import net.minecraft.component.type.AttributeModifiersComponent; import net.minecraft.enchantment.Enchantments; @@ -105,7 +106,9 @@ public class CAutoToolCommand { //自动工具 MinecraftClient mc=MinecraftClient.getInstance(); if (mc.world == null||mc.player==null) return; - if(mc.player.getGameMode() != GameMode.SURVIVAL) return; //跳过不符合条件的游戏模式 + PlayerListEntry entry=mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()); + if(entry==null) return; + if(entry.getGameMode() != GameMode.SURVIVAL) return; //跳过不符合条件的游戏模式 BlockState state= mc.world.getBlockState(event.blockPos); //跳过不可破坏 if(state.getHardness(mc.world, event.blockPos) < 0) return;