Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ Allows you to quickly copy your in-game coordinates to send to your friends!
When in-game, press the `Copy Coordinates` key (<code>`</code> by default) and the coordinates will be copied to your keyboard.

## Config
```json5
{
// The format of the string that gets copied. Use $x, $y and $z as placeholders.
"format": "Coordinates: $x, $y, $z"
}
```yaml
format=$x, $y, $z
```
7 changes: 1 addition & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -11,7 +11,6 @@ version = project.mod_version
group = project.maven_group

repositories {
maven { url "https://maven.shedaniel.me/" }
}

dependencies {
Expand All @@ -22,10 +21,6 @@ dependencies {

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
}

processResources {
Expand Down
9 changes: 4 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.1
loader_version=0.14.8
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.14.21

# Mod Properties
mod_version = 1.0.0
maven_group = io.github.simplexdev
archives_base_name = quickcoordscopy

# Dependencies
fabric_version=0.58.6+1.19.2
cloth_config_version=8.0.75
fabric_version=0.86.0+1.20.1
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
40 changes: 27 additions & 13 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
package io.github.simplexdev.quickcoordscopy;

import io.github.simplexdev.quickcoordscopy.config.QuickCoordsCopyConfig;
import me.shedaniel.autoconfig.AutoConfig;
import org.lwjgl.glfw.GLFW;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.Text;
import org.lwjgl.glfw.GLFW;

public class QuickCoordsCopyClient implements ClientModInitializer {
final String DEFAULT_COORDS_FORMAT = "$x, $y, $z";
final String COORDS_FORMAT_KEY = "formatting";
final String DEFAULT_CONFIG = COORDS_FORMAT_KEY + "=" + DEFAULT_COORDS_FORMAT;

QuickCoordsCopyConfig config = AutoConfig.getConfigHolder(QuickCoordsCopyConfig.class).getConfig();
SimpleConfig config = SimpleConfig
.of("quickcoordscopy")
.provider((namespace) -> DEFAULT_CONFIG)
.request();

private static final KeyBinding copyCoordsKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.quickcoordscopy.copy",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_GRAVE_ACCENT,
"category.quickcoordscopy.main"
));
private static final KeyBinding copyCoordsKey = KeyBindingHelper
.registerKeyBinding(
new KeyBinding(
"key.quickcoordscopy.copy",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_GRAVE_ACCENT,
"category.quickcoordscopy.main"));

@Override
public void onInitializeClient() {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (copyCoordsKey.wasPressed()) {
if (client.player != null) {
var coords = config.format;
coords = coords.replace("$x", String.valueOf(Math.round(client.player.getX())));
coords = coords.replace("$y", String.valueOf(Math.round(client.player.getY())));
coords = coords.replace("$z", String.valueOf(Math.round(client.player.getZ())));
final var format = config.getOrDefault(COORDS_FORMAT_KEY, DEFAULT_COORDS_FORMAT);

final var coords = format
.replace("$x", String.valueOf(Math.round(client.player.getX())))
.replace("$y", String.valueOf(Math.round(client.player.getY())))
.replace("$z", String.valueOf(Math.round(client.player.getZ())));

client.keyboard.setClipboard(coords);
client.player.sendMessage(Text.literal("Copied coordinates to keyboard!"));
}
Expand Down
Loading