Skip to content

Commit

Permalink
add SEND_LOOKING_AT_BLOCK_POS
Browse files Browse the repository at this point in the history
  • Loading branch information
plusls committed Sep 11, 2021
1 parent a0fc6b6 commit d71c056
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 25 additions & 1 deletion src/main/java/com/plusls/ommc/config/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -42,22 +48,24 @@ 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<IConfigBase> 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
);

public static final ImmutableList<ConfigHotkey> HOTKEYS = ImmutableList.of(
OPEN_CONFIG_GUI,
CLEAR_WAYPOINT,
SEND_LOOKING_AT_BLOCK_POS,
SORT_INVENTORY
);

Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/ommc/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/ommc/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "整理仓库时支持空潜影盒堆叠",
Expand Down

0 comments on commit d71c056

Please sign in to comment.