diff --git a/.idea/runConfigurations/Minecraft_Server.xml b/.idea/runConfigurations/Minecraft_Server.xml index 9ec732e..27bc6a0 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/build.gradle b/build.gradle index e103273..46a9212 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'maven-publish' } -version = project.mod_version +version = project.findProperty("minecraft_version")?.toString()?:"1.0" group = project.maven_group repositories { mavenCentral() diff --git a/readme.md b/readme.md index e0ab337..970e11e 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,22 @@ -## 一个MC工具组 +
-> 仍在开发 \ No newline at end of file +# Minecraft 工具集(Fabric) + +
+ +## 支持功能 +此mod的所有功能为**c开头** +1. 自动工具(挖掘、砍伐、亡灵、锋利、伤害等评级)(/cautotool) +2. 自动钓鱼 (/cautofish) +3. 自动武器(与工具为合并功能) +4. 伽马高亮(/fullbirght) +5. C键放大 +6. 基本信息HUD +7. 药水状态HUD +8. 聊天栏头像补丁 +9. 强制Tab列表显示头像补丁 +10. 查询Bukkit系服务器插件(/cqserverplugins) +11. 自动重生(/cautorespawn) +12. 自动挂边(/csafewalk) +13. 无衰落伤害(/cnofallpacket) +14. 快速丢弃(WIP)(/cfastdrop) \ No newline at end of file diff --git a/src/main/java/com/expvintl/mctools/FeaturesSettings.java b/src/main/java/com/expvintl/mctools/FeaturesSettings.java new file mode 100644 index 0000000..5b50a9f --- /dev/null +++ b/src/main/java/com/expvintl/mctools/FeaturesSettings.java @@ -0,0 +1,14 @@ +package com.expvintl.mctools; + +import com.expvintl.mctools.settingtype.BooleanSetting; + +public class FeaturesSettings { + public final static FeaturesSettings INSTANCE=new FeaturesSettings(); + public final BooleanSetting autoRespawn = new BooleanSetting(); + public final BooleanSetting safeWalk = new BooleanSetting(); + public final BooleanSetting checkBukkitPlugins = new BooleanSetting(); + public final BooleanSetting autoTool = new BooleanSetting(); + public final BooleanSetting autoToolIncludePlayer = new BooleanSetting(); + public final BooleanSetting autoFish = new BooleanSetting(); + public final BooleanSetting noFallPacket = new BooleanSetting(); +} diff --git a/src/main/java/com/expvintl/mctools/Globals.java b/src/main/java/com/expvintl/mctools/Globals.java deleted file mode 100644 index 37bc5db..0000000 --- a/src/main/java/com/expvintl/mctools/Globals.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.expvintl.mctools; - -import com.expvintl.mctools.types.Setting; - -public class Globals { - public static Setting autoRespawn=new Setting(); - public static Setting selfWalk=new Setting(); - public static Setting checkBukkitPlugins=new Setting(); - public static Setting autoTool=new Setting(); - public static Setting autoFish=new Setting(); - public static Setting noFallPacket=new Setting(); - public static int TPS=0; -} diff --git a/src/main/java/com/expvintl/mctools/commands/CAutoFishCommand.java b/src/main/java/com/expvintl/mctools/commands/CAutoFishCommand.java index bfdbe83..84971f0 100644 --- a/src/main/java/com/expvintl/mctools/commands/CAutoFishCommand.java +++ b/src/main/java/com/expvintl/mctools/commands/CAutoFishCommand.java @@ -1,6 +1,6 @@ package com.expvintl.mctools.commands; -import com.expvintl.mctools.Globals; +import com.expvintl.mctools.FeaturesSettings; import com.expvintl.mctools.events.MCEventBus; import com.expvintl.mctools.events.client.sounds.PlaySoundEvent; import com.expvintl.mctools.utils.CommandUtils; @@ -22,14 +22,14 @@ public class CAutoFishCommand { private static final CAutoFishCommand INSTANCE=new CAutoFishCommand(); public static void register(CommandDispatcher dispatcher){ MCEventBus.INSTANCE.register(INSTANCE); - CommandUtils.CreateStatusCommand("cautofish",Globals.autoFish,dispatcher); + CommandUtils.CreateStatusCommand("cautofish", FeaturesSettings.INSTANCE.autoFish, dispatcher); dispatcher.register(literal("cautofish").then(argument("开关", BoolArgumentType.bool()).executes(CAutoFishCommand::execute))); } private static int execute(CommandContext context) { - Globals.autoFish.set(context.getArgument("开关", Boolean.class)); - if(Globals.autoFish.get()){ + FeaturesSettings.INSTANCE.autoFish.setValue(context.getArgument("开关", Boolean.class)); + if(FeaturesSettings.INSTANCE.autoFish.getValue()){ context.getSource().getPlayer().sendMessage(Text.literal("已启用自动钓鱼!"),false); }else{ context.getSource().getPlayer().sendMessage(Text.literal("已禁用自动钓鱼!"),false); @@ -38,7 +38,7 @@ public class CAutoFishCommand { } @Subscribe private void onPlaySound(PlaySoundEvent event){ - if(Globals.autoFish.get()) { + if(FeaturesSettings.INSTANCE.autoFish.getValue()) { //自动钓鱼 if (event.soundInstance.getId().getPath().equals("entity.fishing_bobber.splash")) { //收杆 diff --git a/src/main/java/com/expvintl/mctools/commands/CAutoRespawnCommand.java b/src/main/java/com/expvintl/mctools/commands/CAutoRespawnCommand.java index 57c7851..533d27b 100644 --- a/src/main/java/com/expvintl/mctools/commands/CAutoRespawnCommand.java +++ b/src/main/java/com/expvintl/mctools/commands/CAutoRespawnCommand.java @@ -1,6 +1,6 @@ package com.expvintl.mctools.commands; -import com.expvintl.mctools.Globals; +import com.expvintl.mctools.FeaturesSettings; import com.expvintl.mctools.events.MCEventBus; import com.expvintl.mctools.events.client.OpenScreenEvent; import com.expvintl.mctools.utils.CommandUtils; @@ -21,13 +21,13 @@ public class CAutoRespawnCommand { private static final CAutoRespawnCommand INSTANCE=new CAutoRespawnCommand(); public static void register(CommandDispatcher dispatcher){ MCEventBus.INSTANCE.register(INSTANCE); - CommandUtils.CreateStatusCommand("cautorespawn",Globals.autoRespawn,dispatcher); + CommandUtils.CreateStatusCommand("cautorespawn", FeaturesSettings.INSTANCE.autoRespawn, dispatcher); dispatcher.register(literal("cautorespawn").then(argument("开关", BoolArgumentType.bool()).executes(CAutoRespawnCommand::execute))); } private static int execute(CommandContext context) { - Globals.autoRespawn.set(context.getArgument("开关", Boolean.class)); - if(Globals.autoRespawn.get()){ + FeaturesSettings.INSTANCE.autoRespawn.setValue(context.getArgument("开关", Boolean.class)); + if(FeaturesSettings.INSTANCE.autoRespawn.getValue()){ context.getSource().getPlayer().sendMessage(Text.literal("已启用自动重生!"),false); }else{ context.getSource().getPlayer().sendMessage(Text.literal("已禁用自动重生!"),false); @@ -36,7 +36,7 @@ public class CAutoRespawnCommand { } @Subscribe private void onOpenScreen(OpenScreenEvent event){ - if(Globals.autoRespawn.get()) { + if(FeaturesSettings.INSTANCE.autoRespawn.getValue()) { //自动重生 if (event.screen instanceof DeathScreen) { if (MinecraftClient.getInstance().player != null) { diff --git a/src/main/java/com/expvintl/mctools/commands/CAutoToolCommand.java b/src/main/java/com/expvintl/mctools/commands/CAutoToolCommand.java index 6c310c8..b62e5ed 100644 --- a/src/main/java/com/expvintl/mctools/commands/CAutoToolCommand.java +++ b/src/main/java/com/expvintl/mctools/commands/CAutoToolCommand.java @@ -1,13 +1,12 @@ package com.expvintl.mctools.commands; -import com.expvintl.mctools.Globals; +import com.expvintl.mctools.FeaturesSettings; import com.expvintl.mctools.events.MCEventBus; import com.expvintl.mctools.events.player.PlayerAttackBlockEvent; import com.expvintl.mctools.events.player.PlayerAttackEntityEvent; import com.expvintl.mctools.events.player.PlayerBreakBlockEvent; import com.expvintl.mctools.mixin.interfaces.ClientPlayerInteractionManagerAccessor; import com.expvintl.mctools.utils.CommandUtils; -import com.expvintl.mctools.utils.Utils; import com.google.common.collect.Multimap; import com.google.common.eventbus.Subscribe; import com.mojang.brigadier.Command; @@ -23,14 +22,10 @@ import net.minecraft.entity.*; import net.minecraft.entity.attribute.EntityAttribute; import net.minecraft.entity.attribute.EntityAttributeModifier; import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.mob.HostileEntity; import net.minecraft.item.*; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.registry.tag.EntityTypeTags; import net.minecraft.text.Text; import java.util.Collection; -import java.util.function.BiConsumer; import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument; import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; @@ -39,32 +34,42 @@ public class CAutoToolCommand { private static final CAutoToolCommand INSTANCE=new CAutoToolCommand(); public static void register(CommandDispatcher dispatcher){ MCEventBus.INSTANCE.register(INSTANCE); - CommandUtils.CreateStatusCommand("cautotool",Globals.autoTool,dispatcher); - dispatcher.register(literal("cautotool").then(argument("开关", BoolArgumentType.bool()).executes(CAutoToolCommand::execute))); + CommandUtils.CreateStatusCommand("cautotool", FeaturesSettings.INSTANCE.autoTool, dispatcher); + dispatcher.register( + literal("cautotool") + .then(argument("开关", BoolArgumentType.bool()) + .executes(CAutoToolCommand::execute) + .then(argument("包含玩家",BoolArgumentType.bool()) + .executes(CAutoToolCommand::execute)))); } private static int execute(CommandContext context) { - Globals.autoTool.set(context.getArgument("开关", Boolean.class)); - if(Globals.autoTool.get()){ - context.getSource().getPlayer().sendMessage(Text.literal("已启用智能工具!"),false); + FeaturesSettings.INSTANCE.autoTool.setValue(context.getArgument("开关", Boolean.class)); + try{ + FeaturesSettings.INSTANCE.autoToolIncludePlayer.setValue(context.getArgument("包含玩家", Boolean.class)); + }catch (IllegalArgumentException ignored){ + } + if(FeaturesSettings.INSTANCE.autoTool.getValue()){ + context.getSource().getPlayer().sendMessage(Text.literal("已启用智能工具! 对玩家使用智能武器:"+FeaturesSettings.INSTANCE.autoToolIncludePlayer.getValue()),false); }else{ context.getSource().getPlayer().sendMessage(Text.literal("已禁用智能工具!"),false); } return Command.SINGLE_SUCCESS; } - @Subscribe - private void onBreakBlock(PlayerBreakBlockEvent event){ - if(!Globals.autoTool.get()) return; - MinecraftClient mc=MinecraftClient.getInstance(); - if (mc.world == null||mc.player==null) return; - } + // @Subscribe +// private void onBreakBlock(PlayerBreakBlockEvent event){ +// if(!Globals.autoTool.get()) return; +// MinecraftClient mc=MinecraftClient.getInstance(); +// if (mc.world == null||mc.player==null) return; +// } + @Subscribe private void onAttackEntity(PlayerAttackEntityEvent event){ - if(!Globals.autoTool.get()) return; + if(!FeaturesSettings.INSTANCE.autoTool.getValue()) return; if(event.target.hasCustomName()) return; - //不对玩家使用 - if(event.target.isPlayer()) return; + //对玩家使用 + if(FeaturesSettings.INSTANCE.autoToolIncludePlayer.getValue()&&event.target.isPlayer()) return; float bestScore=-1; int slot=-1; for(int i=0;i<9;i++) { @@ -93,7 +98,7 @@ public class CAutoToolCommand { //方块挖掘 @Subscribe private void onAttackBlock(PlayerAttackBlockEvent event){ - if(!Globals.autoTool.get()) return; + if(!FeaturesSettings.INSTANCE.autoTool.getValue()) return; //自动工具 MinecraftClient mc=MinecraftClient.getInstance(); if (mc.world == null||mc.player==null) return; diff --git a/src/main/java/com/expvintl/mctools/commands/CNoFallPacketCommand.java b/src/main/java/com/expvintl/mctools/commands/CNoFallPacketCommand.java index 1c0e539..c8eca35 100644 --- a/src/main/java/com/expvintl/mctools/commands/CNoFallPacketCommand.java +++ b/src/main/java/com/expvintl/mctools/commands/CNoFallPacketCommand.java @@ -1,6 +1,6 @@ package com.expvintl.mctools.commands; -import com.expvintl.mctools.Globals; +import com.expvintl.mctools.FeaturesSettings; import com.expvintl.mctools.events.MCEventBus; import com.expvintl.mctools.events.network.PacketSendEvent; import com.expvintl.mctools.mixin.interfaces.PlayerMoveC2SPacketAccessor; @@ -23,14 +23,14 @@ public class CNoFallPacketCommand { private static final MinecraftClient mc=MinecraftClient.getInstance(); public static void register(CommandDispatcher dispatcher){ MCEventBus.INSTANCE.register(INSTANCE); - CommandUtils.CreateStatusCommand("cnofallpacket",Globals.noFallPacket,dispatcher); + CommandUtils.CreateStatusCommand("cnofallpacket", FeaturesSettings.INSTANCE.noFallPacket, dispatcher); dispatcher.register(literal("cnofallpacket").then(argument("开关", BoolArgumentType.bool()).executes(CNoFallPacketCommand::execute))); } private static int execute(CommandContext context) { - Globals.noFallPacket.set(context.getArgument("开关", Boolean.class)); - if(Globals.noFallPacket.get()){ + FeaturesSettings.INSTANCE.noFallPacket.setValue(context.getArgument("开关", Boolean.class)); + if(FeaturesSettings.INSTANCE.noFallPacket.getValue()){ context.getSource().getPlayer().sendMessage(Text.literal("已启用摔落伤害!"),false); }else{ context.getSource().getPlayer().sendMessage(Text.literal("已禁用摔落伤害!"),false); @@ -42,7 +42,7 @@ public class CNoFallPacketCommand { //跳过非移动的数据包 if(!(event.packet instanceof PlayerMoveC2SPacket)) return; //跳过创造 - if(Globals.noFallPacket.get()&& !mc.player.getAbilities().creativeMode){ + if(FeaturesSettings.INSTANCE.noFallPacket.getValue()&& !mc.player.getAbilities().creativeMode){ if(mc.player.fallDistance<=mc.player.getSafeFallDistance()) return; if(mc.player.getVelocity().y> -0.5) return; //直接发送在地面的数据包来免伤 diff --git a/src/main/java/com/expvintl/mctools/commands/CQServerPluginsCommand.java b/src/main/java/com/expvintl/mctools/commands/CQServerPluginsCommand.java index 2a9fd15..b9bef85 100644 --- a/src/main/java/com/expvintl/mctools/commands/CQServerPluginsCommand.java +++ b/src/main/java/com/expvintl/mctools/commands/CQServerPluginsCommand.java @@ -1,6 +1,6 @@ package com.expvintl.mctools.commands; -import com.expvintl.mctools.Globals; +import com.expvintl.mctools.FeaturesSettings; import com.expvintl.mctools.events.MCEventBus; import com.expvintl.mctools.events.network.PacketReceiveEvent; import com.expvintl.mctools.utils.Utils; @@ -29,13 +29,13 @@ public class CQServerPluginsCommand { private static int execute(CommandContext context) { //注册数据包接受事件 MCEventBus.INSTANCE.register(INSTANCE); - Globals.checkBukkitPlugins.set(true); + FeaturesSettings.INSTANCE.checkBukkitPlugins.setValue(true); context.getSource().getPlayer().networkHandler.sendPacket(new RequestCommandCompletionsC2SPacket(new Random().nextInt(200),"bukkit:ver ")); //1秒后关闭避免识别其他命令提示 Utils.timer.schedule(new TimerTask() { @Override public void run() { - Globals.checkBukkitPlugins.set(false); + FeaturesSettings.INSTANCE.checkBukkitPlugins.setValue(false); MCEventBus.INSTANCE.unregister(INSTANCE); } },1000); @@ -44,7 +44,7 @@ public class CQServerPluginsCommand { @Subscribe public void onReceivePacket(PacketReceiveEvent p){ //探测bukkit服务器插件 - if (!MinecraftClient.getInstance().isIntegratedServerRunning()&& Globals.checkBukkitPlugins.get()) { + if (!MinecraftClient.getInstance().isIntegratedServerRunning()&& FeaturesSettings.INSTANCE.checkBukkitPlugins.getValue()) { if (p.packet instanceof CommandSuggestionsS2CPacket sg) { StringBuilder buf=new StringBuilder(); buf.append(String.format("找到%d个插件:",sg.getSuggestions().getList().size())).append('\n'); @@ -54,7 +54,7 @@ public class CQServerPluginsCommand { if(MinecraftClient.getInstance().player!=null){ MinecraftClient.getInstance().player.sendMessage(Text.literal(buf.toString()),false); } - Globals.checkBukkitPlugins.set(false); + FeaturesSettings.INSTANCE.checkBukkitPlugins.setValue(false); //取消事件注册 MCEventBus.INSTANCE.unregister(INSTANCE); } diff --git a/src/main/java/com/expvintl/mctools/commands/CSafeWalkCommand.java b/src/main/java/com/expvintl/mctools/commands/CSafeWalkCommand.java index 2a0b098..9ea8959 100644 --- a/src/main/java/com/expvintl/mctools/commands/CSafeWalkCommand.java +++ b/src/main/java/com/expvintl/mctools/commands/CSafeWalkCommand.java @@ -1,6 +1,6 @@ package com.expvintl.mctools.commands; -import com.expvintl.mctools.Globals; +import com.expvintl.mctools.FeaturesSettings; import com.expvintl.mctools.utils.CommandUtils; import com.mojang.brigadier.Command; import com.mojang.brigadier.CommandDispatcher; @@ -14,14 +14,14 @@ import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.lit public class CSafeWalkCommand { public static void register(CommandDispatcher dispatcher){ - CommandUtils.CreateStatusCommand("cselfwalk",Globals.selfWalk,dispatcher); + CommandUtils.CreateStatusCommand("cselfwalk", FeaturesSettings.INSTANCE.safeWalk, dispatcher); dispatcher.register(literal("cselfwalk").then(argument("开关", BoolArgumentType.bool()).executes(CSafeWalkCommand::execute))); } private static int execute(CommandContext context) { - Globals.selfWalk.set(context.getArgument("开关", Boolean.class)); - if(Globals.selfWalk.get()){ + FeaturesSettings.INSTANCE.safeWalk.setValue(context.getArgument("开关", Boolean.class)); + if(FeaturesSettings.INSTANCE.safeWalk.getValue()){ context.getSource().getPlayer().sendMessage(Text.literal("已启用自动挂边!"),false); }else{ context.getSource().getPlayer().sendMessage(Text.literal("已禁用自动挂边!"),false); diff --git a/src/main/java/com/expvintl/mctools/mixin/player/PlayerEntityMixin.java b/src/main/java/com/expvintl/mctools/mixin/player/PlayerEntityMixin.java index 8aba7fc..d8252d5 100644 --- a/src/main/java/com/expvintl/mctools/mixin/player/PlayerEntityMixin.java +++ b/src/main/java/com/expvintl/mctools/mixin/player/PlayerEntityMixin.java @@ -1,6 +1,6 @@ package com.expvintl.mctools.mixin.player; -import com.expvintl.mctools.Globals; +import com.expvintl.mctools.FeaturesSettings; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerEntity; import org.spongepowered.asm.mixin.Mixin; @@ -15,7 +15,7 @@ public class PlayerEntityMixin { if(MinecraftClient.getInstance().world!=null&&MinecraftClient.getInstance().player!=null) { if (!MinecraftClient.getInstance().world.isClient) return; //挂住边缘 - if (Globals.selfWalk.get() && !MinecraftClient.getInstance().player.isSneaking()) cir.setReturnValue(true); + if (FeaturesSettings.INSTANCE.safeWalk.getValue() && !MinecraftClient.getInstance().player.isSneaking()) cir.setReturnValue(true); } } } diff --git a/src/main/java/com/expvintl/mctools/settingtype/BooleanSetting.java b/src/main/java/com/expvintl/mctools/settingtype/BooleanSetting.java new file mode 100644 index 0000000..07a4931 --- /dev/null +++ b/src/main/java/com/expvintl/mctools/settingtype/BooleanSetting.java @@ -0,0 +1,13 @@ +package com.expvintl.mctools.settingtype; + +public class BooleanSetting { + private boolean value; + + public void setValue(boolean value) { + this.value = value; + } + + public boolean getValue() { + return value; + } +} diff --git a/src/main/java/com/expvintl/mctools/texthud/PotionInfo.java b/src/main/java/com/expvintl/mctools/texthud/PotionInfo.java index da57efc..af3f7ca 100644 --- a/src/main/java/com/expvintl/mctools/texthud/PotionInfo.java +++ b/src/main/java/com/expvintl/mctools/texthud/PotionInfo.java @@ -6,7 +6,6 @@ import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.RenderTickCounter; import net.minecraft.client.resource.language.I18n; import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.util.Colors; import java.util.Collection; diff --git a/src/main/java/com/expvintl/mctools/types/Setting.java b/src/main/java/com/expvintl/mctools/types/Setting.java deleted file mode 100644 index 01f16b3..0000000 --- a/src/main/java/com/expvintl/mctools/types/Setting.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.expvintl.mctools.types; - -public class Setting { - public boolean value=false; - public boolean get(){ - return this.value; - } - public void set(boolean value){ - this.value=value; - } -} \ No newline at end of file diff --git a/src/main/java/com/expvintl/mctools/utils/CommandUtils.java b/src/main/java/com/expvintl/mctools/utils/CommandUtils.java index 7848892..ec214e5 100644 --- a/src/main/java/com/expvintl/mctools/utils/CommandUtils.java +++ b/src/main/java/com/expvintl/mctools/utils/CommandUtils.java @@ -1,15 +1,16 @@ package com.expvintl.mctools.utils; -import com.expvintl.mctools.types.Setting; +import com.expvintl.mctools.FeaturesSettings; +import com.expvintl.mctools.settingtype.BooleanSetting; import com.mojang.brigadier.Command; import com.mojang.brigadier.CommandDispatcher; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.text.Text; import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; public class CommandUtils { - public static void CreateStatusCommand(String cmd, Setting toggle, CommandDispatcher dispatcher){ + public static void CreateStatusCommand(String cmd, BooleanSetting setting, CommandDispatcher dispatcher){ dispatcher.register(literal(cmd).executes((context -> { - context.getSource().getPlayer().sendMessage(Text.literal("当前启用状态: "+toggle.get()),false); + context.getSource().getPlayer().sendMessage(Text.literal("当前启用状态: "+setting.getValue()),false); return Command.SINGLE_SUCCESS; }))); }