diff --git a/gradle.properties b/gradle.properties index 00ad1dd..2381602 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.17.1 yarn_mappings=1.17.1+build.10 loader_version=0.11.6 # Mod Properties -mod_version=0.3.7-alpha.114514 +mod_version=0.3.8-alpha.114514 maven_group=com.plusls archives_base_name=oh-my-minecraft-client # Dependencies diff --git a/src/main/java/com/plusls/ommc/config/Configs.java b/src/main/java/com/plusls/ommc/config/Configs.java index 8297403..5d19d4b 100644 --- a/src/main/java/com/plusls/ommc/config/Configs.java +++ b/src/main/java/com/plusls/ommc/config/Configs.java @@ -17,8 +17,14 @@ import fi.dy.masa.malilib.util.FileUtils; import fi.dy.masa.malilib.util.JsonUtils; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerInteractionManager; import net.minecraft.client.sound.PositionedSoundInstance; +import net.minecraft.entity.Entity; import net.minecraft.sound.SoundEvents; +import net.minecraft.text.LiteralText; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.hit.HitResult; +import net.minecraft.util.math.BlockPos; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.core.config.Configurator; @@ -42,15 +48,16 @@ public static class Generic { public static final ConfigBoolean DONT_CLEAR_CHAT_HISTORY = new TranslatableConfigBoolean(PREFIX, "dontClearChatHistory", false); public static final ConfigHotkey CLEAR_WAYPOINT = new TranslatableConfigHotkey(PREFIX, "clearWaypoint", "C"); public static final ConfigBoolean FORCE_PARSE_WAYPOINT_FROM_CHAT = new TranslatableConfigBoolean(PREFIX, "forceParseWaypointFromChat", false); + public static final ConfigHotkey SEND_LOOKING_AT_BLOCK_POS = new TranslatableConfigHotkey(PREFIX, "sendLookingAtBlockPos", "O,P"); public static final ConfigHotkey SORT_INVENTORY = new TranslatableConfigHotkey(PREFIX, "sortInventory", "R", KeybindSettings.GUI); public static final ConfigBoolean SORT_INVENTORY_SUPPORT_EMPTY_SHULKER_BOX_STACK = new TranslatableConfigBoolean(PREFIX, "sortInventorySupportEmptyShulkerBoxStack", false); - public static final ImmutableList OPTIONS = ImmutableList.of( OPEN_CONFIG_GUI, DEBUG, DONT_CLEAR_CHAT_HISTORY, CLEAR_WAYPOINT, FORCE_PARSE_WAYPOINT_FROM_CHAT, + SEND_LOOKING_AT_BLOCK_POS, SORT_INVENTORY, SORT_INVENTORY_SUPPORT_EMPTY_SHULKER_BOX_STACK ); @@ -58,6 +65,7 @@ public static class Generic { public static final ImmutableList HOTKEYS = ImmutableList.of( OPEN_CONFIG_GUI, CLEAR_WAYPOINT, + SEND_LOOKING_AT_BLOCK_POS, SORT_INVENTORY ); @@ -67,6 +75,22 @@ public static class Generic { GuiBase.openGui(new GuiConfigs()); return true; }); + SEND_LOOKING_AT_BLOCK_POS.getKeybind().setCallback((keyAction, iKeybind) -> { + MinecraftClient client = MinecraftClient.getInstance(); + Entity cameraEntity = client.getCameraEntity(); + ClientPlayerInteractionManager clientPlayerInteractionManager = client.interactionManager; + if (cameraEntity != null && clientPlayerInteractionManager != null) { + HitResult hitresult = cameraEntity.raycast(clientPlayerInteractionManager.getReachDistance(), client.getTickDelta(), false); + if (hitresult.getType() == HitResult.Type.BLOCK) { + BlockPos lookPos = ((BlockHitResult) hitresult).getBlockPos(); + if (client.player != null) { + client.player.sendChatMessage(String.format("[%d, %d, %d]", lookPos.getX(), lookPos.getY(), lookPos.getZ())); + } + } + } + return true; + }); + CLEAR_WAYPOINT.getKeybind().setCallback((keyAction, iKeybind) -> { HighlightWaypointUtil.highlightPos = null; HighlightWaypointUtil.lastBeamTime = 0; diff --git a/src/main/resources/assets/ommc/lang/en_us.json b/src/main/resources/assets/ommc/lang/en_us.json index 3600641..70b8734 100644 --- a/src/main/resources/assets/ommc/lang/en_us.json +++ b/src/main/resources/assets/ommc/lang/en_us.json @@ -15,6 +15,8 @@ "ommc.config.generic.clearWaypoint.comment": "A hotkey to clear highlight waypoint.", "ommc.config.generic.forceParseWaypointFromChat.name": "forceParseWaypointFromChat", "ommc.config.generic.forceParseWaypointFromChat.comment": "Force parse waypoint from chat (such it will override the clickevent of rtext).", + "ommc.config.generic.sendLookingAtBlockPos.name": "sendLookingAtPos", + "ommc.config.generic.sendLookingAtBlockPos.comment": "A hotkey to send looking at pos.", "ommc.config.generic.sortInventory.name": "sortInventory", "ommc.config.generic.sortInventory.comment": "A hotkey to sort inventory.", "ommc.config.generic.sortInventorySupportEmptyShulkerBoxStack.name": "sortInventorySupportEmptyShulkerBoxStack", diff --git a/src/main/resources/assets/ommc/lang/zh_cn.json b/src/main/resources/assets/ommc/lang/zh_cn.json index f518951..52ad002 100644 --- a/src/main/resources/assets/ommc/lang/zh_cn.json +++ b/src/main/resources/assets/ommc/lang/zh_cn.json @@ -15,6 +15,8 @@ "ommc.config.generic.clearWaypoint.comment": "取消高亮坐标点的快捷键", "ommc.config.generic.forceParseWaypointFromChat.name": "强制从聊天中解析路径点", "ommc.config.generic.forceParseWaypointFromChat.comment": "强制从聊天中解析路径点,就算该信息中存在 click event 也会将其覆盖", + "ommc.config.generic.sendLookingAtBlockPos.name": "发送当前注视的方块的坐标", + "ommc.config.generic.sendLookingAtBlockPos.comment": "发送当前注视的方块的坐标", "ommc.config.generic.sortInventory.name": "整理仓库", "ommc.config.generic.sortInventory.comment": "整理仓库的快捷键", "ommc.config.generic.sortInventorySupportEmptyShulkerBoxStack.name": "整理仓库时支持空潜影盒堆叠",