autofish
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,7 +1,17 @@
|
||||
{
|
||||
"mappings": {
|
||||
"com/expvintl/mctools/mixin/MinecraftClientMixin": {
|
||||
"setScreen": "Lnet/minecraft/class_310;method_1507(Lnet/minecraft/class_437;)V"
|
||||
"setScreen": "Lnet/minecraft/class_310;method_1507(Lnet/minecraft/class_437;)V",
|
||||
"tick": "Lnet/minecraft/class_310;method_1574()V"
|
||||
},
|
||||
"com/expvintl/mctools/mixin/SoundSystemMixin": {
|
||||
"play(Lnet/minecraft/client/sound/SoundInstance;)V": "Lnet/minecraft/class_1140;method_4854(Lnet/minecraft/class_1113;)V"
|
||||
},
|
||||
"com/expvintl/mctools/mixin/interfaces/ClientPlayerInteractionManagerAccessor": {
|
||||
"syncSelectedSlot": "method_2911()V"
|
||||
},
|
||||
"com/expvintl/mctools/mixin/interfaces/MinecraftClientAccessor": {
|
||||
"doItemUse": "method_1583()V"
|
||||
},
|
||||
"com/expvintl/mctools/mixin/interfaces/SimpleOptionAccessor": {
|
||||
"value": "field_37868:Ljava/lang/Object;"
|
||||
@ -20,7 +30,17 @@
|
||||
"data": {
|
||||
"named:intermediary": {
|
||||
"com/expvintl/mctools/mixin/MinecraftClientMixin": {
|
||||
"setScreen": "Lnet/minecraft/class_310;method_1507(Lnet/minecraft/class_437;)V"
|
||||
"setScreen": "Lnet/minecraft/class_310;method_1507(Lnet/minecraft/class_437;)V",
|
||||
"tick": "Lnet/minecraft/class_310;method_1574()V"
|
||||
},
|
||||
"com/expvintl/mctools/mixin/SoundSystemMixin": {
|
||||
"play(Lnet/minecraft/client/sound/SoundInstance;)V": "Lnet/minecraft/class_1140;method_4854(Lnet/minecraft/class_1113;)V"
|
||||
},
|
||||
"com/expvintl/mctools/mixin/interfaces/ClientPlayerInteractionManagerAccessor": {
|
||||
"syncSelectedSlot": "method_2911()V"
|
||||
},
|
||||
"com/expvintl/mctools/mixin/interfaces/MinecraftClientAccessor": {
|
||||
"doItemUse": "method_1583()V"
|
||||
},
|
||||
"com/expvintl/mctools/mixin/interfaces/SimpleOptionAccessor": {
|
||||
"value": "field_37868:Ljava/lang/Object;"
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -9,6 +9,9 @@
|
||||
],
|
||||
"client": [
|
||||
"MinecraftClientMixin",
|
||||
"SoundSystemMixin",
|
||||
"interfaces.ClientPlayerInteractionManagerAccessor",
|
||||
"interfaces.MinecraftClientAccessor",
|
||||
"interfaces.SimpleOptionAccessor",
|
||||
"player.ClientPlayerInteractionManagerMixin"
|
||||
],
|
||||
|
Binary file not shown.
@ -5,4 +5,5 @@ public class FeaturesBool {
|
||||
public static boolean selfWalk=false;
|
||||
public static boolean checkBukkitPlugins=false;
|
||||
public static boolean autoTool=false;
|
||||
public static boolean autoFish=false;
|
||||
}
|
||||
|
@ -10,16 +10,12 @@ import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.command.CommandRegistryAccess;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class MCToolsClient implements ClientModInitializer {
|
||||
private static int infoY=1;
|
||||
@ -57,7 +53,12 @@ public class MCToolsClient implements ClientModInitializer {
|
||||
}else{
|
||||
AddText(drawContext,String.format("X:%.2f Y:%.2f Z:%.2f",playerPos.x,playerPos.y,playerPos.z));
|
||||
}
|
||||
AddText(drawContext,String.format("世界时间: %d天 (%d 小时)",mc.world.getTimeOfDay()/24000,((mc.world.getTimeOfDay()/24000)*20)/60));
|
||||
AddText(drawContext,String.format("当前区块: [%d,%d]",mc.player.getChunkPos().x,mc.player.getChunkPos().z));
|
||||
ItemStack currentItem=p.getInventory().getMainHandStack();
|
||||
if(currentItem!=null&¤tItem.isDamageable()){
|
||||
AddText(drawContext,String.format("耐久度:%d/%d",currentItem.getMaxDamage()-currentItem.getDamage(),currentItem.getMaxDamage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void AddText(DrawContext drawContext,String text){
|
||||
@ -70,6 +71,7 @@ public class MCToolsClient implements ClientModInitializer {
|
||||
CFullbirghtCommand.register(dispatcher);
|
||||
CAutoRespawnCommand.register(dispatcher);
|
||||
CSafeWalkCommand.register(dispatcher);
|
||||
CAutoFishCommand.register(dispatcher);
|
||||
CAutoToolCommand.register(dispatcher);
|
||||
CQServerPluginsCommand.register(dispatcher);
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
package com.expvintl.mctools.commands;
|
||||
|
||||
import com.expvintl.mctools.FeaturesBool;
|
||||
import com.expvintl.mctools.events.MCEventBus;
|
||||
import com.expvintl.mctools.events.client.sounds.PlaySoundEvent;
|
||||
import com.expvintl.mctools.utils.Utils;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
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 java.util.TimerTask;
|
||||
|
||||
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument;
|
||||
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;
|
||||
|
||||
public class CAutoFishCommand {
|
||||
private static final CAutoFishCommand INSTANCE=new CAutoFishCommand();
|
||||
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher){
|
||||
MCEventBus.INSTANCE.register(INSTANCE);
|
||||
dispatcher.register(literal("cautofish").then(argument("开关", BoolArgumentType.bool()).executes(CAutoFishCommand::execute)));
|
||||
}
|
||||
|
||||
private static int execute(CommandContext<FabricClientCommandSource> context) {
|
||||
FeaturesBool.autoFish=context.getArgument("开关", Boolean.class);
|
||||
if(FeaturesBool.autoFish){
|
||||
context.getSource().getPlayer().sendMessage(Text.literal("已启用自动钓鱼!"));
|
||||
}else{
|
||||
context.getSource().getPlayer().sendMessage(Text.literal("已禁用自动钓鱼!"));
|
||||
}
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
@Subscribe
|
||||
private void onPlaySound(PlaySoundEvent event){
|
||||
if(FeaturesBool.autoFish) {
|
||||
//自动钓鱼
|
||||
if (event.soundInstance.getId().getPath().equals("entity.fishing_bobber.splash")) {
|
||||
//收杆
|
||||
Utils.rightClick();
|
||||
Utils.timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utils.rightClick();
|
||||
}
|
||||
},300);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ package com.expvintl.mctools.commands;
|
||||
import com.expvintl.mctools.FeaturesBool;
|
||||
import com.expvintl.mctools.events.MCEventBus;
|
||||
import com.expvintl.mctools.events.client.OpenScreenEvent;
|
||||
import com.expvintl.mctools.mixin.interfaces.SimpleOptionAccessor;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
@ -4,6 +4,7 @@ import com.expvintl.mctools.FeaturesBool;
|
||||
import com.expvintl.mctools.events.MCEventBus;
|
||||
import com.expvintl.mctools.events.player.PlayerAttackBlockEvent;
|
||||
import com.expvintl.mctools.events.player.PlayerBreakBlockEvent;
|
||||
import com.expvintl.mctools.mixin.interfaces.ClientPlayerInteractionManagerAccessor;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
@ -14,6 +15,8 @@ import net.minecraft.block.BambooBlock;
|
||||
import net.minecraft.block.BambooSaplingBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ShearsItem;
|
||||
import net.minecraft.item.SwordItem;
|
||||
@ -76,14 +79,14 @@ public class CAutoToolCommand {
|
||||
}
|
||||
}
|
||||
//确定已经选择好了工具就切换
|
||||
if((slot!=-1&&bestScore>getScore(currentItem,state))||shouldStopUsing(currentItem)||!isTools(currentItem)) {
|
||||
if((slot!=-1&&bestScore>getScore(currentItem,state)&&!lowDurability(currentItem))||!isTools(currentItem)) {
|
||||
//记住上一次的槽方便恢复
|
||||
lastSlot=mc.player.getInventory().selectedSlot;
|
||||
//切换过去
|
||||
mc.player.getInventory().selectedSlot = slot;
|
||||
}
|
||||
if(isTools(currentItem)&&shouldStopUsing(currentItem)) {
|
||||
mc.options.attackKey.setPressed(false);
|
||||
if(mc.interactionManager!=null) {
|
||||
((ClientPlayerInteractionManagerAccessor) mc.interactionManager).syncSelectedSlot();
|
||||
}
|
||||
}
|
||||
}
|
||||
public double getScore(ItemStack item, BlockState state){
|
||||
@ -92,6 +95,13 @@ public class CAutoToolCommand {
|
||||
if(item.getItem() instanceof ToolItem || item.getItem() instanceof ShearsItem){
|
||||
//根据挖掘速度提升评分
|
||||
score+=item.getMiningSpeedMultiplier(state)*10;
|
||||
//附魔加分
|
||||
//耐久
|
||||
score+= EnchantmentHelper.getLevel(Enchantments.UNBREAKING,item)*10;
|
||||
//效率
|
||||
score+=EnchantmentHelper.getLevel(Enchantments.EFFICIENCY,item)*5;
|
||||
//经验修补(此项最优先)
|
||||
score+=EnchantmentHelper.getLevel(Enchantments.MENDING,item)*20;
|
||||
if (item.getItem() instanceof SwordItem item1 && (state.getBlock() instanceof BambooBlock || state.getBlock() instanceof BambooSaplingBlock))
|
||||
//根据挖掘等级加分
|
||||
score += 90 + (item1.getMaterial().getMiningLevel() * 10);
|
||||
@ -99,8 +109,8 @@ public class CAutoToolCommand {
|
||||
return score;
|
||||
}
|
||||
//停用低耐久度
|
||||
private boolean shouldStopUsing(ItemStack itemStack) {
|
||||
return (itemStack.getMaxDamage() - itemStack.getDamage()) < (itemStack.getMaxDamage() * 6 / 100);
|
||||
private boolean lowDurability(ItemStack itemStack) {
|
||||
return (itemStack.getMaxDamage() - itemStack.getDamage()) < (itemStack.getMaxDamage() * 10 / 100);
|
||||
}
|
||||
public boolean isTools(ItemStack item){
|
||||
return item.getItem() instanceof ToolItem || item.getItem() instanceof ShearsItem;
|
||||
|
@ -3,6 +3,7 @@ package com.expvintl.mctools.commands;
|
||||
import com.expvintl.mctools.FeaturesBool;
|
||||
import com.expvintl.mctools.events.MCEventBus;
|
||||
import com.expvintl.mctools.events.network.PacketEvent;
|
||||
import com.expvintl.mctools.utils.Utils;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
@ -13,9 +14,10 @@ import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.network.packet.c2s.play.RequestCommandCompletionsC2SPacket;
|
||||
import net.minecraft.network.packet.s2c.play.CommandSuggestionsS2CPacket;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;
|
||||
|
||||
public class CQServerPluginsCommand {
|
||||
@ -30,7 +32,7 @@ public class CQServerPluginsCommand {
|
||||
FeaturesBool.checkBukkitPlugins=true;
|
||||
context.getSource().getPlayer().networkHandler.sendPacket(new RequestCommandCompletionsC2SPacket(new Random().nextInt(200),"bukkit:ver "));
|
||||
//1秒后关闭避免识别其他命令提示
|
||||
new Timer().schedule(new TimerTask() {
|
||||
Utils.timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
FeaturesBool.checkBukkitPlugins=false;
|
||||
|
@ -0,0 +1,8 @@
|
||||
package com.expvintl.mctools.events.client;
|
||||
|
||||
public class PreTickEvent {
|
||||
private static final PreTickEvent INSTANCE=new PreTickEvent();
|
||||
public static PreTickEvent get(){
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.expvintl.mctools.events.client.sounds;
|
||||
|
||||
import net.minecraft.client.sound.SoundInstance;
|
||||
|
||||
public class PlaySoundEvent {
|
||||
private static final PlaySoundEvent INSTANCE=new PlaySoundEvent();
|
||||
public SoundInstance soundInstance;
|
||||
public static PlaySoundEvent get(SoundInstance instance){
|
||||
INSTANCE.soundInstance=instance;
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.expvintl.mctools.events.player;
|
||||
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.expvintl.mctools.events.player;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.lwjgl.system.windows.INPUT;
|
||||
|
||||
public class PlayerBreakBlockEvent {
|
||||
private static final PlayerBreakBlockEvent INSTANCE=new PlayerBreakBlockEvent();
|
||||
|
@ -1,10 +1,9 @@
|
||||
package com.expvintl.mctools.mixin;
|
||||
|
||||
import com.expvintl.mctools.FeaturesBool;
|
||||
import com.expvintl.mctools.events.MCEventBus;
|
||||
import com.expvintl.mctools.events.client.OpenScreenEvent;
|
||||
import com.expvintl.mctools.events.client.PreTickEvent;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.DeathScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -18,4 +17,9 @@ public class MinecraftClientMixin {
|
||||
private void onSetScreen(Screen screen, CallbackInfo info){
|
||||
MCEventBus.INSTANCE.post(OpenScreenEvent.get(screen));
|
||||
}
|
||||
@Inject(method = "tick",at=@At("HEAD"))
|
||||
private void onPreTick(CallbackInfo ci){
|
||||
MCEventBus.INSTANCE.register(PreTickEvent.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.expvintl.mctools.mixin;
|
||||
|
||||
import com.expvintl.mctools.events.MCEventBus;
|
||||
import com.expvintl.mctools.events.client.sounds.PlaySoundEvent;
|
||||
import net.minecraft.client.sound.SoundInstance;
|
||||
import net.minecraft.client.sound.SoundSystem;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(SoundSystem.class)
|
||||
public class SoundSystemMixin {
|
||||
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V",at=@At("HEAD"))
|
||||
private void onPlaySound(SoundInstance instance, CallbackInfo ci){
|
||||
MCEventBus.INSTANCE.post(PlaySoundEvent.get(instance));
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.expvintl.mctools.mixin.interfaces;
|
||||
|
||||
import net.minecraft.client.network.ClientPlayerInteractionManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(ClientPlayerInteractionManager.class)
|
||||
public interface ClientPlayerInteractionManagerAccessor {
|
||||
@Invoker("syncSelectedSlot")
|
||||
void syncSelectedSlot();
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package com.expvintl.mctools.mixin.interfaces;
|
||||
|
||||
public interface IClientPlayerInteractionManager {
|
||||
void syncSelected();
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.expvintl.mctools.mixin.interfaces;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
public interface MinecraftClientAccessor {
|
||||
@Invoker("doItemUse")
|
||||
void doItemUse();
|
||||
}
|
@ -1,27 +1,14 @@
|
||||
package com.expvintl.mctools.mixin.player;
|
||||
|
||||
import com.expvintl.mctools.FeaturesBool;
|
||||
import com.expvintl.mctools.events.MCEventBus;
|
||||
import com.expvintl.mctools.events.player.PlayerAttackBlockEvent;
|
||||
import com.expvintl.mctools.events.player.PlayerBreakBlockEvent;
|
||||
import com.expvintl.mctools.mixin.interfaces.IClientPlayerInteractionManager;
|
||||
import net.minecraft.block.BambooBlock;
|
||||
import net.minecraft.block.BambooSaplingBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayerInteractionManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ShearsItem;
|
||||
import net.minecraft.item.SwordItem;
|
||||
import net.minecraft.item.ToolItem;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ClientPlayerInteractionManager.class)
|
||||
|
@ -1,14 +1,17 @@
|
||||
package com.expvintl.mctools.utils;
|
||||
|
||||
import com.expvintl.mctools.mixin.interfaces.MinecraftClientAccessor;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Timer;
|
||||
|
||||
public class Utils {
|
||||
private static final MinecraftClient mc=MinecraftClient.getInstance();
|
||||
public static final Timer timer=new Timer();
|
||||
public static String getCurrentDimensionName(){
|
||||
if(mc.world!=null){
|
||||
String dismenName=mc.world.getDimensionKey().getValue().toString();
|
||||
@ -99,4 +102,7 @@ public class Utils {
|
||||
}
|
||||
return "未知";
|
||||
}
|
||||
public static void rightClick(){
|
||||
((MinecraftClientAccessor)mc).doItemUse();
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,9 @@
|
||||
],
|
||||
"client": [
|
||||
"MinecraftClientMixin",
|
||||
"SoundSystemMixin",
|
||||
"interfaces.ClientPlayerInteractionManagerAccessor",
|
||||
"interfaces.MinecraftClientAccessor",
|
||||
"interfaces.SimpleOptionAccessor",
|
||||
"player.ClientPlayerInteractionManagerMixin"
|
||||
],
|
||||
|
Reference in New Issue
Block a user