Compare commits
3 Commits
v0.1.2-1.2
...
v0.1.3-1.2
Author | SHA1 | Date | |
---|---|---|---|
![]() |
cffea2e19e | ||
![]() |
643014f9ac | ||
![]() |
687d5fd29e |
@@ -19,8 +19,8 @@ loom {
|
|||||||
|
|
||||||
mods {
|
mods {
|
||||||
"hotbarreplace" {
|
"hotbarreplace" {
|
||||||
sourceSet sourceSets.main
|
// sourceSet sourceSets.main
|
||||||
// sourceSet sourceSets.client
|
sourceSet sourceSets.client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,7 +8,7 @@ yarn_mappings=1.21+build.9
|
|||||||
loader_version=0.15.11
|
loader_version=0.15.11
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
|
@@ -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.selectedSlot + PlayerInventory.MAIN_SIZE, GLFW.GLFW_MOUSE_BUTTON_1,
|
||||||
SlotActionType.PICKUP, player);
|
SlotActionType.PICKUP, player);
|
||||||
}, 50, TimeUnit.MILLISECONDS);
|
}, click_delay, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
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