3 Commits

Author SHA1 Message Date
Adam Macdonald
cffea2e19e Release 0.1.3 2024-07-21 18:01:55 +01:00
Adam Macdonald
643014f9ac Specify correct sources in build.gradle 2024-07-21 15:35:54 +01:00
Adam Macdonald
687d5fd29e Change move-items-between-slots delay
This is still a bit of (very much) a hack.
2024-07-21 14:22:57 +01:00
4 changed files with 13 additions and 12 deletions

View File

@@ -19,8 +19,8 @@ loom {
mods {
"hotbarreplace" {
sourceSet sourceSets.main
// sourceSet sourceSets.client
// sourceSet sourceSets.main
sourceSet sourceSets.client
}
}

View File

@@ -8,7 +8,7 @@ yarn_mappings=1.21+build.9
loader_version=0.15.11
# Mod Properties
mod_version = 0.1.2
mod_version = 0.1.3
maven_group = xyz.twokilohertz
archives_base_name = HotbarReplace

View File

@@ -22,7 +22,7 @@ public class HotbarReplace implements ClientModInitializer {
@Override
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) {
@@ -53,20 +53,21 @@ public class HotbarReplace implements ClientModInitializer {
if (player.currentScreenHandler.slots.get(i).getStack().isOf(item)) {
// Simulate moving the stack from one slot to another
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,
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(() -> {
client.interactionManager.clickSlot(player.currentScreenHandler.syncId,
inventory.selectedSlot + PlayerInventory.MAIN_SIZE, GLFW.GLFW_MOUSE_BUTTON_1,
SlotActionType.PICKUP, player);
}, 50, TimeUnit.MILLISECONDS);
}, click_delay, TimeUnit.MILLISECONDS);
}
return;

View File

@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "hotbarreplace",
"version": "0.1.2",
"version": "0.1.3",
"name": "HotbarReplace",
"description": "Replace blocks in your hotbar when you run out with blocks from your inventory",
"authors": [