This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="liberica-21" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" project-jdk-name="liberica-21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
2
.idea/modules.xml
generated
2
.idea/modules.xml
generated
@ -3,7 +3,9 @@
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/MCTools.main.iml" filepath="$PROJECT_DIR$/.idea/modules/MCTools.main.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/MCTools.main~1.iml" filepath="$PROJECT_DIR$/.idea/modules/MCTools.main~1.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/MCTools.test.iml" filepath="$PROJECT_DIR$/.idea/modules/MCTools.test.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/MCTools.test~1.iml" filepath="$PROJECT_DIR$/.idea/modules/MCTools.test~1.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/MinecraftProjects.MCTools.main.iml" filepath="$PROJECT_DIR$/.idea/modules/MinecraftProjects.MCTools.main.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/MinecraftProjects.MCTools.test.iml" filepath="$PROJECT_DIR$/.idea/modules/MinecraftProjects.MCTools.test.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/com.expvintl.MCTools.main.iml" filepath="$PROJECT_DIR$/.idea/modules/com.expvintl.MCTools.main.iml" />
|
||||
|
4
.idea/modules/MCTools.main.iml
generated
4
.idea/modules/MCTools.main.iml
generated
@ -14,4 +14,8 @@
|
||||
<component name="McpModuleSettings">
|
||||
<option name="srgType" value="SRG" />
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
2
.idea/runConfigurations/Minecraft_Server.xml
generated
2
.idea/runConfigurations/Minecraft_Server.xml
generated
@ -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.apache.httpcomponents\httpclient\4.5.13\e5f6cae5ca7ecaac1ec2827a9e2d65ae2869cada\httpclient-4.5.13.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\com.ibm.icu\icu4j\73.2\61ad4ef7f9131fcf6d25c34b817f90d6da06c9e9\icu4j-73.2.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-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.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-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-codec\commons-codec\1.16.0\4e3eb3d79888d76b54e28b350915b5dc3919c9de\commons-codec-1.16.0.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-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-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-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-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\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\text2speech\1.17.9\3cad216e3a7f0c19b4b394388bc9ffc446f13b14\text2speech-1.17.9.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\3.3.3\29589b5f87ed335a6c7e7ee6a5775f81f97ecb84\lwjgl-3.3.3.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\commons-logging\commons-logging\1.2\4bfc12adfe4842bf07b657f0369c4cb522955686\commons-logging-1.2.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-compress\1.26.0\659feffdd12280201c8aacb8f7be94f9a883c824\commons-compress-1.26.0.jar"/></classpathModifications></configuration>
|
||||
<classpathModifications><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.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\commons-codec\commons-codec\1.16.0\4e3eb3d79888d76b54e28b350915b5dc3919c9de\commons-codec-1.16.0.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-compress\1.26.0\659feffdd12280201c8aacb8f7be94f9a883c824\commons-compress-1.26.0.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\com.ibm.icu\icu4j\73.2\61ad4ef7f9131fcf6d25c34b817f90d6da06c9e9\icu4j-73.2.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-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\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\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-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\commons-logging\commons-logging\1.2\4bfc12adfe4842bf07b657f0369c4cb522955686\commons-logging-1.2.jar"/><entry exclude="true" path="C:\Users\expvintl\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpclient\4.5.13\e5f6cae5ca7ecaac1ec2827a9e2d65ae2869cada\httpclient-4.5.13.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.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\com.mojang\text2speech\1.17.9\3cad216e3a7f0c19b4b394388bc9ffc446f13b14\text2speech-1.17.9.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"/></classpathModifications></configuration>
|
||||
</component>
|
@ -3,6 +3,8 @@ package com.expvintl.mctools;
|
||||
import com.expvintl.mctools.commands.*;
|
||||
import com.expvintl.mctools.modules.BetterTooltip;
|
||||
import com.expvintl.mctools.modules.PlayerListTextLatency;
|
||||
import com.expvintl.mctools.texthud.MCInfo;
|
||||
import com.expvintl.mctools.texthud.PotionInfo;
|
||||
import com.expvintl.mctools.utils.Utils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
@ -21,87 +23,19 @@ import net.minecraft.util.math.Vec3d;
|
||||
|
||||
|
||||
public class MCToolsClient implements ClientModInitializer {
|
||||
private static int infoY=1;
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
//初始化命令注册回调
|
||||
ClientCommandRegistrationCallback.EVENT.register(MCToolsClient::registerCommands);
|
||||
HudRenderCallback.EVENT.register(MCToolsClient::drawHUD);
|
||||
HudRenderCallback.EVENT.register(MCInfo::drawHUD);
|
||||
HudRenderCallback.EVENT.register(PotionInfo::drawHUD);
|
||||
InitModules();
|
||||
}
|
||||
public void InitModules(){
|
||||
BetterTooltip.INSTANCE.init();
|
||||
PlayerListTextLatency.INSTANCE.init();
|
||||
}
|
||||
private static String gameDayToRealTimeFormat(long gameDays) {
|
||||
// 游戏 1 小时等于 20 分钟
|
||||
long totalMinutes = gameDays * 20;
|
||||
|
||||
long days = totalMinutes / (60 * 24); // 计算天数
|
||||
long remainingMinutesAfterDays = totalMinutes % (60 * 24);
|
||||
|
||||
long hours = remainingMinutesAfterDays / 60; // 计算小时数
|
||||
long minutes = remainingMinutesAfterDays % 60; // 计算剩余分钟数
|
||||
|
||||
StringBuilder timeString = new StringBuilder();
|
||||
|
||||
if (days > 0) {
|
||||
timeString.append(days).append(" 天");
|
||||
}
|
||||
if (hours > 0) {
|
||||
if (!timeString.isEmpty()) {
|
||||
timeString.append(" ");
|
||||
}
|
||||
timeString.append(hours).append(" 小时");
|
||||
}
|
||||
if (minutes > 0 || timeString.isEmpty()) {
|
||||
if (!timeString.isEmpty()) {
|
||||
timeString.append(" ");
|
||||
}
|
||||
timeString.append(minutes).append(" 分钟");
|
||||
}
|
||||
|
||||
return timeString.toString();
|
||||
}
|
||||
private static void drawHUD(DrawContext drawContext, RenderTickCounter v) {
|
||||
MinecraftClient mc=MinecraftClient.getInstance();
|
||||
//跳过调试
|
||||
if(mc.getDebugHud().shouldShowDebugHud()||mc.options.hudHidden) return;
|
||||
|
||||
if(mc.world!=null&&mc.player!=null) {
|
||||
infoY=1;
|
||||
int selfPing=0;
|
||||
ClientPlayerEntity p=mc.player;
|
||||
if(mc.getNetworkHandler()!=null&&mc.getNetworkHandler().getPlayerListEntry(mc.player.getGameProfile().getId())!=null) {
|
||||
selfPing=mc.getNetworkHandler().getPlayerListEntry(mc.player.getGameProfile().getId()).getLatency();
|
||||
}
|
||||
Vec3d playerPos=p.getPos();
|
||||
AddText(drawContext,String.format("%d FPS",mc.getCurrentFps()));
|
||||
AddText(drawContext,String.format("Ping: %d 毫秒",selfPing));
|
||||
AddText(drawContext,String.format("亮度:%d",mc.world.getLightLevel(p.getBlockPos())));
|
||||
AddText(drawContext,String.format("当前维度:%s", Utils.getCurrentDimensionName()));
|
||||
AddText(drawContext,String.format("当前群系:%s",Utils.getCurrentBiomeName()));
|
||||
if(Utils.getCurrentDimensionName().equals("下界")){
|
||||
AddText(drawContext,String.format("X:%.2f Y:%.2f Z:%.2f (主世界 X:%.2f Z:%.2f)",playerPos.x,playerPos.y,playerPos.z,playerPos.x*8,playerPos.z*8));
|
||||
}else if(Utils.getCurrentDimensionName().equals("主世界")){
|
||||
AddText(drawContext,String.format("X:%.2f Y:%.2f Z:%.2f (下界 X:%.2f Z:%.2f)",playerPos.x,playerPos.y,playerPos.z,playerPos.x/8,playerPos.z/8));
|
||||
}else{
|
||||
AddText(drawContext,String.format("X:%.2f Y:%.2f Z:%.2f",playerPos.x,playerPos.y,playerPos.z));
|
||||
}
|
||||
AddText(drawContext,String.format("世界时间: %d天 (%s)",mc.world.getTimeOfDay()/24000,gameDayToRealTimeFormat(mc.world.getTimeOfDay()/24000)));
|
||||
AddText(drawContext,String.format("当前区块: [%d,%d]",mc.player.getChunkPos().x,mc.player.getChunkPos().z));
|
||||
AddText(drawContext,String.format("本地难度:%.2f",mc.world.getLocalDifficulty(mc.player.getBlockPos()).getLocalDifficulty()));
|
||||
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){
|
||||
TextRenderer renderer=MinecraftClient.getInstance().textRenderer;
|
||||
drawContext.drawText(renderer,text,0,infoY,Colors.WHITE,false);
|
||||
infoY+=10;
|
||||
}
|
||||
private static void registerCommands(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandRegistryAccess registryAccess) {
|
||||
//注册命令
|
||||
CFullbirghtCommand.register(dispatcher);
|
||||
@ -112,6 +46,6 @@ public class MCToolsClient implements ClientModInitializer {
|
||||
CQServerPluginsCommand.register(dispatcher);
|
||||
CNoFallPacketCommand.register(dispatcher);
|
||||
CFindBlockCommand.register(dispatcher);
|
||||
CFastDropCommand.register(dispatcher);
|
||||
CFastDropCommand.register(dispatcher,registryAccess);
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,79 @@
|
||||
package com.expvintl.mctools.commands;
|
||||
|
||||
import com.expvintl.mctools.mixin.interfaces.SimpleOptionAccessor;
|
||||
import com.expvintl.mctools.utils.PlayerUtils;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.command.CommandRegistryAccess;
|
||||
import net.minecraft.command.argument.ItemStackArgumentType;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument;
|
||||
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;
|
||||
|
||||
public class CFastDropCommand {
|
||||
public static List<Item> trashItem=new ArrayList<>();
|
||||
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher){
|
||||
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher , CommandRegistryAccess access){
|
||||
dispatcher.register(literal("cfastdrop").executes(CFastDropCommand::execute));
|
||||
dispatcher.register(literal("cfastdrop").then(literal("list").executes((context -> {
|
||||
StringBuilder sb=new StringBuilder();
|
||||
sb.append("已添加:\n");
|
||||
for(Item i:trashItem){
|
||||
sb.append(i.getName().getString()).append(",");
|
||||
}
|
||||
context.getSource().getPlayer().sendMessage(Text.literal(sb.toString()));
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}))));
|
||||
dispatcher.register(literal("cfastdrop").then(literal("clear").executes((context -> {
|
||||
trashItem.clear();
|
||||
context.getSource().getPlayer().sendMessage(Text.literal("已清除全部物品!"));
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}))));
|
||||
dispatcher.register(literal("cfastdrop").then(literal("del").then(argument("物品", ItemStackArgumentType.itemStack(access)).suggests(((context, builder) -> suggestItems(builder))).executes(cmd->{
|
||||
Item item=ItemStackArgumentType.getItemStackArgument(cmd,"物品").getItem();
|
||||
if (item != Items.AIR) { // 确保找到的物品是有效的
|
||||
if (trashItem.contains(item)) {
|
||||
trashItem.remove(item);
|
||||
cmd.getSource().getPlayer().sendMessage(Text.literal("已移除 " + item.getName().getString()));
|
||||
}else{
|
||||
cmd.getSource().getPlayer().sendMessage(Text.literal("没有找到 " + item.getName().getString()));
|
||||
}
|
||||
}else{
|
||||
cmd.getSource().getPlayer().sendMessage(Text.literal("无效物品!"));
|
||||
return 0;
|
||||
}
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}))));
|
||||
dispatcher.register(literal("cfastdrop").then(literal("add").then(argument("物品", ItemStackArgumentType.itemStack(access)).suggests(((context, builder) -> suggestItems(builder))).executes(cmd->{
|
||||
Item item=ItemStackArgumentType.getItemStackArgument(cmd,"物品").getItem();
|
||||
if (item != Items.AIR) { // 确保找到的物品是有效的
|
||||
if(trashItem.contains(item)){
|
||||
cmd.getSource().getPlayer().sendMessage(Text.literal( item.getName().getString() + " 已存在!"));
|
||||
}else {
|
||||
trashItem.add(item);
|
||||
cmd.getSource().getPlayer().sendMessage(Text.literal("已添加 " + item.getName().getString() + " 到垃圾物品列表"));
|
||||
}
|
||||
}else{
|
||||
cmd.getSource().getPlayer().sendMessage(Text.literal("无效物品!"));
|
||||
return 0;
|
||||
}
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}))));
|
||||
trashItem.add(Items.COBBLESTONE);
|
||||
trashItem.add(Items.GRANITE);//花岗岩
|
||||
trashItem.add(Items.ANDESITE);//安山岩
|
||||
@ -35,8 +87,17 @@ public class CFastDropCommand {
|
||||
trashItem.add(Items.DANDELION);
|
||||
trashItem.add(Items.SUNFLOWER);
|
||||
trashItem.add(Items.CORNFLOWER);
|
||||
trashItem.add(Items.TUFF); //凝灰岩
|
||||
trashItem.add(Items.DEEPSLATE); //深板岩
|
||||
trashItem.add(Items.SANDSTONE); //砂岩
|
||||
trashItem.add(Items.DEEPSLATE_BRICKS);//深板岩砖
|
||||
trashItem.add(Items.COBBLED_DEEPSLATE); //深板岩圆石
|
||||
}
|
||||
private static CompletableFuture<Suggestions> suggestItems(SuggestionsBuilder builder) {
|
||||
// 遍历所有注册的物品并将其添加到建议列表中
|
||||
Registries.ITEM.getIds().forEach(id -> builder.suggest(id.toString()));
|
||||
return builder.buildFuture();
|
||||
}
|
||||
|
||||
private static int execute(CommandContext<FabricClientCommandSource> context) {
|
||||
ClientPlayerEntity player=context.getSource().getPlayer();
|
||||
if(player==null){
|
||||
|
@ -11,6 +11,7 @@ import net.minecraft.client.gui.hud.ChatHudLine;
|
||||
import net.minecraft.text.OrderedText;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
@Mixin(ChatHud.class)
|
||||
public class ChatHudMixin {
|
||||
|
@ -12,6 +12,7 @@ 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.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@ -25,6 +26,7 @@ public class PlayerListHudMixin {
|
||||
private void getPlayerName(PlayerListEntry entry, CallbackInfoReturnable<Text> info){
|
||||
if(Utils.isReady()){
|
||||
Text name=entry.getDisplayName();
|
||||
if(MinecraftClient.getInstance().player==null||name==null) return;
|
||||
if(entry.getProfile().getId().toString().equals(MinecraftClient.getInstance().player.getGameProfile().getId().toString())){
|
||||
info.setReturnValue(Text.literal(name.getString()).setStyle(name.getStyle().withColor(0xff0000)));
|
||||
}
|
||||
@ -35,4 +37,10 @@ public class PlayerListHudMixin {
|
||||
private void onRenderLatencyIcon(DrawContext draw, int width, int x, int y, PlayerListEntry entry, CallbackInfo info){
|
||||
MCEventBus.INSTANCE.post(RenderLatencyIconEvent.get(draw,width,x,y,entry,info));
|
||||
}
|
||||
|
||||
//强制启用Tab列表玩家头像
|
||||
@ModifyVariable(method = "render",at = @At(value = "STORE",ordinal = 0),ordinal = 0)
|
||||
private boolean hackShowPlayerHeadIcon(boolean b1){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
78
src/main/java/com/expvintl/mctools/texthud/MCInfo.java
Normal file
78
src/main/java/com/expvintl/mctools/texthud/MCInfo.java
Normal file
@ -0,0 +1,78 @@
|
||||
package com.expvintl.mctools.texthud;
|
||||
|
||||
import com.expvintl.mctools.utils.DrawUtils;
|
||||
import com.expvintl.mctools.utils.Utils;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class MCInfo {
|
||||
private static String gameDayToRealTimeFormat(long gameDays) {
|
||||
// 游戏 1 小时等于 20 分钟
|
||||
long totalMinutes = gameDays * 20;
|
||||
|
||||
long days = totalMinutes / (60 * 24); // 计算天数
|
||||
long remainingMinutesAfterDays = totalMinutes % (60 * 24);
|
||||
|
||||
long hours = remainingMinutesAfterDays / 60; // 计算小时数
|
||||
long minutes = remainingMinutesAfterDays % 60; // 计算剩余分钟数
|
||||
|
||||
StringBuilder timeString = new StringBuilder();
|
||||
|
||||
if (days > 0) {
|
||||
timeString.append(days).append(" 天");
|
||||
}
|
||||
if (hours > 0) {
|
||||
if (!timeString.isEmpty()) {
|
||||
timeString.append(" ");
|
||||
}
|
||||
timeString.append(hours).append(" 小时");
|
||||
}
|
||||
if (minutes > 0 || timeString.isEmpty()) {
|
||||
if (!timeString.isEmpty()) {
|
||||
timeString.append(" ");
|
||||
}
|
||||
timeString.append(minutes).append(" 分钟");
|
||||
}
|
||||
|
||||
return timeString.toString();
|
||||
}
|
||||
public static void drawHUD(DrawContext drawContext, RenderTickCounter v) {
|
||||
MinecraftClient mc=MinecraftClient.getInstance();
|
||||
//跳过调试
|
||||
if(mc.getDebugHud().shouldShowDebugHud()||mc.options.hudHidden) return;
|
||||
if(mc.world!=null&&mc.player!=null) {
|
||||
DrawUtils.leftTextY =1;
|
||||
int selfPing=0;
|
||||
ClientPlayerEntity p=mc.player;
|
||||
if(mc.getNetworkHandler()!=null&&mc.getNetworkHandler().getPlayerListEntry(mc.player.getGameProfile().getId())!=null) {
|
||||
selfPing=mc.getNetworkHandler().getPlayerListEntry(mc.player.getGameProfile().getId()).getLatency();
|
||||
}
|
||||
Vec3d playerPos=p.getPos();
|
||||
DrawUtils.AddLeftText(drawContext,String.format("%d FPS",mc.getCurrentFps()));
|
||||
DrawUtils.AddLeftText(drawContext,String.format("Ping: %d 毫秒",selfPing));
|
||||
DrawUtils.AddLeftText(drawContext,String.format("亮度:%d",mc.world.getLightLevel(p.getBlockPos())));
|
||||
DrawUtils.AddLeftText(drawContext,String.format("当前维度:%s", Utils.getCurrentDimensionName()));
|
||||
DrawUtils.AddLeftText(drawContext,String.format("当前群系:%s",Utils.getCurrentBiomeName()));
|
||||
if(Utils.getCurrentDimensionName().equals("下界")){
|
||||
DrawUtils.AddLeftText(drawContext,String.format("X:%.2f Y:%.2f Z:%.2f (主世界 X:%.2f Z:%.2f)",playerPos.x,playerPos.y,playerPos.z,playerPos.x*8,playerPos.z*8));
|
||||
}else if(Utils.getCurrentDimensionName().equals("主世界")){
|
||||
DrawUtils.AddLeftText(drawContext,String.format("X:%.2f Y:%.2f Z:%.2f (下界 X:%.2f Z:%.2f)",playerPos.x,playerPos.y,playerPos.z,playerPos.x/8,playerPos.z/8));
|
||||
}else{
|
||||
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("本地难度:%.2f",mc.world.getLocalDifficulty(mc.player.getBlockPos()).getLocalDifficulty()));
|
||||
ItemStack currentItem=p.getInventory().getMainHandStack();
|
||||
if(currentItem!=null&¤tItem.isDamageable()){
|
||||
DrawUtils.AddLeftText(drawContext,String.format("耐久度:%d/%d",currentItem.getMaxDamage()-currentItem.getDamage(),currentItem.getMaxDamage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
41
src/main/java/com/expvintl/mctools/texthud/PotionInfo.java
Normal file
41
src/main/java/com/expvintl/mctools/texthud/PotionInfo.java
Normal file
@ -0,0 +1,41 @@
|
||||
package com.expvintl.mctools.texthud;
|
||||
|
||||
import com.expvintl.mctools.utils.DrawUtils;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
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;
|
||||
|
||||
public class PotionInfo {
|
||||
public static void drawHUD(DrawContext drawContext, RenderTickCounter v) {
|
||||
MinecraftClient mc=MinecraftClient.getInstance();
|
||||
//跳过调试
|
||||
if(mc.getDebugHud().shouldShowDebugHud()||mc.options.hudHidden) return;
|
||||
|
||||
if(mc.world!=null&&mc.player!=null) {
|
||||
DrawUtils.rightBottomY=1;
|
||||
Collection<StatusEffectInstance> effects=mc.player.getStatusEffects();
|
||||
for(StatusEffectInstance instance:effects){
|
||||
DrawUtils.AddRightBottomText(drawContext,String.format("%s%d (%s)", I18n.translate(instance.getTranslationKey()),
|
||||
instance.getAmplifier()+1,
|
||||
instance.isInfinite()?"无限":formatPotionDuration(instance.getDuration())));
|
||||
}
|
||||
}
|
||||
}
|
||||
public static String formatPotionDuration(int ticks) {
|
||||
int totalSeconds = ticks / 20; // 将ticks转换为秒
|
||||
int hours = totalSeconds / 3600; // 1小时 = 3600秒
|
||||
int minutes = (totalSeconds % 3600) / 60; // 获取剩余的分钟
|
||||
int seconds = totalSeconds % 60; // 获取剩余的秒数
|
||||
|
||||
if (hours > 0) {
|
||||
return String.format("%d:%02d:%02d", hours, minutes, seconds);
|
||||
} else {
|
||||
return String.format("%02d:%02d", minutes, seconds);
|
||||
}
|
||||
}
|
||||
}
|
26
src/main/java/com/expvintl/mctools/utils/DrawUtils.java
Normal file
26
src/main/java/com/expvintl/mctools/utils/DrawUtils.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.expvintl.mctools.utils;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.util.Colors;
|
||||
|
||||
public class DrawUtils {
|
||||
public static int leftTextY=1;
|
||||
public static int rightTextY=1;
|
||||
public static int rightBottomY=1;
|
||||
public static void AddLeftText(DrawContext drawContext, String text){
|
||||
MinecraftClient mc=MinecraftClient.getInstance();
|
||||
drawContext.drawText(mc.textRenderer,text,0,leftTextY, Colors.WHITE,false);
|
||||
leftTextY+=10;
|
||||
}
|
||||
public static void AddRightText(DrawContext drawContext, String text){
|
||||
MinecraftClient mc=MinecraftClient.getInstance();
|
||||
drawContext.drawText(mc.textRenderer,text,drawContext.getScaledWindowWidth()-2-mc.textRenderer.getWidth(text),rightTextY, Colors.WHITE,false);
|
||||
rightTextY+=10;
|
||||
}
|
||||
public static void AddRightBottomText(DrawContext drawContext, String text){
|
||||
MinecraftClient mc=MinecraftClient.getInstance();
|
||||
drawContext.drawText(mc.textRenderer,text,drawContext.getScaledWindowWidth()-2-mc.textRenderer.getWidth(text),drawContext.getScaledWindowHeight()-10-rightBottomY, Colors.WHITE,false);
|
||||
rightBottomY+=10;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user