Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8bc766d
[IntelligenceModding/Advanced-Peripherals-Features#59] Keyboard item …
SirEndii Sep 23, 2024
6695fda
Remove custom indentation
SirEndii Sep 23, 2024
027787b
Binding/Unbinding for the keyboard
SirEndii Sep 23, 2024
19f4de9
Use translatable components and add name and description for the keyb…
SirEndii Sep 23, 2024
c507f0a
Removed owner tag from the memory card
SirEndii Sep 23, 2024
ab6a8cd
Key press/Char typed sync to the computer logic
SirEndii Sep 24, 2024
5af40a8
The keyboard is now a working module, it currently uses the hotkey mo…
SirEndii Sep 25, 2024
b94b8be
Mouse events for the keyboard module
SirEndii Sep 26, 2024
9ba1214
Fixed an issue where the keyboard does not bound to the glasses when …
SirEndii Sep 26, 2024
e8f70d7
Render a little info text when the player is using the keyboard
SirEndii Sep 28, 2024
1b147a3
Preven JEI/REI/EMI from rendering in the keyboard screen
SirEndii Sep 30, 2024
48ce6e5
Merge branch 'dev/0.8' into feat/keyboard
SirEndii Jan 16, 2025
b689497
checkstyle
SirEndii Jan 16, 2025
36193be
Simplify KeyboardScreen
SirEndii Jan 16, 2025
5e439b9
Sort ClientRegistry.java
SirEndii Jan 17, 2025
a7c5984
Merge branch 'dev/0.8' into feat/keyboard
SirEndii Jan 17, 2025
f5efd86
Add language entries
SirEndii Jan 17, 2025
25cb800
Merge branch 'dev/0.8' of https://github.com/IntelligenceModding/Adva…
zyxkad Mar 15, 2025
256cf0e
make keyboard based on computer ID instead of position
zyxkad Mar 15, 2025
5251139
run runData
zyxkad Mar 15, 2025
3549dd9
implement keyboard mouse capture mode
zyxkad Mar 15, 2025
d6dd79b
fix styles
zyxkad Mar 15, 2025
21e7aeb
Merge pull request #719 from zyxkad/player-rotate-handle-feature
SirEndii Mar 19, 2025
58a92cd
make lock final
zyxkad Mar 19, 2025
cf93b69
fix keyboard does not work in multiplayer
zyxkad Jun 19, 2025
0e90294
fix keyboard_close fires with delay
zyxkad Jun 19, 2025
b471dd3
remove unused import
zyxkad Jun 19, 2025
4978a6b
Merge pull request #751 from zyxkad/feat/keyboard
SirEndii Sep 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,12 @@ dependencies {
compileOnly fg.deobf("com.ldtteam:domum_ornamentum:${domumornamentum_version}:universal")
compileOnly fg.deobf("com.ldtteam:blockui:${blockui_version}")
// IMPORTANT. This should be removed/commented when running `runData`
runtimeOnly fg.deobf("com.ldtteam:minecolonies:${minecolonies_version}")
/*runtimeOnly fg.deobf("com.ldtteam:minecolonies:${minecolonies_version}")
runtimeOnly fg.deobf("com.ldtteam:structurize:${structurize_version}")
runtimeOnly fg.deobf("com.ldtteam:multipiston:${multipiston_version}")
runtimeOnly fg.deobf("com.ldtteam:domum_ornamentum:${domumornamentum_version}:universal")
runtimeOnly fg.deobf("com.ldtteam:blockui:${blockui_version}")
*/

// Patchouli
compileOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// 1.19.2 2024-05-28T14:53:16.656615 LootTables
d865e8ac35302c486faf5c7122569c554186186d data/advancedperipherals/loot_tables/blocks/block_reader.json
a6f896cc3dbd8da12737825ec71e32970f54025c data/advancedperipherals/loot_tables/blocks/chat_box.json
f50f506ae1987537f76be4c05a81689b25798f91 data/advancedperipherals/loot_tables/blocks/colony_integrator.json
4dcad851450e4ddd8d28a0017a417bf6e5579bda data/advancedperipherals/loot_tables/blocks/distance_detector.json
1d1b858d09538dc66bab2c33a2f9c58361a9c472 data/advancedperipherals/loot_tables/blocks/energy_detector.json
317004b1358ef9bf83957d2d6796529a226161c7 data/advancedperipherals/loot_tables/blocks/environment_detector.json
df6186990887f77b7db37ebb8ee50a7e7f096b0a data/advancedperipherals/loot_tables/blocks/fluid_detector.json
cea5a036d4ccdcc6ef026d1a226b5e13f1060676 data/advancedperipherals/loot_tables/blocks/gas_detector.json
d5a3964f518b138cbd7305c819a36af3d9340e4a data/advancedperipherals/loot_tables/blocks/geo_scanner.json
8aa1deea908fd02f049e047c8ca16679bbef68a2 data/advancedperipherals/loot_tables/blocks/inventory_manager.json
9a2898a63e2e0c087ce8eba211c63d1c8b9fd4aa data/advancedperipherals/loot_tables/blocks/me_bridge.json
973770040bacb61482adb9739fd1d977f16c107f data/advancedperipherals/loot_tables/blocks/nbt_storage.json
b4b80e8c9d62b53d9252cdfc5918c077d3a01f6e data/advancedperipherals/loot_tables/blocks/peripheral_casing.json
58b6adbea5d4ae43ed9af0b627df2b8a4907acde data/advancedperipherals/loot_tables/blocks/player_detector.json
a58aebcc52684302968e7af4f50a12aff93aaf2d data/advancedperipherals/loot_tables/blocks/redstone_integrator.json
0ef1678f88b8fcb744bfd95261f66745340be8f4 data/advancedperipherals/loot_tables/blocks/rs_bridge.json
// 1.19.2 2024-09-23T21:28:44.4809605 LootTables
618b63c020ab64890c8a2d2506dd61cd30259a44 data/advancedperipherals/loot_tables/blocks/block_reader.json
0923665563d05307a7fa7d711a2d7a994a31eb6e data/advancedperipherals/loot_tables/blocks/chat_box.json
bf2a80256cfba0bd8c0283d493882e5816882f1f data/advancedperipherals/loot_tables/blocks/colony_integrator.json
cff4b81aa381bc0d1172b0a4c8bb35c1b954a018 data/advancedperipherals/loot_tables/blocks/distance_detector.json
1c5dbe1a8e07e040a3c2893a002cd535ee41dc20 data/advancedperipherals/loot_tables/blocks/energy_detector.json
8cc03eca1d191f725bc558836f26a85a466cb127 data/advancedperipherals/loot_tables/blocks/environment_detector.json
12589e7642b383029457d97a64637494ea8507a3 data/advancedperipherals/loot_tables/blocks/fluid_detector.json
421a3ece56485bd46374844639bfd606ce4665ec data/advancedperipherals/loot_tables/blocks/gas_detector.json
a2ae352dce564b878daecf47026f268dd432fbcf data/advancedperipherals/loot_tables/blocks/geo_scanner.json
807d449d02c0af701f84d3e806ebac20d3a1f91c data/advancedperipherals/loot_tables/blocks/inventory_manager.json
bb9b442dfad1d5f31397585c8394c85243fa169a data/advancedperipherals/loot_tables/blocks/me_bridge.json
52b1fe2e265be456ebf48d7e0d9ebcc8c994176f data/advancedperipherals/loot_tables/blocks/nbt_storage.json
2651e6053857a31f5bccc360969924848a197ad5 data/advancedperipherals/loot_tables/blocks/peripheral_casing.json
6b5058b6bc49689bf2b858b89f3981a4bb681750 data/advancedperipherals/loot_tables/blocks/player_detector.json
6af6542c7b64aa22dbfcdb01299daf4911827a49 data/advancedperipherals/loot_tables/blocks/redstone_integrator.json
b221c6a82da0875264a112b54f847ac6a1f36797 data/advancedperipherals/loot_tables/blocks/rs_bridge.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.19.2 2024-05-28T14:53:16.658014 Languages: en_us
2580077212426421e05822910bde2edff88e2346 assets/advancedperipherals/lang/en_us.json
// 1.19.2 2024-09-25T15:15:12.3008086 Languages: en_us
c5dde7701295d5ad506663dba947865df73d753c assets/advancedperipherals/lang/en_us.json
15 changes: 11 additions & 4 deletions src/generated/resources/assets/advancedperipherals/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"item.advancedperipherals.end_automata_core": "End Automata Core",
"item.advancedperipherals.hotkey_module": "Hotkey Module",
"item.advancedperipherals.husbandry_automata_core": "Husbandry Automata Core",
"item.advancedperipherals.keyboard": "Keyboard",
"item.advancedperipherals.memory_card": "Memory Card",
"item.advancedperipherals.nightvision_module": "Night Vision Module",
"item.advancedperipherals.overlay_module": "Overlay Module",
Expand All @@ -48,6 +49,8 @@
"item.advancedperipherals.smart_glasses": "Smart Glasses",
"item.advancedperipherals.smart_glasses_interface": "Smart Glasses Interface",
"item.advancedperipherals.smart_glasses_netherite": "Netherite reinforced Smart Glasses",
"item.advancedperipherals.tooltip.binding.bound_to": "&7Bound to &b%s&7.",
"item.advancedperipherals.tooltip.binding.bound_to_glasses": "&7Bound to Smart Glasses with Id &b%s&7.",
"item.advancedperipherals.tooltip.block_reader": "&7Reads nbt data of blocks to interact with blocks which do not have computer support.",
"item.advancedperipherals.tooltip.chat_box": "&7Interacts with the ingame chat, can read and write messages.",
"item.advancedperipherals.tooltip.chunk_controller": "&7A crafting ingredient for the Chunky Turtle.",
Expand All @@ -60,14 +63,14 @@
"item.advancedperipherals.tooltip.geo_scanner": "&7Scans the area around it to find some shiny ores.",
"item.advancedperipherals.tooltip.husbandry_automata_core": "&7Upgrade for turtles, that allows basic and advanced interactions with animals.",
"item.advancedperipherals.tooltip.inventory_manager": "&7This block is able to send or receive specific items from a player inventory.",
"item.advancedperipherals.tooltip.keyboard": "&7Can be bound to a computer, used to type something on a computer without the need to open the computer.",
"item.advancedperipherals.tooltip.me_bridge": "&7The ME Bridge interacts with Applied Energistics to manage your items.",
"item.advancedperipherals.tooltip.memory_card": "&7Can save the rights of a player to use it in an inventory manager.",
"item.advancedperipherals.tooltip.memory_card.bound": "&7Bound to &b%s&7.",
"item.advancedperipherals.tooltip.nbt_storage": "&7Acts like a storage disk. Can store nbt based data.",
"item.advancedperipherals.tooltip.overpowered_end_automata_core": "&7Improved version of the end automata core, that provides some overpowered uses! Be careful, the upgrade is very fragile.",
"item.advancedperipherals.tooltip.overpowered_husbandry_automata_core": "&7Improved version of the husbandry automata core, that provides some overpowered uses! Be careful, the upgrade is very fragile.",
"item.advancedperipherals.tooltip.overpowered_weak_automata_core": "&7Improved version of the weak automata core, that provides some overpowered uses! Be careful, the upgrade is very fragile.",
"item.advancedperipherals.tooltip.peripheral_casing": "&7An empty hull without the love it deserves. Used as crafting ingredient",
"item.advancedperipherals.tooltip.peripheral_casing": "&7An empty hull without the love it deserves. Used as crafting ingredient.",
"item.advancedperipherals.tooltip.player_detector": "&7This peripheral can be used to interact with players, but don't be a stalker.",
"item.advancedperipherals.tooltip.redstone_integrator": "&7This block is able to interact with redstone. Works exactly like the redstone api of an computer.",
"item.advancedperipherals.tooltip.rs_bridge": "&7The RS Bridge interacts with Refined Storage to manage your items.",
Expand All @@ -82,9 +85,13 @@
"pocket.advancedperipherals.environment_pocket": "Environment",
"pocket.advancedperipherals.geoscanner_pocket": "Geo",
"pocket.advancedperipherals.player_pocket": "Player Detector",
"text.advancedperipherals.added_player": "Added you to the memory card",
"text.advancedperipherals.automata_core_feed_by_player": "You're trying to feed an entity to a soul, but your own body refuses to do this. Maybe something more mechanical can do this?",
"text.advancedperipherals.removed_player": "Cleared the memory card",
"text.advancedperipherals.bind_keyboard": "&7Bound to &b%s&7",
"text.advancedperipherals.bind_memorycard": "&7Added you to the memory card",
"text.advancedperipherals.cleared_keyboard": "&7Bind removed",
"text.advancedperipherals.cleared_memorycard": "&7Cleared the memory card",
"text.advancedperipherals.could_not_bind_keyboard": "&cCould not bind the keyboard to the computer located at &c%s",
"text.advancedperipherals.keyboard_notbound": "&7Keyboard not bound",
"text.advancedperipherals.saddle_turtle_dismount_hint": "Controlling %1$s. Press %2$s and %3$s to dismount.",
"text.advancedperipherals.smart_glasses.modules": "Modules",
"text.advancedperipherals.smart_glasses.peripherals": "Peripherals",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "advancedperipherals:distance_detector"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "advancedperipherals:fluid_detector"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "advancedperipherals:gas_detector"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import de.srendi.advancedperipherals.AdvancedPeripherals;
import de.srendi.advancedperipherals.client.renderer.DistanceDetectorRenderer;
import de.srendi.advancedperipherals.client.screens.InventoryManagerScreen;
import de.srendi.advancedperipherals.client.screens.KeyboardScreen;
import de.srendi.advancedperipherals.client.screens.SaddleTurtleScreen;
import de.srendi.advancedperipherals.client.screens.SmartGlassesScreen;
import de.srendi.advancedperipherals.client.smartglasses.OverlayModuleOverlay;
Expand Down Expand Up @@ -43,6 +44,7 @@ public static void registerModels(ModelEvent.RegisterAdditional event) {
public static void onClientSetup(FMLClientSetupEvent event) {
MenuScreens.register(APContainerTypes.INVENTORY_MANAGER_CONTAINER.get(), InventoryManagerScreen::new);
MenuScreens.register(APContainerTypes.SMART_GLASSES_CONTAINER.get(), SmartGlassesScreen::new);
MenuScreens.register(APContainerTypes.KEYBOARD_CONTAINER.get(), KeyboardScreen::new);

ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.CHUNKY_TURTLE.get(), TurtleUpgradeModeller.flatItem());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.COMPASS_TURTLE.get(), TurtleUpgradeModeller.flatItem());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
package de.srendi.advancedperipherals.client.screens;

import com.mojang.blaze3d.vertex.PoseStack;
import dan200.computercraft.client.gui.ClientInputHandler;
import dan200.computercraft.shared.computer.core.InputHandler;
import de.srendi.advancedperipherals.client.screens.base.BaseScreen;
import de.srendi.advancedperipherals.common.container.KeyboardContainer;
import net.minecraft.SharedConstants;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.glfw.GLFW;

import java.util.BitSet;

/**
* A simple screen but without any rendering calls. Used to unlock the mouse so we can freely write stuff
* <p>
* Char/key logic stolen from CC's WidgetTerminal
*/
public class KeyboardScreen extends BaseScreen<KeyboardContainer> {

protected final InputHandler input;
private final BitSet keysDown = new BitSet(256);

private float terminateTimer = -1;
private float rebootTimer = -1;
private float shutdownTimer = -1;

private int lastMouseButton = -1;
private int lastMouseX = -1;
private int lastMouseY = -1;

public KeyboardScreen(KeyboardContainer screenContainer, Inventory inv, Component titleIn) {
super(screenContainer, inv, titleIn);
input = new ClientInputHandler(menu);
}

@Override
public void render(@NotNull PoseStack poseStack, int x, int y, float partialTicks) {
Minecraft minecraft = Minecraft.getInstance();
float scale = 2f;
int screenWidth = minecraft.getWindow().getGuiScaledWidth();
int screenHeight = minecraft.getWindow().getGuiScaledHeight();
// Make the text a bit smaller on small screens
if (screenWidth <= 1080)
scale = 1f;

poseStack.scale(scale, scale, 1);
String text = "Press ESC to close the Keyboard Screen.";
float textX = (screenWidth / 2f - minecraft.font.width(text) * scale / 2f) / scale;
minecraft.font.drawShadow(poseStack, text, textX, 1, 0xFFFFFF);

// Prevents JEI/REI/EMI from rendering. Maybe not the best way, but it works for now.
poseStack.scale(4f, 4f, 1);
minecraft.font.draw(poseStack, "", screenWidth, screenHeight, 0xFFFFFF);
}

@Override
protected void renderBg(@NotNull PoseStack matrixStack, float partialTicks, int x, int y) {
}

@Override
public void renderBackground(@NotNull PoseStack pPoseStack) {
}

@Override
public boolean charTyped(char ch, int modifiers) {
if (ch >= 32 && ch <= 126 || ch >= 160 && ch <= 255) { // printable chars in byte range
// Queue the "char" event
input.queueEvent("char", new Object[]{Character.toString(ch)});
}

return true;
}

@Override
public boolean keyPressed(int key, int scancode, int modifiers) {
if (key == GLFW.GLFW_KEY_ESCAPE) {
onClose();
return true;
}
if ((modifiers & GLFW.GLFW_MOD_CONTROL) != 0) {
switch (key) {
case GLFW.GLFW_KEY_T:
if (terminateTimer < 0) terminateTimer = 0;
return true;
case GLFW.GLFW_KEY_S:
if (shutdownTimer < 0) shutdownTimer = 0;
return true;
case GLFW.GLFW_KEY_R:
if (rebootTimer < 0) rebootTimer = 0;
return true;

case GLFW.GLFW_KEY_V:
// Ctrl+V for paste
String clipboard = Minecraft.getInstance().keyboardHandler.getClipboard();
if (clipboard != null) {
// Clip to the first occurrence of \r or \n
int newLineIndex1 = clipboard.indexOf("\r");
int newLineIndex2 = clipboard.indexOf("\n");
if (newLineIndex1 >= 0 && newLineIndex2 >= 0) {
clipboard = clipboard.substring(0, Math.min(newLineIndex1, newLineIndex2));
} else if (newLineIndex1 >= 0) {
clipboard = clipboard.substring(0, newLineIndex1);
} else if (newLineIndex2 >= 0) {
clipboard = clipboard.substring(0, newLineIndex2);
}

// Filter the string
clipboard = SharedConstants.filterText(clipboard);
if (!clipboard.isEmpty()) {
// Clip to 512 characters and queue the event
if (clipboard.length() > 512) clipboard = clipboard.substring(0, 512);
input.queueEvent("paste", new Object[]{clipboard});
}

return true;
}
}
}

if (key >= 0 && terminateTimer < 0 && rebootTimer < 0 && shutdownTimer < 0) {
// Queue the "key" event and add to the down set
boolean repeat = keysDown.get(key);
keysDown.set(key);
input.keyDown(key, repeat);
}

return true;
}

@Override
public boolean keyReleased(int key, int scancode, int modifiers) {
// Queue the "key_up" event and remove from the down set
if (key >= 0 && keysDown.get(key)) {
keysDown.set(key, false);
input.keyUp(key);
}

switch (key) {
case GLFW.GLFW_KEY_T:
terminateTimer = -1;
break;
case GLFW.GLFW_KEY_R:
rebootTimer = -1;
break;
case GLFW.GLFW_KEY_S:
shutdownTimer = -1;
break;
case GLFW.GLFW_KEY_LEFT_CONTROL:
case GLFW.GLFW_KEY_RIGHT_CONTROL:
terminateTimer = rebootTimer = shutdownTimer = -1;
break;
}

return true;
}

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
input.mouseClick(button + 1, (int) mouseX, (int) mouseY);

lastMouseButton = button;
lastMouseX = (int) mouseX;
lastMouseY = (int) mouseY;

return true;
}

@Override
public boolean mouseReleased(double mouseX, double mouseY, int button) {
if (lastMouseButton == button) {
input.mouseUp(lastMouseButton + 1, (int) mouseX, (int) mouseY);
lastMouseButton = -1;
}

return false;
}

@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double v2, double v3) {
if (button == lastMouseButton && (mouseX != lastMouseX || mouseY != lastMouseY)) {
input.mouseDrag(button + 1, (int) mouseX, (int) mouseY);
lastMouseX = (int) mouseX;
lastMouseY = (int) mouseY;
}

return false;
}

@Override
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
input.mouseScroll(delta < 0 ? 1 : -1, (int) mouseX, (int) mouseY);

lastMouseX = (int) mouseX;
lastMouseY = (int) mouseY;

return true;
}

@Override
public int getSizeX() {
return 256;
}

@Override
public int getSizeY() {
return 256;
}

@Override
public ResourceLocation getTexture() {
return null;
}
}
Loading
Loading