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;