重新改进自动工具,添加清除黑暗效果
Build / build (push) Failing after 2m3s

This commit is contained in:
expvintl
2025-10-21 00:54:02 +08:00
parent 45acee184f
commit ee1e49f387
8 changed files with 89 additions and 50 deletions
+1 -1
View File
@@ -12,5 +12,5 @@
</envs>
<shortenClasspath name="ARGS_FILE"/>
<classpathModifications><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.jcraft\jorbis\0.0.17\8872d22b293e8f5d7d56ff92be966e6dc28ebdc6\jorbis-0.0.17.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl-glfw\3.3.3\efa1eb78c5ccd840e9f329717109b5e892d72f8e\lwjgl-glfw-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl-opengl\3.3.3\2f6b0147078396a58979125a4c947664e98293a\lwjgl-opengl-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\com.mojang\patchy\2.2.10\da05971b07cbb379d002cf7eaec6a2048211fefc\patchy-2.2.10.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\com.mojang\blocklist\1.0.10\5c685c5ffa94c4cd39496c7184c1d122e515ecef\blocklist-1.0.10.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-compress\1.27.1\a19151084758e2fbb6b41eddaa88e7b8ff4e6599\commons-compress-1.27.1.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\com.mojang\text2speech\1.18.11\e853a12cdd6ba4f4836e8f4bf3b37844a13482b6\text2speech-1.18.11.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpclient\4.5.14\1194890e6f56ec29177673f2f12d0b8e627dec98\httpclient-4.5.14.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl-tinyfd\3.3.3\82d755ca94b102e9ca77283b9e2dc46d1b15fbe5\lwjgl-tinyfd-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\commons-logging\commons-logging\1.3.4\b9fc14968d63a8b8a8a2c1885fe3e90564239708\commons-logging-1.3.4.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\com.ibm.icu\icu4j\76.1\215f3a8e936d4069344bd75f2b1368fd58112894\icu4j-76.1.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpcore\4.4.16\51cf043c87253c9f58b539c9f7e44c8894223850\httpcore-4.4.16.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl-jemalloc\3.3.3\b543467b7ff3c6920539a88ee602d34098628be5\lwjgl-jemalloc-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl-stb\3.3.3\25dd6161988d7e65f71d5065c99902402ee32746\lwjgl-stb-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl\3.3.3\29589b5f87ed335a6c7e7ee6a5775f81f97ecb84\lwjgl-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl-openal\3.3.3\daada81ceb5fc0c291fbfdd4433cb8d9423577f2\lwjgl-openal-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl-freetype\3.3.3\a0db6c84a8becc8ca05f9dbfa985edc348a824c7\lwjgl-freetype-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\commons-codec\commons-codec\1.17.1\973638b7149d333563584137ebf13a691bb60579\commons-codec-1.17.1.jar"/></classpathModifications></configuration>
<classpathModifications><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl-stb\3.3.3\25dd6161988d7e65f71d5065c99902402ee32746\lwjgl-stb-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\commons-logging\commons-logging\1.3.4\b9fc14968d63a8b8a8a2c1885fe3e90564239708\commons-logging-1.3.4.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-compress\1.27.1\a19151084758e2fbb6b41eddaa88e7b8ff4e6599\commons-compress-1.27.1.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\com.ibm.icu\icu4j\76.1\215f3a8e936d4069344bd75f2b1368fd58112894\icu4j-76.1.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpclient\4.5.14\1194890e6f56ec29177673f2f12d0b8e627dec98\httpclient-4.5.14.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\com.mojang\patchy\2.2.10\da05971b07cbb379d002cf7eaec6a2048211fefc\patchy-2.2.10.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\com.mojang\blocklist\1.0.10\5c685c5ffa94c4cd39496c7184c1d122e515ecef\blocklist-1.0.10.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl-freetype\3.3.3\a0db6c84a8becc8ca05f9dbfa985edc348a824c7\lwjgl-freetype-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpcore\4.4.16\51cf043c87253c9f58b539c9f7e44c8894223850\httpcore-4.4.16.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl-jemalloc\3.3.3\b543467b7ff3c6920539a88ee602d34098628be5\lwjgl-jemalloc-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\commons-codec\commons-codec\1.17.1\973638b7149d333563584137ebf13a691bb60579\commons-codec-1.17.1.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.jcraft\jorbis\0.0.17\8872d22b293e8f5d7d56ff92be966e6dc28ebdc6\jorbis-0.0.17.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl-glfw\3.3.3\efa1eb78c5ccd840e9f329717109b5e892d72f8e\lwjgl-glfw-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\com.mojang\text2speech\1.18.11\e853a12cdd6ba4f4836e8f4bf3b37844a13482b6\text2speech-1.18.11.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl-opengl\3.3.3\2f6b0147078396a58979125a4c947664e98293a\lwjgl-opengl-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl\3.3.3\29589b5f87ed335a6c7e7ee6a5775f81f97ecb84\lwjgl-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl-tinyfd\3.3.3\82d755ca94b102e9ca77283b9e2dc46d1b15fbe5\lwjgl-tinyfd-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.lwjgl\lwjgl-openal\3.3.3\daada81ceb5fc0c291fbfdd4433cb8d9423577f2\lwjgl-openal-3.3.3.jar"/></classpathModifications></configuration>
</component>
@@ -11,5 +11,5 @@ public class FeaturesSettings {
public final BooleanSetting autoToolIncludePlayer = new BooleanSetting();
public final BooleanSetting autoFish = new BooleanSetting();
public final BooleanSetting noFallPacket = new BooleanSetting();
public final BooleanSetting noDarkness=new BooleanSetting();
}
@@ -3,12 +3,14 @@ package com.expvintl.mctools;
import com.expvintl.mctools.commands.*;
import com.expvintl.mctools.modules.BetterTooltip;
import com.expvintl.mctools.modules.CameraZoom;
import com.expvintl.mctools.modules.ClearDarknessEffect;
import com.expvintl.mctools.texthud.MCInfo;
import com.expvintl.mctools.texthud.PotionInfo;
import com.mojang.brigadier.CommandDispatcher;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.hud.VanillaHudElements;
import net.minecraft.command.CommandRegistryAccess;
@@ -22,12 +24,12 @@ public class MCToolsClient implements ClientModInitializer {
ClientCommandRegistrationCallback.EVENT.register(MCToolsClient::registerCommands);
HudElementRegistry.attachElementBefore(VanillaHudElements.CROSSHAIR, Identifier.of("mctools","DrawInfo"),MCInfo::drawHUD);
HudElementRegistry.attachElementBefore(VanillaHudElements.CROSSHAIR, Identifier.of("mctools","DrawPotionInfo"),PotionInfo::drawHUD);
InitModules();
}
public void InitModules(){
BetterTooltip.INSTANCE.init();
CameraZoom.INSTANCE.init();
ClearDarknessEffect.INSTANCE.init();
}
private static void registerCommands(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandRegistryAccess registryAccess) {
@@ -40,5 +42,6 @@ public class MCToolsClient implements ClientModInitializer {
CQServerPluginsCommand.register(dispatcher);
CNoFallPacketCommand.register(dispatcher);
CFastDropCommand.register(dispatcher,registryAccess);
CNoDarknessCommand.register(dispatcher);
}
}
@@ -26,6 +26,7 @@ import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.*;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.tag.EntityTypeTags;
import net.minecraft.registry.tag.ItemTags;
import net.minecraft.text.Text;
import net.minecraft.world.GameMode;
@@ -77,7 +78,7 @@ public class CAutoToolCommand {
int slot=-1;
for(int i=0;i<PlayerInventory.HOTBAR_SIZE;i++) {
ItemStack item = event.player.getInventory().getStack(i);
if(!isSwordItem(item.getItem())&&!isToolItem(item.getItem())) continue;
if(!isSwordItem(item)&&!isToolItem(item.getItem())) continue;
float score=getWeaponScore(event.target, item);
if(score<=0) continue;
//选出最好分数的工具
@@ -116,6 +117,11 @@ public class CAutoToolCommand {
//遍历每一个物品槽
for(int i = 0; i< PlayerInventory.HOTBAR_SIZE; i++){
ItemStack item = mc.player.getInventory().getStack(i);
if (!isToolItem(item.getItem()) && !(item.getItem() instanceof ShearsItem)) {
continue;
}
//如果不可挖掘则跳过
if (!item.getItem().canMine(item,state, mc.world, event.blockPos,mc.player)||!item.isSuitableFor(state)) continue;
float score= getToolsScore(item,state);
if(score<=0) continue;
//选出最好分数的工具
@@ -135,8 +141,8 @@ public class CAutoToolCommand {
}
}
}
public boolean isSwordItem(Item item){
return item.getComponents().contains(DataComponentTypes.WEAPON);
public boolean isSwordItem(ItemStack item){
return item.isIn(ItemTags.SWORDS);
}
public boolean isToolItem(Item item){
return item.getComponents().contains(DataComponentTypes.TOOL);
@@ -169,28 +175,26 @@ public class CAutoToolCommand {
block == Blocks.GRAVEL || // 沙砾 (影响燧石掉落概率)
block == Blocks.SEA_LANTERN;
}
public float getToolsScore(ItemStack item, BlockState state){
float score=0;
if(isToolItem(item.getItem())||item.getItem() instanceof ShearsItem){
//根据挖掘速度提升评分
score+=item.getMiningSpeedMultiplier(state)*2;
//附魔加分
//耐久
score+= Utils.GetEnchantLevel(Enchantments.UNBREAKING, item);
//效率
score+=Utils.GetEnchantLevel(Enchantments.EFFICIENCY,item);
//经验修补
score+=Utils.GetEnchantLevel(Enchantments.MENDING,item);
public float getToolsScore(ItemStack item, BlockState state) {
float score = 0;
//根据挖掘速度提升评分
score += item.getMiningSpeedMultiplier(state) * 2;
//附魔加分
//耐久
score += Utils.GetEnchantLevel(Enchantments.UNBREAKING, item);
//效率
score += Utils.GetEnchantLevel(Enchantments.EFFICIENCY, item);
//经验修补
score += Utils.GetEnchantLevel(Enchantments.MENDING, item);
if(isBlockFortune(state.getBlock())){
score+=Utils.GetEnchantLevel(Enchantments.FORTUNE,item);//时运
}
if (isBlockFortune(state.getBlock())) {
score += Utils.GetEnchantLevel(Enchantments.FORTUNE, item);//时运
}
if (isSwordItem(item.getItem()) && (state.getBlock() instanceof BambooBlock|| state.getBlock() instanceof BambooShootBlock)) {
if((item.getItem().getComponents().get(DataComponentTypes.TOOL)!=null)){
//根据挖掘等级加分
score += 90 + item.getMiningSpeedMultiplier(state);
}
if (isSwordItem(item) && (state.getBlock() instanceof BambooBlock || state.getBlock() instanceof BambooShootBlock)) {
if ((item.getItem().getComponents().get(DataComponentTypes.TOOL) != null)) {
//根据挖掘等级加分
score += 90 + item.getMiningSpeedMultiplier(state);
}
}
return score;
@@ -198,7 +202,7 @@ public class CAutoToolCommand {
public float getWeaponScore(Entity ent, ItemStack item) {
float damageScore = 0;
//剑优先
if (isSwordItem(item.getItem())) damageScore += 100;
if (isSwordItem(item)) damageScore += 100;
//计算物品的基础伤害属性(较为复杂)
AttributeModifiersComponent comp=item.getOrDefault(DataComponentTypes.ATTRIBUTE_MODIFIERS, AttributeModifiersComponent.DEFAULT);
final float[] damageHolder = {0.0f};
@@ -0,0 +1,31 @@
package com.expvintl.mctools.commands;
import com.expvintl.mctools.FeaturesSettings;
import com.expvintl.mctools.utils.CommandUtils;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.context.CommandContext;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.text.Text;
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument;
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;
public class CNoDarknessCommand {
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher){
CommandUtils.CreateStatusCommand("cnodarkness", FeaturesSettings.INSTANCE.noDarkness, dispatcher);
dispatcher.register(literal("cnodarkness").then(argument("开关", BoolArgumentType.bool()).executes(CNoDarknessCommand::execute)));
}
private static int execute(CommandContext<FabricClientCommandSource> context) {
FeaturesSettings.INSTANCE.noDarkness.setValue(context.getArgument("开关", Boolean.class));
if(FeaturesSettings.INSTANCE.noDarkness.getValue()){
context.getSource().getPlayer().sendMessage(Text.literal("已禁用黑暗效果!"),false);
}else{
context.getSource().getPlayer().sendMessage(Text.literal("已启用黑暗效果!"),false);
}
return Command.SINGLE_SUCCESS;
}
}
@@ -1,22 +0,0 @@
package com.expvintl.mctools.gui;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.Text;
public class MainMenu extends Screen {
public MainMenu(Text title) {
super(title);
}
@Override
protected void init() {
}
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
context.drawText(textRenderer,"Test",100,100,-1,false);
super.render(context, mouseX, mouseY, delta);
}
}
@@ -2,8 +2,11 @@ package com.expvintl.mctools.modules;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;
@@ -16,5 +19,4 @@ public class CameraZoom {
isZoom=zoom.isPressed();
});
}
}
@@ -0,0 +1,21 @@
package com.expvintl.mctools.modules;
import com.expvintl.mctools.FeaturesSettings;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.effect.StatusEffects;
public class ClearDarknessEffect {
public static ClearDarknessEffect INSTANCE=new ClearDarknessEffect();
public void init(){
ClientTickEvents.END_CLIENT_TICK.register(this::tick);
}
public void tick(MinecraftClient client){
if(client.player!=null && FeaturesSettings.INSTANCE.noDarkness.getValue()){
if (client.player.hasStatusEffect(StatusEffects.DARKNESS)) {
client.player.removeStatusEffect(StatusEffects.DARKNESS);
}
}
}
}