3 Commits

Author SHA1 Message Date
Adam Macdonald
533dc47607 Items from armour slots no longer moved to hotbar, fixes #1 2023-03-29 19:23:22 +01:00
Adam Macdonald
d119e650e1 Change license specification in mod json config 2023-03-27 21:37:14 +01:00
Adam Macdonald
bad438ad38 Change license to MIT license 2023-03-27 21:24:43 +01:00
4 changed files with 26 additions and 22 deletions

30
LICENSE
View File

@@ -1,15 +1,21 @@
HotbarReplace Minecraft Mod MIT License
Copyright (C) 2023 Adam Macdonald
This program is free software: you can redistribute it and/or modify Copyright (c) 2023 Adam Macdonald
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, Permission is hereby granted, free of charge, to any person obtaining a copy
but WITHOUT ANY WARRANTY; without even the implied warranty of of this software and associated documentation files (the "Software"), to deal
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the in the Software without restriction, including without limitation the rights
GNU General Public License for more details. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
You should have received a copy of the GNU General Public License The above copyright notice and this permission notice shall be included in all
along with this program. If not, see <https://www.gnu.org/licenses/>. copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

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

View File

@@ -6,7 +6,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.slot.SlotActionType; import net.minecraft.screen.slot.SlotActionType;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -23,7 +22,7 @@ public class HotbarReplace implements ModInitializer {
@Override @Override
public void onInitialize() { public void onInitialize() {
LOGGER.info("HotbarReplace v0.1.1 initialised"); LOGGER.info("HotbarReplace v0.1.2 initialised");
} }
public static void tryReplaceSlot(ItemPlacementContext context, Item item) { public static void tryReplaceSlot(ItemPlacementContext context, Item item) {
@@ -41,13 +40,12 @@ public class HotbarReplace implements ModInitializer {
// Return if the inventory is empty // Return if the inventory is empty
if (inventory.isEmpty()) return; if (inventory.isEmpty()) return;
// Attempt to find a stack of matching items // If current screen handler is null, return
for (int i = 0; i < inventory.main.size(); i++) { if (player.currentScreenHandler == null) return;
if (i == inventory.selectedSlot) continue;
ItemStack stack = inventory.main.get(i); // Attempt to find a stack of matching items in the player's inventory
for (int i = 0; i < player.currentScreenHandler.slots.size(); i++) {
if (stack.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) {
client.interactionManager.clickSlot(player.currentScreenHandler.syncId, i, GLFW.GLFW_MOUSE_BUTTON_1, SlotActionType.PICKUP, player); client.interactionManager.clickSlot(player.currentScreenHandler.syncId, i, GLFW.GLFW_MOUSE_BUTTON_1, SlotActionType.PICKUP, player);

View File

@@ -14,7 +14,7 @@
"issues": "https://github.com/twokilohertz/HotbarReplace/issues" "issues": "https://github.com/twokilohertz/HotbarReplace/issues"
}, },
"license": "GPLv3", "license": "MIT",
"icon": "assets/hotbarreplace/icon.png", "icon": "assets/hotbarreplace/icon.png",
"environment": "*", "environment": "*",