diff --git a/.idea/runConfigurations/Minecraft_Server.xml b/.idea/runConfigurations/Minecraft_Server.xml
index aff153d..5f372c2 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/gradle.properties b/gradle.properties
index 0168541..a655a86 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,12 +3,12 @@ org.gradle.jvmargs=-Xmx2G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
- minecraft_version=1.21
- yarn_mappings=1.21+build.9
+ minecraft_version=1.20.4
+ yarn_mappings=1.20.4+build.3
loader_version=0.16.0
#Fabric api
- fabric_version=0.100.8+1.21
+ fabric_version=0.97.2+1.20.4
# Mod Properties
mod_version = 1.0
diff --git a/src/main/java/com/expvintl/mctools/commands/CAutoToolCommand.java b/src/main/java/com/expvintl/mctools/commands/CAutoToolCommand.java
index 97b4bfc..ec9122b 100644
--- a/src/main/java/com/expvintl/mctools/commands/CAutoToolCommand.java
+++ b/src/main/java/com/expvintl/mctools/commands/CAutoToolCommand.java
@@ -18,7 +18,7 @@ import net.minecraft.block.BambooBlock;
import net.minecraft.block.BambooShootBlock;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
-import net.minecraft.component.DataComponentTypes;
+import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
@@ -130,14 +130,14 @@ public class CAutoToolCommand {
score+=item.getMiningSpeedMultiplier(state)*30;
//附魔加分
//耐久
- 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 (item.getItem() instanceof SwordItem item1 && (state.getBlock() instanceof BambooBlock|| state.getBlock() instanceof BambooShootBlock))
//根据挖掘等级加分
- score += 90 + (item1.getComponents().get(DataComponentTypes.TOOL).getSpeed(state) * 10);
+ score += 90 + (item1.getMaterial().getMiningSpeedMultiplier() * 10);
}
return score;
}
@@ -150,13 +150,13 @@ public class CAutoToolCommand {
if (item.getItem() instanceof ToolItem tool) {
damageScore += tool.getMaterial().getAttackDamage();
//锋利加分
- 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)*3;
+ damageScore+=EnchantmentHelper.getLevel(Enchantments.FIRE_ASPECT,item)*3;
//击退
- damageScore+=Utils.GetEnchantLevel(Enchantments.KNOCKBACK,item)*2;
+ damageScore+=EnchantmentHelper.getLevel(Enchantments.KNOCKBACK,item)*2;
}
return damageScore;
}
diff --git a/src/main/java/com/expvintl/mctools/texthud/MCInfo.java b/src/main/java/com/expvintl/mctools/texthud/MCInfo.java
index d42e96c..6b6dd74 100644
--- a/src/main/java/com/expvintl/mctools/texthud/MCInfo.java
+++ b/src/main/java/com/expvintl/mctools/texthud/MCInfo.java
@@ -42,7 +42,7 @@ 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;
@@ -67,7 +67,7 @@ public class MCInfo {
DrawUtils.AddLeftText(drawContext,String.format("X:%.2f Y:%.2f Z:%.2f",playerPos.x,playerPos.y,playerPos.z));
}
DrawUtils.AddLeftText(drawContext,String.format("世界时间: %d天 (%s)",mc.world.getTimeOfDay()/24000,gameDayToRealTimeFormat(mc.world.getTimeOfDay()/24000)));
- DrawUtils.AddLeftText(drawContext,String.format("当前区块: [%d,%d]",mc.player.getChunkPos().x,mc.player.getChunkPos().z));
+ DrawUtils.AddLeftText(drawContext,String.format("当前区块: [%d,%d],方块:[%d,%d,%d]",mc.player.getChunkPos().x,mc.player.getChunkPos().z,mc.player.getBlockX()&0xF,mc.player.getBlockY()&0xF,mc.player.getBlockZ()&0xF));
DrawUtils.AddLeftText(drawContext,String.format("本地难度:%.2f",mc.world.getLocalDifficulty(mc.player.getBlockPos()).getLocalDifficulty()));
ItemStack currentItem=p.getInventory().getMainHandStack();
if(currentItem!=null&¤tItem.isDamageable()){
diff --git a/src/main/java/com/expvintl/mctools/texthud/PotionInfo.java b/src/main/java/com/expvintl/mctools/texthud/PotionInfo.java
index 295ba93..be23d9c 100644
--- a/src/main/java/com/expvintl/mctools/texthud/PotionInfo.java
+++ b/src/main/java/com/expvintl/mctools/texthud/PotionInfo.java
@@ -11,7 +11,7 @@ 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;
diff --git a/src/main/java/com/expvintl/mctools/utils/Utils.java b/src/main/java/com/expvintl/mctools/utils/Utils.java
index 3895071..ec2fb3e 100644
--- a/src/main/java/com/expvintl/mctools/utils/Utils.java
+++ b/src/main/java/com/expvintl/mctools/utils/Utils.java
@@ -41,7 +41,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 "主世界";
@@ -196,18 +196,18 @@ public class Utils {
return "未知";
}
- public static int GetEnchantLevel(RegistryKey enchantName, ItemStack item){
- //跳过附魔书
- if(item.getItem()== Items.ENCHANTED_BOOK) return 0;
- Set>> enchants=item.getEnchantments().getEnchantmentEntries();
- for(Object2IntMap.Entry> entry:enchants){
- //返回找到的附魔等级
- if(entry.getKey().matchesKey(enchantName)) {
- return entry.getIntValue();
- }
- }
- return 0;
- }
+// public static int GetEnchantLevel(RegistryKey enchantName, ItemStack item){
+// //跳过附魔书
+// if(item.getItem()== Items.ENCHANTED_BOOK) return 0;
+// Set>> enchants=item.getEnchantments().getEnchantmentEntries();
+// for(Object2IntMap.Entry> entry:enchants){
+// //返回找到的附魔等级
+// if(entry.getKey().matchesKey(enchantName)) {
+// return entry.getIntValue();
+// }
+// }
+// return 0;
+// }
public static void rightClick() {
((MinecraftClientAccessor) mc).doItemUse();
}
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
index 57a2132..3220f02 100644
--- a/src/main/resources/fabric.mod.json
+++ b/src/main/resources/fabric.mod.json
@@ -21,6 +21,6 @@
"depends": {
"fabricloader": ">=0.8.0",
"fabric": "*",
- "minecraft": "~1.21"
+ "minecraft": "~1.20.4"
}
}