@ -8,6 +8,7 @@ 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;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
@ -16,8 +17,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.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.AttributeModifiersComponent;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.entity.attribute.EntityAttribute;
|
||||
@ -29,6 +29,7 @@ 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;
|
||||
@ -82,7 +83,7 @@ public class CAutoToolCommand {
|
||||
//低耐久测试
|
||||
if(!isLowDurability(currentItem)) {
|
||||
//切换过去
|
||||
event.player.getInventory().setSelectedSlot(slot);
|
||||
event.player.getInventory().selectedSlot=slot;
|
||||
MinecraftClient mc=MinecraftClient.getInstance();
|
||||
if(mc.interactionManager!=null) {
|
||||
((ClientPlayerInteractionManagerAccessor) mc.interactionManager).syncSelectedSlot();
|
||||
@ -119,7 +120,7 @@ public class CAutoToolCommand {
|
||||
//确定已经选择好了工具就切换
|
||||
if(!isLowDurability(currentItem)) {
|
||||
//切换过去
|
||||
mc.player.getInventory().setSelectedSlot(slot);
|
||||
mc.player.getInventory().selectedSlot=slot;
|
||||
if(mc.interactionManager!=null) {
|
||||
((ClientPlayerInteractionManagerAccessor) mc.interactionManager).syncSelectedSlot();
|
||||
}
|
||||
@ -192,20 +193,20 @@ public class CAutoToolCommand {
|
||||
score+=item.getMiningSpeedMultiplier(state)*2;
|
||||
//附魔加分
|
||||
//耐久
|
||||
score+= Utils.GetEnchantLevel(Enchantments.UNBREAKING, item);
|
||||
score+= EnchantmentHelper.getLevel(Enchantments.UNBREAKING, item);
|
||||
//效率
|
||||
score+=Utils.GetEnchantLevel(Enchantments.EFFICIENCY,item);
|
||||
score+=EnchantmentHelper.getLevel(Enchantments.EFFICIENCY,item);
|
||||
//经验修补
|
||||
score+=Utils.GetEnchantLevel(Enchantments.MENDING,item);
|
||||
score+=EnchantmentHelper.getLevel(Enchantments.MENDING,item);
|
||||
|
||||
if(isBlockFortune(state.getBlock())){
|
||||
score+=Utils.GetEnchantLevel(Enchantments.FORTUNE,item);//时运
|
||||
score+=EnchantmentHelper.getLevel(Enchantments.FORTUNE,item);//时运
|
||||
}
|
||||
|
||||
if (isSwordItem(item.getItem()) && (state.getBlock() instanceof BambooBlock|| state.getBlock() instanceof BambooShootBlock)) {
|
||||
if((item.getItem().getComponents().get(DataComponentTypes.TOOL)!=null)){
|
||||
if (isSwordItem(item.getItem()) && (state.getBlock() instanceof BambooBlock)) {
|
||||
if(item.getItem() instanceof ToolItem tool){
|
||||
//根据挖掘等级加分
|
||||
score += 90 + (item.getItem().getComponents().get(DataComponentTypes.TOOL).getSpeed(state));
|
||||
score += 90 + tool.getMaterial().getMiningSpeedMultiplier();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -216,33 +217,31 @@ public class CAutoToolCommand {
|
||||
//剑优先
|
||||
if (isSwordItem(item.getItem())) damageScore += 100;
|
||||
//计算物品的基础伤害属性(较为复杂)
|
||||
AttributeModifiersComponent comp=item.getOrDefault(DataComponentTypes.ATTRIBUTE_MODIFIERS, AttributeModifiersComponent.DEFAULT);
|
||||
final float[] damageHolder = {0.0f};
|
||||
BiConsumer<RegistryEntry<EntityAttribute>, EntityAttributeModifier> baseDamage=(attentry, modify)->{
|
||||
if(attentry.matches(EntityAttributes.ATTACK_DAMAGE)){
|
||||
//计算基础伤害
|
||||
damageHolder [0]= (float)modify.value();
|
||||
Multimap<EntityAttribute, EntityAttributeModifier> modifiers = item.getAttributeModifiers(EquipmentSlot.MAINHAND);
|
||||
Collection<EntityAttributeModifier> damageModifiers = modifiers.get(EntityAttributes.GENERIC_ATTACK_DAMAGE);
|
||||
for (EntityAttributeModifier modifier : damageModifiers) {
|
||||
if (modifier.getOperation() == EntityAttributeModifier.Operation.ADDITION) {
|
||||
damageScore+=(float) modifier.getValue();
|
||||
break;
|
||||
}
|
||||
};
|
||||
comp.applyModifiers(EquipmentSlot.MAINHAND,baseDamage);//计算主手时的伤害
|
||||
damageScore+=damageHolder[0];
|
||||
}
|
||||
//节肢杀手
|
||||
EntityType<?> id=ent.getType();
|
||||
if(id==EntityType.SPIDER||id==EntityType.CAVE_SPIDER||id==EntityType.SILVERFISH||id==EntityType.ENDERMITE||id==EntityType.BEE) {
|
||||
damageScore += Utils.GetEnchantLevel(Enchantments.BANE_OF_ARTHROPODS, item) * 3;
|
||||
damageScore += EnchantmentHelper.getLevel(Enchantments.BANE_OF_ARTHROPODS, item) * 3;
|
||||
}
|
||||
//亡灵杀手(这伤害通常更高)
|
||||
if(ent.getType().isIn(EntityTypeTags.UNDEAD)){
|
||||
damageScore+=Utils.GetEnchantLevel(Enchantments.SMITE,item)*3;// 3倍
|
||||
if(((LivingEntity)ent).getGroup()==EntityGroup.UNDEAD){
|
||||
damageScore+=EnchantmentHelper.getLevel(Enchantments.SMITE,item)*3;// 3倍
|
||||
}
|
||||
//锋利加分
|
||||
damageScore += Utils.GetEnchantLevel(Enchantments.SHARPNESS, item) * 2;
|
||||
damageScore += EnchantmentHelper.getLevel(Enchantments.SHARPNESS, item) * 2;
|
||||
//精修
|
||||
damageScore += Utils.GetEnchantLevel(Enchantments.MENDING, item);
|
||||
damageScore += EnchantmentHelper.getLevel(Enchantments.MENDING, item);
|
||||
//火焰附加
|
||||
damageScore += Utils.GetEnchantLevel(Enchantments.FIRE_ASPECT, item);
|
||||
damageScore += EnchantmentHelper.getLevel(Enchantments.FIRE_ASPECT, item);
|
||||
//击退
|
||||
damageScore += Utils.GetEnchantLevel(Enchantments.KNOCKBACK, item);
|
||||
damageScore += EnchantmentHelper.getLevel(Enchantments.KNOCKBACK, item);
|
||||
return damageScore;
|
||||
}
|
||||
//停用低耐久度
|
||||
@ -258,6 +257,6 @@ public class CAutoToolCommand {
|
||||
item == Items.IRON_AXE || item == Items.IRON_SHOVEL ||
|
||||
item == Items.IRON_HOE;
|
||||
return !(isWooden||isStone||isIron) //忽略木/石/铁工具
|
||||
&&(itemStack.getMaxDamage() - itemStack.getDamage()) < (itemStack.getMaxDamage() * 10 / 100);
|
||||
&&(itemStack.getMaxDamage() - itemStack.getDamage()) < (itemStack.getMaxDamage() * 2 / 100);
|
||||
}
|
||||
}
|
||||
|
@ -9,14 +9,14 @@ import net.minecraft.text.Text;
|
||||
|
||||
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;
|
||||
|
||||
public class CFullbirghtCommand{
|
||||
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher){
|
||||
public class CFullbirghtCommand {
|
||||
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
||||
dispatcher.register(literal("cfullbirght").executes(CFullbirghtCommand::execute));
|
||||
}
|
||||
|
||||
private static int execute(CommandContext<FabricClientCommandSource> context) {
|
||||
((SimpleOptionAccessor)(Object)context.getSource().getClient().options.getGamma()).forceSetValue(32767.0);
|
||||
context.getSource().getPlayer().sendMessage(Text.literal("已应用高亮"),false);
|
||||
((SimpleOptionAccessor) (Object) context.getSource().getClient().options.getGamma()).forceSetValue(32767.0);
|
||||
context.getSource().getPlayer().sendMessage(Text.literal("已应用高亮"), false);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,15 @@
|
||||
package com.expvintl.mctools.mixin.client;
|
||||
|
||||
import com.expvintl.mctools.modules.CameraZoom;
|
||||
import com.expvintl.mctools.utils.Utils;
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public class GameRendererMixin {
|
||||
@ModifyReturnValue(method = "getFov",at=@At("RETURN"))
|
||||
private float getFov(float origin){
|
||||
return CameraZoom.INSTANCE.isZoom?20.f:origin;
|
||||
private double getFov(double original){
|
||||
return CameraZoom.INSTANCE.isZoom?20.f:original;
|
||||
}
|
||||
}
|
||||
|
@ -44,10 +44,10 @@ public class MCInfo {
|
||||
|
||||
return timeString.toString();
|
||||
}
|
||||
public static void drawHUD(DrawContext drawContext, RenderTickCounter v) {
|
||||
public static void drawHUD(DrawContext drawContext, float v) {
|
||||
MinecraftClient mc=MinecraftClient.getInstance();
|
||||
//跳过调试
|
||||
if(mc.getDebugHud().shouldShowDebugHud()||mc.options.hudHidden) return;
|
||||
if(mc.options.debugEnabled||mc.options.hudHidden) return;
|
||||
if(mc.world!=null&&mc.player!=null) {
|
||||
DrawUtils.leftTextY =1;
|
||||
int selfPing=0;
|
||||
|
@ -11,10 +11,10 @@ import net.minecraft.util.Colors;
|
||||
import java.util.Collection;
|
||||
|
||||
public class PotionInfo {
|
||||
public static void drawHUD(DrawContext drawContext, RenderTickCounter v) {
|
||||
public static void drawHUD(DrawContext drawContext, float v) {
|
||||
MinecraftClient mc=MinecraftClient.getInstance();
|
||||
//跳过调试
|
||||
if(mc.getDebugHud().shouldShowDebugHud()||mc.options.hudHidden) return;
|
||||
if(mc.options.debugEnabled||mc.options.hudHidden) return;
|
||||
|
||||
if(mc.world!=null&&mc.player!=null) {
|
||||
DrawUtils.rightBottomY=1;
|
||||
|
@ -44,7 +44,7 @@ public class Utils {
|
||||
|
||||
public static String getCurrentDimensionName() {
|
||||
if (mc.world != null) {
|
||||
String dismenName = mc.world.getDimensionEntry().getIdAsString();
|
||||
String dismenName = mc.world.getDimensionKey().getValue().toString();
|
||||
switch (dismenName) {
|
||||
case "minecraft:overworld":
|
||||
return "主世界";
|
||||
@ -199,18 +199,6 @@ public class Utils {
|
||||
return "未知";
|
||||
}
|
||||
|
||||
public static int GetEnchantLevel(RegistryKey<Enchantment> enchantName, ItemStack item){
|
||||
//跳过附魔书
|
||||
if(item.getItem()== Items.ENCHANTED_BOOK) return 0;
|
||||
Set<Object2IntMap.Entry<RegistryEntry<Enchantment>>> enchants=item.getEnchantments().getEnchantmentEntries();
|
||||
for(Object2IntMap.Entry<RegistryEntry<Enchantment>> entry:enchants){
|
||||
//返回找到的附魔等级
|
||||
if(entry.getKey().matchesKey(enchantName)) {
|
||||
return entry.getIntValue();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public static void rightClick() {
|
||||
((MinecraftClientAccessor) mc).doItemUse();
|
||||
}
|
||||
@ -245,7 +233,7 @@ public class Utils {
|
||||
if(sender==null) return;
|
||||
PlayerListEntry entry = mc.getNetworkHandler().getPlayerListEntry(sender.getId());
|
||||
if (entry == null) return;
|
||||
PlayerSkinDrawer.draw(draw,entry.getSkinTextures(),0,y,8);
|
||||
PlayerSkinDrawer.draw(draw,entry.getSkinTexture(),0,y,8);
|
||||
draw.getMatrices().translate(10, 0, 0);
|
||||
}
|
||||
public static GameProfile getChatSender(String text){
|
||||
|
@ -21,6 +21,6 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.8.0",
|
||||
"fabric": "*",
|
||||
"minecraft": "~1.21"
|
||||
"minecraft": "~1.20.1"
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.expvintl.mctools.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"hud.ChatHudMixin",
|
||||
"hud.PlayerListHudMixin",
|
||||
|
Reference in New Issue
Block a user