8 Commits

Author SHA1 Message Date
Adam Macdonald
809870f4a9 Correct all package names & bump version to 0.1.1 2023-03-24 02:35:17 +00:00
Adam Macdonald
cbdb5f141c Don't hardcode a magic number for the hotbar slot ID offset 2023-03-24 02:28:34 +00:00
Adam Macdonald
5ee5d2632a Java source paths are correct now 2023-03-24 02:26:39 +00:00
Adam Macdonald
7cd6b9858c Update README 2023-03-24 01:20:50 +00:00
Adam Macdonald
216e0f9dfb Add README 2023-03-24 01:20:15 +00:00
Adam Macdonald
3a2bf3ed93 Update mod icon 2023-03-23 23:57:29 +00:00
Adam Macdonald
0990b53056 Update homepage, sources & issue tracker links 2023-03-23 23:19:58 +00:00
Adam Macdonald
a5442206d1 Remove unneeded import 2023-03-23 23:17:55 +00:00
7 changed files with 24 additions and 14 deletions

8
README.md Normal file
View File

@@ -0,0 +1,8 @@
## HotbarReplace
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.
### Known issues/Improvements
* The mod won't refill your hotbar slot with other stacks in other hotbar slots
* Make the mod more resilient to network delay and packet loss (don't hardcode a 50 ms delay)

View File

@@ -11,8 +11,8 @@ yarn_mappings=1.19.3+build.5
loader_version=0.14.17
# Mod Properties
mod_version = 0.1.0
maven_group = io.github.twokilohertz
mod_version = 0.1.1
maven_group = io.github.twokilohertz.hotbarreplace
archives_base_name = HotbarReplace
# Dependencies

View File

@@ -1,4 +1,4 @@
package io.github.twokilohertz;
package io.github.twokilohertz.hotbarreplace;
import net.fabricmc.api.ModInitializer;
import net.minecraft.client.MinecraftClient;
@@ -12,7 +12,6 @@ import org.lwjgl.glfw.GLFW;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -24,7 +23,7 @@ public class HotbarReplace implements ModInitializer {
@Override
public void onInitialize() {
LOGGER.info("HotbarReplace initialised");
LOGGER.info("HotbarReplace v0.1.1 initialised");
}
public static void tryReplaceSlot(ItemPlacementContext context, Item item) {
@@ -53,10 +52,12 @@ public class HotbarReplace implements ModInitializer {
if (client != null) {
client.interactionManager.clickSlot(player.currentScreenHandler.syncId, i, GLFW.GLFW_MOUSE_BUTTON_1, SlotActionType.PICKUP, player);
// Wait 50 seconds (on another thread) before attempting to move the new stack
// The magic number 36 is the offset to get the hotbar slotId
/*
Wait 50 seconds (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 + 36, GLFW.GLFW_MOUSE_BUTTON_1, SlotActionType.PICKUP, player);
client.interactionManager.clickSlot(player.currentScreenHandler.syncId, inventory.selectedSlot + PlayerInventory.MAIN_SIZE, GLFW.GLFW_MOUSE_BUTTON_1, SlotActionType.PICKUP, player);
}, 50, TimeUnit.MILLISECONDS);
}

View File

@@ -1,4 +1,4 @@
package io.github.twokilohertz.mixin;
package io.github.twokilohertz.hotbarreplace.mixin;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
@@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import io.github.twokilohertz.HotbarReplace;
import io.github.twokilohertz.hotbarreplace.HotbarReplace;
@Mixin(BlockItem.class)
public class BlockItemMixin {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -9,8 +9,9 @@
"Adam Macdonald"
],
"contact": {
"homepage": "https://twokilohertz.github.io/",
"sources": "https://twokilohertz.github.io/"
"homepage": "https://github.com/twokilohertz/HotbarReplace",
"sources": "https://github.com/twokilohertz/HotbarReplace",
"issues": "https://github.com/twokilohertz/HotbarReplace/issues"
},
"license": "GPLv3",
@@ -19,7 +20,7 @@
"environment": "*",
"entrypoints": {
"main": [
"io.github.twokilohertz.HotbarReplace"
"io.github.twokilohertz.hotbarreplace.HotbarReplace"
]
},
"mixins": [

View File

@@ -1,7 +1,7 @@
{
"required": true,
"minVersion": "0.8",
"package": "io.github.twokilohertz.mixin",
"package": "io.github.twokilohertz.hotbarreplace.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],