Compare commits
15 Commits
v0.1.2-1.2
...
v0.1.3
Author | SHA1 | Date | |
---|---|---|---|
4ea309bbe9 | |||
f186c66ad7 | |||
f88b167931 | |||
45c65560f1 | |||
83d42630d8 | |||
62bccc2452 | |||
92f9a82ee5 | |||
![]() |
17aa218b6c | ||
![]() |
7114e853b8 | ||
![]() |
4d6dbc594d | ||
![]() |
d79f9b4edc | ||
![]() |
064f65d50d | ||
![]() |
cffea2e19e | ||
![]() |
643014f9ac | ||
![]() |
687d5fd29e |
38
.gitea/workflows/gradle.yml
Normal file
38
.gitea/workflows/gradle.yml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
name: Java CI with Gradle
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["master"]
|
||||||
|
pull_request:
|
||||||
|
branches: ["master"]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: archlinux-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Install prerequisite packages
|
||||||
|
run: pacman -Syu --noconfirm && pacman -S --noconfirm git nodejs
|
||||||
|
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up JDK 21
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: "21"
|
||||||
|
distribution: "temurin"
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@v4
|
||||||
|
|
||||||
|
- name: Build with Gradle Wrapper
|
||||||
|
run: ./gradlew build
|
||||||
|
|
||||||
|
- name: Upload build artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: JARs
|
||||||
|
path: build/libs
|
||||||
|
retention-days: 30
|
||||||
|
compression-level: 9
|
11
README.md
11
README.md
@@ -1,11 +1,18 @@
|
|||||||
## HotbarReplace
|
## HotbarReplace
|
||||||
|
|
||||||
|
[](https://git.2khz.xyz/adam/HotbarReplace/actions/workflows/gradle.yml)
|
||||||
|
|
||||||
HotbarReplace is a Minecraft mod for the Fabric modding framework which replaces blocks in your hotbar with blocks of the same type from your inventory upon running out while placing, see demo GIF below to see how it works!
|
HotbarReplace is a Minecraft mod for the Fabric modding framework which replaces blocks in your hotbar with blocks of the same type from your inventory upon running out while placing, see demo GIF below to see how it works!
|
||||||
|
|
||||||
### Known issues/Improvements
|
### Known issues/Improvements
|
||||||
|
|
||||||
* Make the mod more resilient to network delay and packet loss (don't hardcode a 50 ms delay)
|
* [You tell me!](https://git.2khz.xyz/adam/HotbarReplace/issues) I'd like to see this mod be as simple & bug-free as possible!
|
||||||
|
|
||||||
### Demo GIF
|
### Where to find it?
|
||||||
|
|
||||||
|
- Here! On GitHub you can grab whichever release you like from the sidebar on the right-hand side.
|
||||||
|
- Otherwise, also on [Modrinth](https://modrinth.com/mod/hotbarreplace).
|
||||||
|
|
||||||
|
#### Demo GIF
|
||||||
|
|
||||||

|

|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '1.7-SNAPSHOT'
|
id 'fabric-loom' version '1.10-SNAPSHOT'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,8 +19,8 @@ loom {
|
|||||||
|
|
||||||
mods {
|
mods {
|
||||||
"hotbarreplace" {
|
"hotbarreplace" {
|
||||||
sourceSet sourceSets.main
|
// sourceSet sourceSets.main
|
||||||
// sourceSet sourceSets.client
|
sourceSet sourceSets.client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
minecraft_version=1.21
|
minecraft_version=1.21.5
|
||||||
yarn_mappings=1.21+build.9
|
yarn_mappings=1.21.5+build.1
|
||||||
loader_version=0.15.11
|
loader_version=0.16.13
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 0.1.2
|
mod_version = 0.1.3
|
||||||
maven_group = xyz.twokilohertz
|
maven_group = xyz.twokilohertz
|
||||||
archives_base_name = HotbarReplace
|
archives_base_name = HotbarReplace
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
fabric_version=0.100.7+1.21
|
fabric_version=0.121.0+1.21.5
|
||||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
5
gradlew
vendored
5
gradlew
vendored
@@ -86,8 +86,7 @@ done
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
' "$PWD" ) || exit
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@@ -206,7 +205,7 @@ fi
|
|||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
# Collect all arguments for the java command:
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
# and any embedded shellness will be escaped.
|
# and any embedded shellness will be escaped.
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
# treated as '${Hostname}' itself on the command line.
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
@@ -22,7 +22,7 @@ public class HotbarReplace implements ClientModInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
LOGGER.info("HotbarReplace v0.1.2 initialised");
|
LOGGER.info("HotbarReplace v0.1.3 initialised");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void tryReplaceSlot(ItemPlacementContext context, Item item) {
|
public static void tryReplaceSlot(ItemPlacementContext context, Item item) {
|
||||||
@@ -53,20 +53,21 @@ public class HotbarReplace implements ClientModInitializer {
|
|||||||
if (player.currentScreenHandler.slots.get(i).getStack().isOf(item)) {
|
if (player.currentScreenHandler.slots.get(i).getStack().isOf(item)) {
|
||||||
// Simulate moving the stack from one slot to another
|
// Simulate moving the stack from one slot to another
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
|
// TODO: This still feels like a bit of a hack
|
||||||
|
// I honestly do not know Minecraft internals enough to be sure that there won't
|
||||||
|
// be de-sync issues.
|
||||||
|
|
||||||
|
int current_fps = client.getCurrentFps();
|
||||||
|
int click_delay = Math.round(1.0f / (float) current_fps) * 1000;
|
||||||
|
|
||||||
client.interactionManager.clickSlot(player.currentScreenHandler.syncId, i, GLFW.GLFW_MOUSE_BUTTON_1,
|
client.interactionManager.clickSlot(player.currentScreenHandler.syncId, i, GLFW.GLFW_MOUSE_BUTTON_1,
|
||||||
SlotActionType.PICKUP, player);
|
SlotActionType.PICKUP, player);
|
||||||
|
|
||||||
/*
|
|
||||||
* Wait 50 milliseconds (on another thread) before attempting to move the new
|
|
||||||
* stack
|
|
||||||
* PlayerInventory.MAIN_SIZE added to the selected slot (hotbar slot) is the
|
|
||||||
* correct slot ID
|
|
||||||
*/
|
|
||||||
scheduler.schedule(() -> {
|
scheduler.schedule(() -> {
|
||||||
client.interactionManager.clickSlot(player.currentScreenHandler.syncId,
|
client.interactionManager.clickSlot(player.currentScreenHandler.syncId,
|
||||||
inventory.selectedSlot + PlayerInventory.MAIN_SIZE, GLFW.GLFW_MOUSE_BUTTON_1,
|
inventory.getSelectedSlot() + PlayerInventory.MAIN_SIZE, GLFW.GLFW_MOUSE_BUTTON_1,
|
||||||
SlotActionType.PICKUP, player);
|
SlotActionType.PICKUP, player);
|
||||||
}, 50, TimeUnit.MILLISECONDS);
|
}, click_delay, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@@ -20,7 +20,7 @@ public class BlockItemMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(at = @At("TAIL"), method = "Lnet/minecraft/item/BlockItem;place(Lnet/minecraft/item/ItemPlacementContext;)Lnet/minecraft/util/ActionResult;")
|
@Inject(at = @At("TAIL"), method = "Lnet/minecraft/item/BlockItem;place(Lnet/minecraft/item/ItemPlacementContext;)Lnet/minecraft/util/ActionResult;")
|
||||||
private void mixin_BlockItem_place_tail(ItemPlacementContext context, CallbackInfoReturnable<ActionResult> info) {
|
private void BlockItem_place_tail(ItemPlacementContext context, CallbackInfoReturnable<ActionResult> info) {
|
||||||
// Early return if the block place action would fail
|
// Early return if the block place action would fail
|
||||||
if (info.getReturnValue() != ActionResult.SUCCESS)
|
if (info.getReturnValue() != ActionResult.SUCCESS)
|
||||||
return;
|
return;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"id": "hotbarreplace",
|
"id": "hotbarreplace",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"name": "HotbarReplace",
|
"name": "HotbarReplace",
|
||||||
"description": "Replace blocks in your hotbar when you run out with blocks from your inventory",
|
"description": "Replace blocks in your hotbar when you run out with blocks from your inventory",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
Reference in New Issue
Block a user