diff --git a/1_14/build.gradle b/1_14/build.gradle deleted file mode 100644 index db14232..0000000 --- a/1_14/build.gradle +++ /dev/null @@ -1,27 +0,0 @@ -group 'me.videogamesm12' - -repositories { - exclusiveContent { - forRepository { - maven { - name = "Modrinth" - url = "https://api.modrinth.com/maven" - } - } - filter { - includeGroup "maven.modrinth" - } - } -} - -dependencies { - minecraft "com.mojang:minecraft:1.14.4" - mappings "net.fabricmc:yarn:1.14.4+build.18:v2" - modImplementation "net.fabricmc.fabric-api:fabric-api:0.28.5+1.14" - - // Fabric didn't have a client command API at the time 1.14 and 1.15 were mainstream. It was only until around 1.16 - // when the Fabric API developers decided a client command API was necessary. Thing is, they never back-ported it - // change to 1.14 nor 1.15's versions of the Fabric API, so I have to rely on an ancient archived mod to do the - // trick. Fucking shit! - modImplementation "maven.modrinth:cotton-client-commands:1.0.1" -} \ No newline at end of file diff --git a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/FourteenHooks.java b/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/FourteenHooks.java deleted file mode 100644 index fe68cdb..0000000 --- a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/FourteenHooks.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.legacy; - -import com.google.gson.JsonElement; -import me.videogamesm12.hotbarsplus.api.IVersionHook; -import net.minecraft.text.Text; - -/** - *

FourteenHooks

- *

Hooks specific to 1.14.x - 1.15.x

- */ -public class FourteenHooks implements IVersionHook -{ - @Override - public Text convertFromJson(JsonElement tree) - { - return Text.Serializer.fromJson(tree); - } -} diff --git a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/HotbarsPlus.java b/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/HotbarsPlus.java deleted file mode 100644 index 570525b..0000000 --- a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/HotbarsPlus.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.legacy; - -import me.videogamesm12.hotbarsplus.api.event.navigation.HotbarNavigateEvent; -import me.videogamesm12.hotbarsplus.core.HBPCore; -import me.videogamesm12.hotbarsplus.legacy.manager.CommandManager; -import me.videogamesm12.hotbarsplus.legacy.manager.CustomToastManager; -import me.videogamesm12.hotbarsplus.legacy.manager.KeybindManager; -import me.videogamesm12.hotbarsplus.legacy.mixin.CreativeInvScreenMixin; -import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; -import net.minecraft.item.ItemGroup; -import net.minecraft.util.ActionResult; - -import java.math.BigInteger; - -public class HotbarsPlus implements ClientModInitializer, HotbarNavigateEvent -{ - @Override - public void onInitializeClient() - { - HBPCore.KEYBINDS = new KeybindManager(); - //-- - if (FabricLoader.getInstance().isModLoaded("cotton-client-commands")) - { - HBPCore.COMMANDS = new CommandManager(); - } - else - { - HBPCore.LOGGER.warn("Cotton Client Commands was not found. In-game commands will not work."); - } - //-- - HBPCore.TOASTS = new CustomToastManager(); - HBPCore.VHOOKS = new FourteenHooks(); - //-- - HotbarNavigateEvent.EVENT.register(this); - } - - @Override - public ActionResult onNavigate(BigInteger page) - { - // Refreshes the menu if it is currently open; - if (MinecraftClient.getInstance().currentScreen instanceof CreativeInventoryScreen) - { - Screen screen = MinecraftClient.getInstance().currentScreen; - - if (((CreativeInvScreenMixin.CISAccessor) screen).getSelectedTab() == ItemGroup.HOTBAR.getIndex()) - { - ((CreativeInvScreenMixin.CISAccessor) screen).setSelectedTab(ItemGroup.HOTBAR); - } - } - - return ActionResult.PASS; - } -} \ No newline at end of file diff --git a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/gui/CustomButtons.java b/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/gui/CustomButtons.java deleted file mode 100644 index f0ac42f..0000000 --- a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/gui/CustomButtons.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.legacy.gui; - -import me.videogamesm12.hotbarsplus.core.HBPCore; -import net.minecraft.client.gui.widget.ButtonWidget; - -/** - * CustomButtons - *

Custom buttons for the mod specific to 1.14.x.

- * -- - * @implNote This is here because 1.14 doesn't support custom fonts in text components. - */ -public class CustomButtons -{ - public static class BackupButton extends ButtonWidget - { - public BackupButton(int x, int y) - { - super(x, y, 16, 12, "✍", - (button) -> HBPCore.UBL.backupHotbar()); - } - } - - public static class NextButton extends ButtonWidget - { - public NextButton(int x, int y) - { - super(x, y, 16, 12, "→", (button) -> HBPCore.UPL.incrementPage()); - } - } - - public static class PreviousButton extends ButtonWidget - { - public PreviousButton(int x, int y) - { - super(x, y, 16, 12, "←", (button) -> HBPCore.UPL.decrementPage()); - } - } -} diff --git a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/manager/CommandManager.java b/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/manager/CommandManager.java deleted file mode 100644 index e5750bc..0000000 --- a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/manager/CommandManager.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.legacy.manager; - -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.LongArgumentType; -import com.mojang.brigadier.tree.LiteralCommandNode; -import io.github.cottonmc.clientcommands.ArgumentBuilders; -import io.github.cottonmc.clientcommands.ClientCommandPlugin; -import io.github.cottonmc.clientcommands.CottonClientCommandSource; -import me.videogamesm12.hotbarsplus.api.manager.ICommandManager; -import me.videogamesm12.hotbarsplus.core.commands.*; - -public class CommandManager implements ICommandManager, ClientCommandPlugin -{ - private LiteralCommandNode hotbarsPlusCommand; - - @Override - public void register() - { - // Don't do anything here as Cotton Client Commands does the work for us - } - - @Override - public LiteralCommandNode getCommandNode() - { - return hotbarsPlusCommand; - } - - @Override - public void registerCommands(CommandDispatcher dispatcher) - { - hotbarsPlusCommand = dispatcher.register( - ArgumentBuilders.literal("hotbars+").then( - ArgumentBuilders.literal("backup").executes(BackupCommand.impl()) - ).then( - ArgumentBuilders.literal("next").executes(NextCommand.impl()) - ).then( - ArgumentBuilders.literal("previous").executes(PreviousCommand.impl()) - ).then( - ArgumentBuilders.literal("goto").then( - ArgumentBuilders.argument("page", LongArgumentType.longArg()).executes(GoToCommand.impl()) - ) - ).then( - ArgumentBuilders.literal("cache").then( - ArgumentBuilders.literal("list").executes(CacheCommand.ListCommand.impl()) - ).then( - ArgumentBuilders.literal("clear").executes(CacheCommand.ClearCommand.impl()) - ) - ) - ); - } -} diff --git a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/manager/CustomToastManager.java b/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/manager/CustomToastManager.java deleted file mode 100644 index 43e3ffe..0000000 --- a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/manager/CustomToastManager.java +++ /dev/null @@ -1,117 +0,0 @@ -package me.videogamesm12.hotbarsplus.legacy.manager; - -import com.mojang.blaze3d.platform.GlStateManager; -import lombok.Getter; -import lombok.Setter; -import me.videogamesm12.hotbarsplus.api.manager.IToastManager; -import me.videogamesm12.hotbarsplus.core.universal.NotificationManager; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawableHelper; -import net.minecraft.client.toast.Toast; -import net.minecraft.client.toast.ToastManager; -import net.minecraft.text.Text; - -public class CustomToastManager implements IToastManager -{ - @Override - public HotbarToast getToastFrom(NotificationManager.NotificationType type, Text... texts) - { - Text title; - Text description; - - switch (texts.length) - { - case 0: - { - throw new IllegalArgumentException("Fuck you"); - } - case 1: - { - title = texts[0]; - description = null; - break; - } - default: - case 2: - { - title = texts[0]; - description = texts[1]; - break; - } - } - - return new HotbarToast(title, description, type); - } - - @Override - public void showToast(IHotbarToast toast) - { - HotbarToast instance = MinecraftClient.getInstance().getToastManager().getToast(HotbarToast.class, toast.getType()); - if (instance == null) - { - MinecraftClient.getInstance().getToastManager().add((HotbarToast) toast); - } - else - { - HotbarToast hToast = (HotbarToast) toast; - //-- - instance.setTitle(hToast.getTitle()); - instance.setDescription(hToast.getDescription()); - instance.setJustUpdated(true); - } - } - - @Getter - @Setter - public static class HotbarToast implements IHotbarToast, Toast - { - private Text title; - private Text description; - //-- - private NotificationManager.NotificationType type; - private long time; - //-- - private boolean justUpdated = true; - - public HotbarToast(Text title, Text description, NotificationManager.NotificationType type) - { - this.title = title; - this.description = description; - this.type = type; - } - - @Override - public Visibility draw(ToastManager manager, long currentTime) - { - if (justUpdated) - { - this.time = currentTime; - justUpdated = false; - } - - MinecraftClient.getInstance().getTextureManager().bindTexture(TEXTURE); - GlStateManager.color3f(1, 1, 1); - DrawableHelper.blit(0, 0, 0, 20, 160, 32, 160, 52); - //-- - GlStateManager.enableBlend(); - DrawableHelper.blit(6, 6, 20 * type.ordinal(), 0, 20, 20, 160, 52); - GlStateManager.disableBlend(); - //-- - int titleY = description == null ? 12 : 7; - MinecraftClient.getInstance().textRenderer.draw(title.asString(), 30, titleY, type.getColor()); - - if (description != null) - { - MinecraftClient.getInstance().textRenderer.draw(description.asString(), 30, 18, 0xFFFFFF); - } - - return currentTime - time >= 5000 ? Visibility.HIDE : Visibility.SHOW; - } - - @Override - public NotificationManager.NotificationType getType() - { - return type; - } - } -} diff --git a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/manager/KeybindManager.java b/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/manager/KeybindManager.java deleted file mode 100644 index b17b956..0000000 --- a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/manager/KeybindManager.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.legacy.manager; - -import me.videogamesm12.hotbarsplus.api.manager.IKeybindManager; -import me.videogamesm12.hotbarsplus.api.event.keybind.BackupBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.NextBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.PreviousBindPressEvent; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.options.KeyBinding; -import net.minecraft.client.util.InputUtil; -import org.lwjgl.glfw.GLFW; - -public class KeybindManager implements IKeybindManager, ClientTickEvents.EndTick -{ - public KeyBinding backup = new KeyBinding("key.hotbarsplus.backup", InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_UNKNOWN, "category.hotbarsplus.navigation"); - public KeyBinding next = new KeyBinding("key.hotbarsplus.next", InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_RIGHT_BRACKET, "category.hotbarsplus.navigation"); - public KeyBinding previous = new KeyBinding("key.hotbarsplus.previous", InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_LEFT_BRACKET, "category.hotbarsplus.navigation"); - - public KeybindManager() - { - registerKeybinds(); - } - - @Override - public void registerKeybinds() - { - backup = KeyBindingHelper.registerKeyBinding(backup); - next = KeyBindingHelper.registerKeyBinding(next); - previous = KeyBindingHelper.registerKeyBinding(previous); - //-- - ClientTickEvents.END_CLIENT_TICK.register(this); - } - - @Override - public void onEndTick(MinecraftClient client) - { - if (backup.wasPressed()) - { - BackupBindPressEvent.EVENT.invoker().onBackupPress(); - } - - if (next.wasPressed()) - { - NextBindPressEvent.EVENT.invoker().onNextPress(); - } - else if (previous.wasPressed()) - { - PreviousBindPressEvent.EVENT.invoker().onPreviousPress(); - } - } -} diff --git a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/mixin/CSAccessor.java b/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/mixin/CSAccessor.java deleted file mode 100644 index 0c65544..0000000 --- a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/mixin/CSAccessor.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.legacy.mixin; - -import net.minecraft.client.gui.screen.ingame.ContainerScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(ContainerScreen.class) -public interface CSAccessor -{ - @Accessor("x") - int getX(); - - @Accessor("y") - int getY(); -} diff --git a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/mixin/CreativeInvScreenMixin.java b/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/mixin/CreativeInvScreenMixin.java deleted file mode 100644 index ad87105..0000000 --- a/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/mixin/CreativeInvScreenMixin.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.legacy.mixin; - -import me.videogamesm12.hotbarsplus.api.event.keybind.BackupBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.NextBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.PreviousBindPressEvent; -import me.videogamesm12.hotbarsplus.core.HBPCore; -import me.videogamesm12.hotbarsplus.legacy.gui.CustomButtons; -import me.videogamesm12.hotbarsplus.legacy.manager.KeybindManager; -import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen; -import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemGroup; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.gen.Accessor; -import org.spongepowered.asm.mixin.gen.Invoker; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(CreativeInventoryScreen.class) -public abstract class CreativeInvScreenMixin extends AbstractInventoryScreen - implements CSAccessor -{ - public CustomButtons.NextButton next; - public CustomButtons.BackupButton backup; - public CustomButtons.PreviousButton previous; - - @Shadow private boolean field_2888; - - public CreativeInvScreenMixin(CreativeInventoryScreen.CreativeContainer container, PlayerInventory playerInventory, Text text) - { - super(container, playerInventory, text); - } - - @Inject(method = "init", at = @At("RETURN")) - public void injInit(CallbackInfo ci) - { - // Offset - int x = this.getX() + 159; - int y = this.getY() + 4; - - // Initialize buttons - this.next = new CustomButtons.NextButton(x + 16, y); - this.backup = new CustomButtons.BackupButton(x, y); - this.previous = new CustomButtons.PreviousButton(x - 16, y); - - // Modify buttons to adjust for the currently selected tab - if (((CISAccessor) this).getSelectedTab() != ItemGroup.HOTBAR.getIndex()) - { - next.visible = false; - backup.visible = false; - previous.visible = false; - } - - // Regardless of the current tab, disable this button if the selected hotbar file doesn't exist - backup.active = HBPCore.UPL.hotbarPageExists(); - - // Adding buttons - addButton(next); - addButton(backup); - addButton(previous); - } - - @Inject(method = "setSelectedTab", at = @At("HEAD")) - public void injSetCreativeTab(ItemGroup group, CallbackInfo ci) - { - if (next != null && backup != null && previous != null) - { - if (group == ItemGroup.HOTBAR) - { - next.visible = true; - backup.visible = true; - previous.visible = true; - } - else - { - next.visible = false; - backup.visible = false; - previous.visible = false; - } - - backup.active = HBPCore.UPL.hotbarPageExists(); - } - } - - @Inject(method = "keyPressed", at = @At(value = "HEAD", shift = At.Shift.AFTER), cancellable = true) - public void injectKeyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable cir) - { - if (((CISAccessor) this).getSelectedTab() == ItemGroup.HOTBAR.getIndex()) - { - KeybindManager manager = (KeybindManager) HBPCore.KEYBINDS; - - if (manager.next.matchesKey(keyCode, scanCode)) - { - NextBindPressEvent.EVENT.invoker().onNextPress(); - field_2888 = true; - cir.setReturnValue(true); - } - else if (manager.backup.matchesKey(keyCode, scanCode)) - { - BackupBindPressEvent.EVENT.invoker().onBackupPress(); - field_2888 = true; - cir.setReturnValue(true); - } - else if (manager.previous.matchesKey(keyCode, scanCode)) - { - PreviousBindPressEvent.EVENT.invoker().onPreviousPress(); - field_2888 = true; - cir.setReturnValue(true); - } - } - } - - @Mixin(CreativeInventoryScreen.class) - public interface CISAccessor - { - @Invoker("setSelectedTab") - void setSelectedTab(ItemGroup group); - - @Accessor - int getSelectedTab(); - } -} diff --git a/1_14/src/main/resources/assets/hotbarsplus-legacy/icon.png b/1_14/src/main/resources/assets/hotbarsplus-legacy/icon.png deleted file mode 100644 index cac1259..0000000 Binary files a/1_14/src/main/resources/assets/hotbarsplus-legacy/icon.png and /dev/null differ diff --git a/1_14/src/main/resources/fabric.mod.json b/1_14/src/main/resources/fabric.mod.json deleted file mode 100644 index 5a24eba..0000000 --- a/1_14/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "schemaVersion": 1, - "id": "hotbarsplus-legacy", - "version": "${version}", - "name": "Legacy Hooks", - "description": "Hooks specific to 1.14.x/1.15.x for Hotbars+.", - "authors": ["videogamesm12"], - "contact": { - "issues": "https://github.com/VideoGameSmash12/HotbarsPlus/issues", - "homepage": "https://github.com/VideoGameSmash12/HotbarsPlus", - "sources": "https://github.com/VideoGameSmash12/HotbarsPlus" - }, - "license": "MIT", - "icon": "assets/hotbarsplus-legacy/icon.png", - "environment": "client", - "entrypoints": { - "client": ["me.videogamesm12.hotbarsplus.legacy.HotbarsPlus"], - "cotton-client-commands": ["me.videogamesm12.hotbarsplus.legacy.manager.CommandManager"] - }, - "mixins": [ - "hotbarsplus.legacy.mixins.json" - ], - "depends": { - "minecraft": ["1.14.x", "1.15.x"] - }, - "custom": { - "modmenu:api": true, - "modmenu:parent": "hotbarsplus" - } -} \ No newline at end of file diff --git a/1_14/src/main/resources/hotbarsplus.legacy.mixins.json b/1_14/src/main/resources/hotbarsplus.legacy.mixins.json deleted file mode 100644 index 821051d..0000000 --- a/1_14/src/main/resources/hotbarsplus.legacy.mixins.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.videogamesm12.hotbarsplus.legacy.mixin", - "compatibilityLevel": "JAVA_8", - "mixins": [ - ], - "client": [ - "CreativeInvScreenMixin", - "CreativeInvScreenMixin$CISAccessor", - "CSAccessor" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/1_16/build.gradle b/1_16/build.gradle deleted file mode 100644 index 6f91852..0000000 --- a/1_16/build.gradle +++ /dev/null @@ -1,23 +0,0 @@ -group 'me.videogamesm12' - -repositories { - exclusiveContent { - forRepository { - maven { - name = "Modrinth" - url = "https://api.modrinth.com/maven" - } - } - filter { - includeGroup "maven.modrinth" - } - } -} - -dependencies { - minecraft "com.mojang:minecraft:1.16.5" - mappings "net.fabricmc:yarn:1.16.5+build.10:v2" - modImplementation "net.fabricmc.fabric-api:fabric-api:0.42.0+1.16" - - modImplementation "maven.modrinth:cotton-client-commands:1.0.1" -} \ No newline at end of file diff --git a/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/HotbarsPlus.java b/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/HotbarsPlus.java deleted file mode 100644 index 4982afd..0000000 --- a/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/HotbarsPlus.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_16; - -import me.videogamesm12.hotbarsplus.api.event.navigation.HotbarNavigateEvent; -import me.videogamesm12.hotbarsplus.core.HBPCore; -import me.videogamesm12.hotbarsplus.v1_16.manager.CommandManager; -import me.videogamesm12.hotbarsplus.v1_16.manager.CustomToastManager; -import me.videogamesm12.hotbarsplus.v1_16.manager.FallbackCommandManager; -import me.videogamesm12.hotbarsplus.v1_16.manager.KeybindManager; -import me.videogamesm12.hotbarsplus.v1_16.mixin.CreativeInvScreenMixin; -import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; -import net.minecraft.item.ItemGroup; -import net.minecraft.util.ActionResult; - -import java.math.BigInteger; - -public class HotbarsPlus implements ClientModInitializer, HotbarNavigateEvent -{ - @Override - public void onInitializeClient() - { - HBPCore.KEYBINDS = new KeybindManager(); - //-- - /* - So the issue here is that there was a period of time when both Cotton Client Commands and Fabric API's - client command API were available for 1.16. However, Fabric API's client command API was only available for - 1.16.5. Cotton Client Commands was available for 1.16 - 1.16.4, but probably worked on 1.16.5 too. - -- - This is a compromise solution that allows both to work. - */ - if (FabricLoader.getInstance().isModLoaded("cotton-client-commands")) - { - // Cotton Client Commands - HBPCore.COMMANDS = new FallbackCommandManager(); - } - else - { - // Fabric API - try - { - HBPCore.COMMANDS = new CommandManager(); - } - catch (Throwable ex) - { - HBPCore.LOGGER.warn("Neither a sufficient version of the Fabric API nor Cotton Client Commands were found. No in-game commands will work."); - } - } - //-- - HBPCore.TOASTS = new CustomToastManager(); - //-- - HotbarNavigateEvent.EVENT.register(this); - } - - @Override - public ActionResult onNavigate(BigInteger page) - { - // Refreshes the menu if it is currently open; - if (MinecraftClient.getInstance().currentScreen instanceof CreativeInventoryScreen) - { - Screen screen = MinecraftClient.getInstance().currentScreen; - - if (((CreativeInventoryScreen) screen).getSelectedTab() == ItemGroup.HOTBAR.getIndex()) - { - ((CreativeInvScreenMixin.CISAccessor) screen).setSelectedTab(ItemGroup.HOTBAR); - } - } - - return ActionResult.PASS; - } -} \ No newline at end of file diff --git a/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/CommandManager.java b/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/CommandManager.java deleted file mode 100644 index 6876064..0000000 --- a/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/CommandManager.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_16.manager; - -import com.mojang.brigadier.arguments.LongArgumentType; -import com.mojang.brigadier.tree.LiteralCommandNode; -import me.videogamesm12.hotbarsplus.api.manager.ICommandManager; -import me.videogamesm12.hotbarsplus.core.commands.*; -import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager; -import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource; - -public class CommandManager implements ICommandManager -{ - private LiteralCommandNode hotbarsPlusCommand; - - public CommandManager() - { - register(); - } - - @Override - public void register() - { - hotbarsPlusCommand = ClientCommandManager.DISPATCHER.register( - ClientCommandManager.literal("hotbars+").then( - ClientCommandManager.literal("backup").executes(BackupCommand.impl()) - ).then( - ClientCommandManager.literal("next").executes(NextCommand.impl()) - ).then( - ClientCommandManager.literal("previous").executes(PreviousCommand.impl()) - ).then( - ClientCommandManager.literal("goto").then( - ClientCommandManager.argument("page", LongArgumentType.longArg()).executes(GoToCommand.impl()) - ) - ).then( - ClientCommandManager.literal("cache").then( - ClientCommandManager.literal("list").executes(CacheCommand.ListCommand.impl()) - ).then( - ClientCommandManager.literal("clear").executes(CacheCommand.ClearCommand.impl()) - ) - ) - ); - } - - @Override - public LiteralCommandNode getCommandNode() - { - return hotbarsPlusCommand; - } -} diff --git a/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/CustomToastManager.java b/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/CustomToastManager.java deleted file mode 100644 index cc92773..0000000 --- a/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/CustomToastManager.java +++ /dev/null @@ -1,119 +0,0 @@ -package me.videogamesm12.hotbarsplus.v1_16.manager; - -import com.mojang.blaze3d.platform.GlStateManager; -import lombok.Getter; -import lombok.Setter; -import me.videogamesm12.hotbarsplus.api.manager.IToastManager; -import me.videogamesm12.hotbarsplus.core.universal.NotificationManager; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawableHelper; -import net.minecraft.client.toast.Toast; -import net.minecraft.client.toast.ToastManager; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.Text; -import org.lwjgl.opengl.GL11; - -public class CustomToastManager implements IToastManager -{ - @Override - public HotbarToast getToastFrom(NotificationManager.NotificationType type, Text... texts) - { - Text title; - Text description; - - switch (texts.length) - { - case 0: - { - throw new IllegalArgumentException("Fuck you"); - } - case 1: - { - title = texts[0]; - description = null; - break; - } - default: - case 2: - { - title = texts[0]; - description = texts[1]; - break; - } - } - - return new HotbarToast(title, description, type); - } - - @Override - public void showToast(IHotbarToast toast) - { - HotbarToast instance = MinecraftClient.getInstance().getToastManager().getToast(HotbarToast.class, toast.getType()); - if (instance == null) - { - MinecraftClient.getInstance().getToastManager().add((HotbarToast) toast); - } - else - { - HotbarToast hToast = (HotbarToast) toast; - //-- - instance.setTitle(hToast.getTitle()); - instance.setDescription(hToast.getDescription()); - instance.setJustUpdated(true); - } - } - - @Getter - @Setter - public static class HotbarToast implements IHotbarToast, Toast - { - private Text title; - private Text description; - //-- - private NotificationManager.NotificationType type; - private long time; - //-- - private boolean justUpdated = true; - - public HotbarToast(Text title, Text description, NotificationManager.NotificationType type) - { - this.title = title; - this.description = description; - this.type = type; - } - - @Override - public Visibility draw(MatrixStack stack, ToastManager manager, long currentTime) - { - if (justUpdated) - { - this.time = currentTime; - justUpdated = false; - } - - MinecraftClient.getInstance().getTextureManager().bindTexture(IToastManager.TEXTURE); - GL11.glColor4f(1, 1, 1, 1); - DrawableHelper.drawTexture(stack, 0, 0, 0, 20, 160, 32, 160, 52); - //-- - GlStateManager.enableBlend(); - DrawableHelper.drawTexture(stack, 6, 6, 20 * type.ordinal(), 0, 20, 20, 160, 52); - GlStateManager.disableBlend(); - //-- - int titleY = description == null ? 12 : 7; - MinecraftClient.getInstance().textRenderer.draw(stack, title.getString(), 30, titleY, type.getColor()); - - if (description != null) - { - MinecraftClient.getInstance().textRenderer.draw(stack, description.asString(), 30, 18, 0xFFFFFF); - } - - return currentTime - time >= 5000 ? Visibility.HIDE : Visibility.SHOW; - } - - @Override - public NotificationManager.NotificationType getType() - { - return type; - } - } -} diff --git a/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/FallbackCommandManager.java b/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/FallbackCommandManager.java deleted file mode 100644 index 623b409..0000000 --- a/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/FallbackCommandManager.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2023 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - - -package me.videogamesm12.hotbarsplus.v1_16.manager; - -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.LongArgumentType; -import com.mojang.brigadier.tree.LiteralCommandNode; -import io.github.cottonmc.clientcommands.ArgumentBuilders; -import io.github.cottonmc.clientcommands.ClientCommandPlugin; -import io.github.cottonmc.clientcommands.CottonClientCommandSource; -import me.videogamesm12.hotbarsplus.api.manager.ICommandManager; -import me.videogamesm12.hotbarsplus.core.commands.*; - -public class FallbackCommandManager implements ICommandManager, ClientCommandPlugin -{ - private LiteralCommandNode hotbarsPlusCommand; - - @Override - public void register() - { - // Unused, Cotton Client Commands does all the magic for us - } - - @Override - public LiteralCommandNode getCommandNode() - { - return hotbarsPlusCommand; - } - - @Override - public void registerCommands(CommandDispatcher dispatcher) - { - hotbarsPlusCommand = dispatcher.register( - ArgumentBuilders.literal("hotbars+").then( - ArgumentBuilders.literal("backup").executes(BackupCommand.impl()) - ).then( - ArgumentBuilders.literal("next").executes(NextCommand.impl()) - ).then( - ArgumentBuilders.literal("previous").executes(PreviousCommand.impl()) - ).then( - ArgumentBuilders.literal("goto").then( - ArgumentBuilders.argument("page", LongArgumentType.longArg()).executes(GoToCommand.impl()) - ) - ).then( - ArgumentBuilders.literal("cache").then( - ArgumentBuilders.literal("list").executes(CacheCommand.ListCommand.impl()) - ).then( - ArgumentBuilders.literal("clear").executes(CacheCommand.ClearCommand.impl()) - ) - ) - ); - } -} diff --git a/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/KeybindManager.java b/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/KeybindManager.java deleted file mode 100644 index 8536c6b..0000000 --- a/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/KeybindManager.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_16.manager; - -import me.videogamesm12.hotbarsplus.api.manager.IKeybindManager; -import me.videogamesm12.hotbarsplus.api.event.keybind.BackupBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.NextBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.PreviousBindPressEvent; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; -import org.lwjgl.glfw.GLFW; - -public class KeybindManager implements IKeybindManager, ClientTickEvents.EndTick -{ - public KeyBinding backup = new KeyBinding("key.hotbarsplus.backup", InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_UNKNOWN, "category.hotbarsplus.navigation"); - public KeyBinding next = new KeyBinding("key.hotbarsplus.next", InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_RIGHT_BRACKET, "category.hotbarsplus.navigation"); - public KeyBinding previous = new KeyBinding("key.hotbarsplus.previous", InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_LEFT_BRACKET, "category.hotbarsplus.navigation"); - - public KeybindManager() - { - registerKeybinds(); - } - - @Override - public void registerKeybinds() - { - backup = KeyBindingHelper.registerKeyBinding(backup); - next = KeyBindingHelper.registerKeyBinding(next); - previous = KeyBindingHelper.registerKeyBinding(previous); - //-- - ClientTickEvents.END_CLIENT_TICK.register(this); - } - - @Override - public void onEndTick(MinecraftClient client) - { - if (backup.wasPressed()) - { - BackupBindPressEvent.EVENT.invoker().onBackupPress(); - } - - if (next.wasPressed()) - { - NextBindPressEvent.EVENT.invoker().onNextPress(); - } - else if (previous.wasPressed()) - { - PreviousBindPressEvent.EVENT.invoker().onPreviousPress(); - } - } -} diff --git a/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/mixin/CreativeInvScreenMixin.java b/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/mixin/CreativeInvScreenMixin.java deleted file mode 100644 index 12ad4eb..0000000 --- a/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/mixin/CreativeInvScreenMixin.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_16.mixin; - -import me.videogamesm12.hotbarsplus.api.event.keybind.BackupBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.NextBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.PreviousBindPressEvent; -import me.videogamesm12.hotbarsplus.core.HBPCore; -import me.videogamesm12.hotbarsplus.core.gui.CustomButtons; -import me.videogamesm12.hotbarsplus.v1_16.manager.KeybindManager; -import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen; -import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemGroup; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.gen.Invoker; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -/** - * CreativeInvScreenMixin - *

Creative Inventory Menu injection for 1.16.5.

- * -- - * - */ -@Mixin(CreativeInventoryScreen.class) -public abstract class CreativeInvScreenMixin extends AbstractInventoryScreen - implements HSAccessor -{ - @Shadow public abstract int getSelectedTab(); - - @Shadow private boolean ignoreTypedCharacter; - - public CustomButtons.NextButton next; - public CustomButtons.BackupButton backup; - public CustomButtons.PreviousButton previous; - - public CreativeInvScreenMixin(CreativeInventoryScreen.CreativeScreenHandler screenHandler, PlayerInventory playerInventory, Text text) - { - super(screenHandler, playerInventory, text); - } - - @Inject(method = "init", at = @At("RETURN")) - public void injInit(CallbackInfo ci) - { - // Offset - int x = this.getX() + 159; - int y = this.getY() + 4; - - // Initialize buttons - this.next = new CustomButtons.NextButton(x + 16, y); - this.backup = new CustomButtons.BackupButton(x, y); - this.previous = new CustomButtons.PreviousButton(x - 16, y); - - // Modify buttons to adjust for the currently selected tab - if (getSelectedTab() != ItemGroup.HOTBAR.getIndex()) - { - next.visible = false; - backup.visible = false; - previous.visible = false; - } - - // Regardless of the current tab, disable this button if the selected hotbar file doesn't exist - backup.active = HBPCore.UPL.hotbarPageExists(); - - // Adding buttons - addButton(next); - addButton(backup); - addButton(previous); - } - - @Inject(method = "setSelectedTab", at = @At("HEAD")) - public void injSetCreativeTab(ItemGroup group, CallbackInfo ci) - { - if (next != null && backup != null && previous != null) - { - if (group == ItemGroup.HOTBAR) - { - next.visible = true; - backup.visible = true; - previous.visible = true; - } - else - { - next.visible = false; - backup.visible = false; - previous.visible = false; - } - - backup.active = HBPCore.UPL.hotbarPageExists(); - } - } - - @Inject(method = "keyPressed", at = @At(value = "HEAD", shift = At.Shift.AFTER), cancellable = true) - public void injectKeyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable cir) - { - if (getSelectedTab() == ItemGroup.HOTBAR.getIndex()) - { - KeybindManager manager = (KeybindManager) HBPCore.KEYBINDS; - - if (manager.next.matchesKey(keyCode, scanCode)) - { - NextBindPressEvent.EVENT.invoker().onNextPress(); - ignoreTypedCharacter = true; - cir.setReturnValue(true); - } - else if (manager.backup.matchesKey(keyCode, scanCode)) - { - BackupBindPressEvent.EVENT.invoker().onBackupPress(); - ignoreTypedCharacter = true; - cir.setReturnValue(true); - } - else if (manager.previous.matchesKey(keyCode, scanCode)) - { - PreviousBindPressEvent.EVENT.invoker().onPreviousPress(); - ignoreTypedCharacter = true; - cir.setReturnValue(true); - } - } - } - - @Mixin(CreativeInventoryScreen.class) - public interface CISAccessor - { - @Invoker("setSelectedTab") - void setSelectedTab(ItemGroup group); - } -} \ No newline at end of file diff --git a/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/mixin/HSAccessor.java b/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/mixin/HSAccessor.java deleted file mode 100644 index e0c2d83..0000000 --- a/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/mixin/HSAccessor.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_16.mixin; - -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(HandledScreen.class) -public interface HSAccessor -{ - @Accessor("x") - int getX(); - - @Accessor("y") - int getY(); -} diff --git a/1_16/src/main/resources/assets/hotbarsplus-1_16/icon.png b/1_16/src/main/resources/assets/hotbarsplus-1_16/icon.png deleted file mode 100644 index 1b0491c..0000000 Binary files a/1_16/src/main/resources/assets/hotbarsplus-1_16/icon.png and /dev/null differ diff --git a/1_16/src/main/resources/fabric.mod.json b/1_16/src/main/resources/fabric.mod.json deleted file mode 100644 index b23463d..0000000 --- a/1_16/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "schemaVersion": 1, - "id": "hotbarsplus-1_16", - "version": "${version}", - "name": "Hooks for 1.16", - "description": "Hooks specific to 1.16.x for Hotbars+.", - "authors": ["videogamesm12"], - "contact": { - "issues": "https://github.com/VideoGameSmash12/HotbarsPlus/issues", - "homepage": "https://github.com/VideoGameSmash12/HotbarsPlus", - "sources": "https://github.com/VideoGameSmash12/HotbarsPlus" - }, - "license": "MIT", - "icon": "assets/hotbarsplus-1_16/icon.png", - "environment": "client", - "entrypoints": { - "client": [ - "me.videogamesm12.hotbarsplus.v1_16.HotbarsPlus" - ], - "cotton-client-commands": [ - "me.videogamesm12.hotbarsplus.v1_16.manager.FallbackCommandManager" - ] - }, - "mixins": [ - "hotbarsplus.1_16.mixins.json" - ], - "depends": { - "minecraft": "1.16.x" - }, - "custom": { - "modmenu": { - "badges": ["library"], - "parent": "hotbarsplus" - } - } -} \ No newline at end of file diff --git a/1_16/src/main/resources/hotbarsplus.1_16.mixins.json b/1_16/src/main/resources/hotbarsplus.1_16.mixins.json deleted file mode 100644 index e01640d..0000000 --- a/1_16/src/main/resources/hotbarsplus.1_16.mixins.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.videogamesm12.hotbarsplus.v1_16.mixin", - "compatibilityLevel": "JAVA_8", - "mixins": [ - "CreativeInvScreenMixin", - "CreativeInvScreenMixin$CISAccessor", - "HSAccessor" - ], - "client": [ - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/1_17/build.gradle b/1_17/build.gradle deleted file mode 100644 index dbd8568..0000000 --- a/1_17/build.gradle +++ /dev/null @@ -1,7 +0,0 @@ -group 'me.videogamesm12' - -dependencies { - minecraft "com.mojang:minecraft:1.17.1" - mappings "net.fabricmc:yarn:1.17.1+build.65:v2" - modImplementation "net.fabricmc.fabric-api:fabric-api:0.46.1+1.17" -} \ No newline at end of file diff --git a/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/HotbarsPlus.java b/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/HotbarsPlus.java deleted file mode 100644 index 2bd7af1..0000000 --- a/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/HotbarsPlus.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_17; - -import me.videogamesm12.hotbarsplus.api.event.navigation.HotbarNavigateEvent; -import me.videogamesm12.hotbarsplus.core.HBPCore; -import me.videogamesm12.hotbarsplus.v1_17.manager.CommandManager; -import me.videogamesm12.hotbarsplus.v1_17.manager.CustomToastManager; -import me.videogamesm12.hotbarsplus.v1_17.manager.KeybindManager; -import me.videogamesm12.hotbarsplus.v1_17.mixin.CreativeInvScreenMixin; -import net.fabricmc.api.ClientModInitializer; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; -import net.minecraft.item.ItemGroup; -import net.minecraft.util.ActionResult; - -import java.math.BigInteger; - -public class HotbarsPlus implements ClientModInitializer, HotbarNavigateEvent -{ - @Override - public void onInitializeClient() - { - HBPCore.KEYBINDS = new KeybindManager(); - HBPCore.COMMANDS = new CommandManager(); - HBPCore.TOASTS = new CustomToastManager(); - //-- - HotbarNavigateEvent.EVENT.register(this); - } - - @Override - public ActionResult onNavigate(BigInteger page) - { - // Refreshes the menu if it is currently open; - if (MinecraftClient.getInstance().currentScreen instanceof CreativeInventoryScreen) - { - Screen screen = MinecraftClient.getInstance().currentScreen; - - if (((CreativeInventoryScreen) screen).getSelectedTab() == ItemGroup.HOTBAR.getIndex()) - { - ((CreativeInvScreenMixin.CISAccessor) screen).setSelectedTab(ItemGroup.HOTBAR); - } - } - - return ActionResult.PASS; - } -} diff --git a/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/manager/CommandManager.java b/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/manager/CommandManager.java deleted file mode 100644 index 69a5c2d..0000000 --- a/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/manager/CommandManager.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_17.manager; - -import com.mojang.brigadier.arguments.LongArgumentType; -import com.mojang.brigadier.tree.LiteralCommandNode; -import me.videogamesm12.hotbarsplus.api.manager.ICommandManager; -import me.videogamesm12.hotbarsplus.core.commands.*; -import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager; -import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource; - -public class CommandManager implements ICommandManager -{ - private LiteralCommandNode hotbarsPlusCommand; - - public CommandManager() - { - register(); - } - - @Override - public void register() - { - hotbarsPlusCommand = ClientCommandManager.DISPATCHER.register( - ClientCommandManager.literal("hotbars+").then( - ClientCommandManager.literal("backup").executes(BackupCommand.impl()) - ).then( - ClientCommandManager.literal("next").executes(NextCommand.impl()) - ).then( - ClientCommandManager.literal("previous").executes(PreviousCommand.impl()) - ).then( - ClientCommandManager.literal("goto").then( - ClientCommandManager.argument("page", LongArgumentType.longArg()).executes(GoToCommand.impl()) - ) - ).then( - ClientCommandManager.literal("cache").then( - ClientCommandManager.literal("list").executes(CacheCommand.ListCommand.impl()) - ).then( - ClientCommandManager.literal("clear").executes(CacheCommand.ClearCommand.impl()) - ) - ) - ); - } - - @Override - public LiteralCommandNode getCommandNode() - { - return hotbarsPlusCommand; - } -} diff --git a/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/manager/CustomToastManager.java b/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/manager/CustomToastManager.java deleted file mode 100644 index 621418e..0000000 --- a/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/manager/CustomToastManager.java +++ /dev/null @@ -1,117 +0,0 @@ -package me.videogamesm12.hotbarsplus.v1_17.manager; - -import com.mojang.blaze3d.systems.RenderSystem; -import lombok.Getter; -import lombok.Setter; -import me.videogamesm12.hotbarsplus.api.manager.IToastManager; -import me.videogamesm12.hotbarsplus.core.universal.NotificationManager; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawableHelper; -import net.minecraft.client.toast.Toast; -import net.minecraft.client.toast.ToastManager; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.Text; - -public class CustomToastManager implements IToastManager -{ - @Override - public HotbarToast getToastFrom(NotificationManager.NotificationType type, Text... texts) - { - Text title; - Text description; - - switch (texts.length) - { - case 0: - { - throw new IllegalArgumentException("Fuck you"); - } - case 1: - { - title = texts[0]; - description = null; - break; - } - default: - case 2: - { - title = texts[0]; - description = texts[1]; - break; - } - } - - return new HotbarToast(title, description, type); - } - - @Override - public void showToast(IHotbarToast toast) - { - HotbarToast instance = MinecraftClient.getInstance().getToastManager().getToast(HotbarToast.class, toast.getType()); - if (instance == null) - { - MinecraftClient.getInstance().getToastManager().add((HotbarToast) toast); - } - else - { - HotbarToast hToast = (HotbarToast) toast; - //-- - instance.setTitle(hToast.getTitle()); - instance.setDescription(hToast.getDescription()); - instance.setJustUpdated(true); - } - } - - @Getter - @Setter - public static class HotbarToast implements IHotbarToast, Toast - { - private Text title; - private Text description; - //-- - private NotificationManager.NotificationType type; - private long time; - //-- - private boolean justUpdated = true; - - public HotbarToast(Text title, Text description, NotificationManager.NotificationType type) - { - this.title = title; - this.description = description; - this.type = type; - } - - @Override - public Visibility draw(MatrixStack stack, ToastManager manager, long currentTime) - { - if (justUpdated) - { - this.time = currentTime; - justUpdated = false; - } - - RenderSystem.setShaderTexture(0, IToastManager.TEXTURE); - RenderSystem.setShaderColor(1F, 1F, 1F, 1F); - - DrawableHelper.drawTexture(stack, 0, 0, 0, 20, 160, 32, 160, 52); - //-- - DrawableHelper.drawTexture(stack, 6, 6, 20 * type.ordinal(), 0, 20, 20, 160, 52); - //-- - int titleY = description == null ? 12 : 7; - MinecraftClient.getInstance().textRenderer.draw(stack, title.getString(), 30, titleY, type.getColor()); - - if (description != null) - { - MinecraftClient.getInstance().textRenderer.draw(stack, description.asString(), 30, 18, 0xFFFFFF); - } - - return currentTime - time >= 5000 ? Visibility.HIDE : Visibility.SHOW; - } - - @Override - public NotificationManager.NotificationType getType() - { - return type; - } - } -} diff --git a/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/manager/KeybindManager.java b/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/manager/KeybindManager.java deleted file mode 100644 index 8c104f5..0000000 --- a/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/manager/KeybindManager.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_17.manager; - -import me.videogamesm12.hotbarsplus.api.manager.IKeybindManager; -import me.videogamesm12.hotbarsplus.api.event.keybind.BackupBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.NextBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.PreviousBindPressEvent; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; -import org.lwjgl.glfw.GLFW; - -public class KeybindManager implements IKeybindManager, ClientTickEvents.EndTick -{ - public KeyBinding backup = new KeyBinding("key.hotbarsplus.backup", InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_UNKNOWN, "category.hotbarsplus.navigation"); - public KeyBinding next = new KeyBinding("key.hotbarsplus.next", InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_RIGHT_BRACKET, "category.hotbarsplus.navigation"); - public KeyBinding previous = new KeyBinding("key.hotbarsplus.previous", InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_LEFT_BRACKET, "category.hotbarsplus.navigation"); - - public KeybindManager() - { - registerKeybinds(); - } - - @Override - public void registerKeybinds() - { - backup = KeyBindingHelper.registerKeyBinding(backup); - next = KeyBindingHelper.registerKeyBinding(next); - previous = KeyBindingHelper.registerKeyBinding(previous); - //-- - ClientTickEvents.END_CLIENT_TICK.register(this); - } - - @Override - public void onEndTick(MinecraftClient client) - { - if (backup.wasPressed()) - { - BackupBindPressEvent.EVENT.invoker().onBackupPress(); - } - - if (next.wasPressed()) - { - NextBindPressEvent.EVENT.invoker().onNextPress(); - } - else if (previous.wasPressed()) - { - PreviousBindPressEvent.EVENT.invoker().onPreviousPress(); - } - } -} diff --git a/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/mixin/CreativeInvScreenMixin.java b/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/mixin/CreativeInvScreenMixin.java deleted file mode 100644 index ede5492..0000000 --- a/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/mixin/CreativeInvScreenMixin.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_17.mixin; - -import me.videogamesm12.hotbarsplus.api.event.keybind.BackupBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.NextBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.PreviousBindPressEvent; -import me.videogamesm12.hotbarsplus.core.HBPCore; -import me.videogamesm12.hotbarsplus.core.gui.CustomButtons; -import me.videogamesm12.hotbarsplus.v1_17.manager.KeybindManager; -import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen; -import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemGroup; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.gen.Invoker; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(CreativeInventoryScreen.class) -public abstract class CreativeInvScreenMixin extends AbstractInventoryScreen - implements HSAccessor -{ - @Shadow public abstract int getSelectedTab(); - - @Shadow private boolean ignoreTypedCharacter; - public CustomButtons.NextButton next; - public CustomButtons.BackupButton backup; - public CustomButtons.PreviousButton previous; - - public CreativeInvScreenMixin(CreativeInventoryScreen.CreativeScreenHandler screenHandler, PlayerInventory playerInventory, Text text) - { - super(screenHandler, playerInventory, text); - } - - @Inject(method = "init", at = @At("RETURN")) - public void injInit(CallbackInfo ci) - { - // Offset - int x = this.getX() + 159; - int y = this.getY() + 4; - - // Initialize buttons - this.next = new CustomButtons.NextButton(x + 16, y); - this.backup = new CustomButtons.BackupButton(x, y); - this.previous = new CustomButtons.PreviousButton(x - 16, y); - - // Modify buttons to adjust for the currently selected tab - if (getSelectedTab() != ItemGroup.HOTBAR.getIndex()) - { - next.visible = false; - backup.visible = false; - previous.visible = false; - } - - // Regardless of the current tab, disable this button if the selected hotbar file doesn't exist - backup.active = HBPCore.UPL.hotbarPageExists(); - - // Adding buttons - addDrawableChild(next); - addDrawableChild(backup); - addDrawableChild(previous); - } - - @Inject(method = "setSelectedTab", at = @At("HEAD")) - public void injSetCreativeTab(ItemGroup group, CallbackInfo ci) - { - if (next != null && backup != null && previous != null) - { - if (group == ItemGroup.HOTBAR) - { - next.visible = true; - backup.visible = true; - previous.visible = true; - } - else - { - next.visible = false; - backup.visible = false; - previous.visible = false; - } - - backup.active = HBPCore.UPL.hotbarPageExists(); - } - } - - @Inject(method = "keyPressed", at = @At(value = "HEAD", shift = At.Shift.AFTER), cancellable = true) - public void injectKeyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable cir) - { - if (getSelectedTab() == ItemGroup.HOTBAR.getIndex()) - { - KeybindManager manager = (KeybindManager) HBPCore.KEYBINDS; - - if (manager.next.matchesKey(keyCode, scanCode)) - { - NextBindPressEvent.EVENT.invoker().onNextPress(); - ignoreTypedCharacter = true; - cir.setReturnValue(true); - } - else if (manager.backup.matchesKey(keyCode, scanCode)) - { - BackupBindPressEvent.EVENT.invoker().onBackupPress(); - ignoreTypedCharacter = true; - cir.setReturnValue(true); - } - else if (manager.previous.matchesKey(keyCode, scanCode)) - { - PreviousBindPressEvent.EVENT.invoker().onPreviousPress(); - ignoreTypedCharacter = true; - cir.setReturnValue(true); - } - } - } - - @Mixin(CreativeInventoryScreen.class) - public interface CISAccessor - { - @Invoker("setSelectedTab") - void setSelectedTab(ItemGroup group); - } -} \ No newline at end of file diff --git a/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/mixin/HSAccessor.java b/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/mixin/HSAccessor.java deleted file mode 100644 index 3943828..0000000 --- a/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/mixin/HSAccessor.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_17.mixin; - -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(HandledScreen.class) -public interface HSAccessor -{ - @Accessor("x") - int getX(); - - @Accessor("y") - int getY(); -} diff --git a/1_17/src/main/resources/assets/hotbarsplus-1_17/icon.png b/1_17/src/main/resources/assets/hotbarsplus-1_17/icon.png deleted file mode 100644 index bb6c7fb..0000000 Binary files a/1_17/src/main/resources/assets/hotbarsplus-1_17/icon.png and /dev/null differ diff --git a/1_17/src/main/resources/fabric.mod.json b/1_17/src/main/resources/fabric.mod.json deleted file mode 100644 index c828494..0000000 --- a/1_17/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "schemaVersion": 1, - "id": "hotbarsplus-1_17", - "version": "${version}", - "name": "Hooks for 1.17.x/1.18.x", - "description": "Hooks specific to 1.17.x/1.18.x for Hotbars+.", - "authors": ["videogamesm12"], - "contact": { - "issues": "https://github.com/VideoGameSmash12/HotbarsPlus/issues", - "homepage": "https://github.com/VideoGameSmash12/HotbarsPlus", - "sources": "https://github.com/VideoGameSmash12/HotbarsPlus" - }, - "license": "MIT", - "icon": "assets/hotbarsplus-1_17/icon.png", - "environment": "client", - "entrypoints": { - "client": [ - "me.videogamesm12.hotbarsplus.v1_17.HotbarsPlus" - ] - }, - "mixins": [ - "hotbarsplus.1_17.mixins.json" - ], - "depends": { - "minecraft": ["1.17.x", "1.18.x"] - }, - "custom": { - "modmenu": { - "badges": ["library"], - "parent": "hotbarsplus" - } - } -} diff --git a/1_17/src/main/resources/hotbarsplus.1_17.mixins.json b/1_17/src/main/resources/hotbarsplus.1_17.mixins.json deleted file mode 100644 index eafdf00..0000000 --- a/1_17/src/main/resources/hotbarsplus.1_17.mixins.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.videogamesm12.hotbarsplus.v1_17.mixin", - "compatibilityLevel": "JAVA_8", - "mixins": [ - "CreativeInvScreenMixin", - "CreativeInvScreenMixin$CISAccessor", - "HSAccessor" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/1_19/build.gradle b/1_19/build.gradle deleted file mode 100644 index 92d6dfd..0000000 --- a/1_19/build.gradle +++ /dev/null @@ -1,7 +0,0 @@ -group 'me.videogamesm12' - -dependencies { - minecraft "com.mojang:minecraft:1.19" - mappings "net.fabricmc:yarn:1.19+build.2:v2" - modImplementation "net.fabricmc.fabric-api:fabric-api:0.56.0+1.19" -} \ No newline at end of file diff --git a/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/HotbarsPlus.java b/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/HotbarsPlus.java deleted file mode 100644 index 43164e3..0000000 --- a/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/HotbarsPlus.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_19; - -import me.videogamesm12.hotbarsplus.api.event.navigation.HotbarNavigateEvent; -import me.videogamesm12.hotbarsplus.core.HBPCore; -import me.videogamesm12.hotbarsplus.v1_19.manager.CommandManager; -import me.videogamesm12.hotbarsplus.v1_19.manager.CustomToastManager; -import me.videogamesm12.hotbarsplus.v1_19.manager.KeybindManager; -import me.videogamesm12.hotbarsplus.v1_19.mixin.CreativeInvScreenMixin; -import net.fabricmc.api.ClientModInitializer; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; -import net.minecraft.item.ItemGroup; -import net.minecraft.util.ActionResult; - -import java.math.BigInteger; - -public class HotbarsPlus implements ClientModInitializer, HotbarNavigateEvent -{ - @Override - public void onInitializeClient() - { - HBPCore.COMMANDS = new CommandManager(); - HBPCore.KEYBINDS = new KeybindManager(); - HBPCore.TOASTS = new CustomToastManager(); - //-- - HotbarNavigateEvent.EVENT.register(this); - } - - @Override - public ActionResult onNavigate(BigInteger page) - { - // Refreshes the menu if it is currently open; - if (MinecraftClient.getInstance().currentScreen instanceof CreativeInventoryScreen) - { - Screen screen = MinecraftClient.getInstance().currentScreen; - - if (((CreativeInventoryScreen) screen).getSelectedTab() == ItemGroup.HOTBAR.getIndex()) - { - ((CreativeInvScreenMixin.CISAccessor) screen).setSelectedTab(ItemGroup.HOTBAR); - } - } - - return ActionResult.PASS; - } -} diff --git a/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/gui/CustomButtons.java b/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/gui/CustomButtons.java deleted file mode 100644 index acb2369..0000000 --- a/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/gui/CustomButtons.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_19.gui; - -import me.videogamesm12.hotbarsplus.api.util.Util; -import me.videogamesm12.hotbarsplus.core.HBPCore; -import net.kyori.adventure.key.Key; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.Style; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.text.Text; - -public class CustomButtons -{ - public static class BackupButton extends ButtonWidget - { - public static Text label = Util.advToNative(Component.text("\uD83D\uDCBE").style(Style.style().font( - Key.key("hotbarsplus", "default")).build())); - - public BackupButton(int x, int y) - { - super(x, y, 16, 12, label, - (button) -> HBPCore.UBL.backupHotbar(), - (button, stack, mx, my) -> Util.advToNative(Component.translatable("gui.hotbarsplus.cis.backup_button.tooltip"))); - } - } - - public static class NextButton extends ButtonWidget - { - public NextButton(int x, int y) - { - super(x, y, 16, 12, Util.advToNative(Component.text("→")), (button) -> HBPCore.UPL.incrementPage(), - (button, stack, mx, my) -> Util.advToNative(Component.translatable("gui.hotbarsplus.cis.next_button.tooltip"))); - } - } - - public static class PreviousButton extends ButtonWidget - { - public PreviousButton(int x, int y) - { - super(x, y, 16, 12, Util.advToNative(Component.text("←")), (button) -> HBPCore.UPL.decrementPage(), - (button, stack, mx, my) -> Util.advToNative(Component.translatable("gui.hotbarsplus.cis.previous_button.tooltip"))); - } - } -} diff --git a/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CommandManager.java b/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CommandManager.java deleted file mode 100644 index c63949c..0000000 --- a/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CommandManager.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_19.manager; - -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.LongArgumentType; -import com.mojang.brigadier.tree.LiteralCommandNode; -import me.videogamesm12.hotbarsplus.api.manager.ICommandManager; -import me.videogamesm12.hotbarsplus.core.commands.*; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; -import net.minecraft.command.CommandRegistryAccess; - -public class CommandManager implements ICommandManager, ClientCommandRegistrationCallback -{ - private LiteralCommandNode hotbarsPlusCommand; - - public CommandManager() - { - ClientCommandRegistrationCallback.EVENT.register(this); - } - - @Override - public void register() - { - // Unused, Fabric API v2 removed the original method of registering commands - } - - @Override - public LiteralCommandNode getCommandNode() - { - return hotbarsPlusCommand; - } - - @Override - public void register(CommandDispatcher dispatcher, CommandRegistryAccess registryAccess) - { - hotbarsPlusCommand = dispatcher.register( - ClientCommandManager.literal("hotbars+").then( - ClientCommandManager.literal("backup").executes(BackupCommand.impl()) - ).then( - ClientCommandManager.literal("next").executes(NextCommand.impl()) - ).then( - ClientCommandManager.literal("previous").executes(PreviousCommand.impl()) - ).then( - ClientCommandManager.literal("goto").then( - ClientCommandManager.argument("page", LongArgumentType.longArg()).executes(GoToCommand.impl()) - ) - ).then( - ClientCommandManager.literal("cache").then( - ClientCommandManager.literal("list").executes(CacheCommand.ListCommand.impl()) - ).then( - ClientCommandManager.literal("clear").executes(CacheCommand.ClearCommand.impl()) - ) - ) - ); - } -} diff --git a/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CustomToastManager.java b/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CustomToastManager.java deleted file mode 100644 index a3f17fa..0000000 --- a/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CustomToastManager.java +++ /dev/null @@ -1,117 +0,0 @@ -package me.videogamesm12.hotbarsplus.v1_19.manager; - -import com.mojang.blaze3d.systems.RenderSystem; -import lombok.Getter; -import lombok.Setter; -import me.videogamesm12.hotbarsplus.api.manager.IToastManager; -import me.videogamesm12.hotbarsplus.core.universal.NotificationManager; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawableHelper; -import net.minecraft.client.toast.Toast; -import net.minecraft.client.toast.ToastManager; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.Text; - -public class CustomToastManager implements IToastManager -{ - @Override - public HotbarToast getToastFrom(NotificationManager.NotificationType type, Text... texts) - { - Text title; - Text description; - - switch (texts.length) - { - case 0: - { - throw new IllegalArgumentException("Fuck you"); - } - case 1: - { - title = texts[0]; - description = null; - break; - } - default: - case 2: - { - title = texts[0]; - description = texts[1]; - break; - } - } - - return new HotbarToast(title, description, type); - } - - @Override - public void showToast(IHotbarToast toast) - { - HotbarToast instance = MinecraftClient.getInstance().getToastManager().getToast(HotbarToast.class, toast.getType()); - if (instance == null) - { - MinecraftClient.getInstance().getToastManager().add((HotbarToast) toast); - } - else - { - HotbarToast hToast = (HotbarToast) toast; - //-- - instance.setTitle(hToast.getTitle()); - instance.setDescription(hToast.getDescription()); - instance.setJustUpdated(true); - } - } - - @Getter - @Setter - public static class HotbarToast implements IHotbarToast, Toast - { - private Text title; - private Text description; - //-- - private NotificationManager.NotificationType type; - private long time; - //-- - private boolean justUpdated = true; - - public HotbarToast(Text title, Text description, NotificationManager.NotificationType type) - { - this.title = title; - this.description = description; - this.type = type; - } - - @Override - public Visibility draw(MatrixStack stack, ToastManager manager, long currentTime) - { - if (justUpdated) - { - this.time = currentTime; - justUpdated = false; - } - - RenderSystem.setShaderTexture(0, IToastManager.TEXTURE); - RenderSystem.setShaderColor(1F, 1F, 1F, 1F); - - DrawableHelper.drawTexture(stack, 0, 0, 0, 20, 160, 32, 160, 52); - //-- - DrawableHelper.drawTexture(stack, 6, 6, 20 * type.ordinal(), 0, 20, 20, 160, 52); - //-- - int titleY = description == null ? 12 : 7; - MinecraftClient.getInstance().textRenderer.draw(stack, title.getString(), 30, titleY, type.getColor()); - - if (description != null) - { - MinecraftClient.getInstance().textRenderer.draw(stack, description.getString(), 30, 18, 0xFFFFFF); - } - - return currentTime - time >= 5000 ? Visibility.HIDE : Visibility.SHOW; - } - - @Override - public NotificationManager.NotificationType getType() - { - return type; - } - } -} diff --git a/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/KeybindManager.java b/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/KeybindManager.java deleted file mode 100644 index 16c8576..0000000 --- a/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/KeybindManager.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_19.manager; - -import me.videogamesm12.hotbarsplus.api.manager.IKeybindManager; -import me.videogamesm12.hotbarsplus.api.event.keybind.BackupBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.NextBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.PreviousBindPressEvent; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; -import org.lwjgl.glfw.GLFW; - -public class KeybindManager implements IKeybindManager, ClientTickEvents.EndTick -{ - public KeyBinding backup = new KeyBinding("key.hotbarsplus.backup", InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_UNKNOWN, "category.hotbarsplus.navigation"); - public KeyBinding next = new KeyBinding("key.hotbarsplus.next", InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_RIGHT_BRACKET, "category.hotbarsplus.navigation"); - public KeyBinding previous = new KeyBinding("key.hotbarsplus.previous", InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_LEFT_BRACKET, "category.hotbarsplus.navigation"); - - public KeybindManager() - { - registerKeybinds(); - } - - @Override - public void registerKeybinds() - { - backup = KeyBindingHelper.registerKeyBinding(backup); - next = KeyBindingHelper.registerKeyBinding(next); - previous = KeyBindingHelper.registerKeyBinding(previous); - //-- - ClientTickEvents.END_CLIENT_TICK.register(this); - } - - @Override - public void onEndTick(MinecraftClient client) - { - if (backup.wasPressed()) - { - BackupBindPressEvent.EVENT.invoker().onBackupPress(); - } - - if (next.wasPressed()) - { - NextBindPressEvent.EVENT.invoker().onNextPress(); - } - else if (previous.wasPressed()) - { - PreviousBindPressEvent.EVENT.invoker().onPreviousPress(); - } - } -} diff --git a/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/CreativeInvScreenMixin.java b/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/CreativeInvScreenMixin.java deleted file mode 100644 index 2ce4cb3..0000000 --- a/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/CreativeInvScreenMixin.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_19.mixin; - -import me.videogamesm12.hotbarsplus.core.HBPCore; -import me.videogamesm12.hotbarsplus.v1_19.gui.CustomButtons; -import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen; -import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemGroup; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.gen.Invoker; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(CreativeInventoryScreen.class) -public abstract class CreativeInvScreenMixin extends AbstractInventoryScreen - implements HSAccessor -{ - @Shadow public abstract int getSelectedTab(); - - public CustomButtons.NextButton next; - public CustomButtons.BackupButton backup; - public CustomButtons.PreviousButton previous; - - public CreativeInvScreenMixin(CreativeInventoryScreen.CreativeScreenHandler screenHandler, PlayerInventory playerInventory, Text text) - { - super(screenHandler, playerInventory, text); - } - - @Inject(method = "init", at = @At("RETURN")) - public void injInit(CallbackInfo ci) - { - // Offset - int x = this.getX() + 159; - int y = this.getY() + 4; - - // Initialize buttons - this.next = new CustomButtons.NextButton(x + 16, y); - this.backup = new CustomButtons.BackupButton(x, y); - this.previous = new CustomButtons.PreviousButton(x - 16, y); - - // Modify buttons - if (getSelectedTab() != ItemGroup.HOTBAR.getIndex()) - { - next.visible = false; - backup.visible = false; - previous.visible = false; - } - - backup.active = HBPCore.UPL.hotbarPageExists(); - - // Adding buttons - addDrawableChild(next); - addDrawableChild(backup); - addDrawableChild(previous); - } - - @Inject(method = "setSelectedTab", at = @At("HEAD")) - public void injSetCreativeTab(ItemGroup group, CallbackInfo ci) - { - if (next != null && backup != null && previous != null) - { - if (group == ItemGroup.HOTBAR) - { - next.visible = true; - backup.visible = true; - previous.visible = true; - } - else - { - next.visible = false; - backup.visible = false; - previous.visible = false; - } - - backup.active = HBPCore.UPL.hotbarPageExists(); - } - } - - @Mixin(CreativeInventoryScreen.class) - public interface CISAccessor - { - @Invoker("setSelectedTab") - void setSelectedTab(ItemGroup group); - } -} \ No newline at end of file diff --git a/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/HSAccessor.java b/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/HSAccessor.java deleted file mode 100644 index 6127f1e..0000000 --- a/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/HSAccessor.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_19.mixin; - -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(HandledScreen.class) -public interface HSAccessor -{ - @Accessor("x") - public int getX(); - - @Accessor("y") - public int getY(); -} diff --git a/1_19/src/main/resources/fabric.mod.json b/1_19/src/main/resources/fabric.mod.json deleted file mode 100644 index 5ef1afa..0000000 --- a/1_19/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "schemaVersion": 1, - "id": "hotbarsplus-1_19", - "version": "${version}", - "name": "Hooks for 1.19+", - "description": "Hooks specific to 1.19+ for Hotbars+.", - "authors": ["videogamesm12"], - "contact": { - "issues": "https://github.com/VideoGameSmash12/HotbarsPlus/issues", - "homepage": "https://github.com/VideoGameSmash12/HotbarsPlus", - "sources": "https://github.com/VideoGameSmash12/HotbarsPlus" - }, - "license": "MIT", - "icon": "assets/hotbarsplus/icon.png", - "environment": "client", - "entrypoints": { - "client": [ - "me.videogamesm12.hotbarsplus.v1_19.HotbarsPlus" - ] - }, - "mixins": [ - "hotbarsplus.1_19.mixins.json" - ], - "depends": { - "fabricloader": ">=0.12.12", - "minecraft": ">=1.19 <1.19.3" - }, - "breaks": { - "multihotbar": "*" - }, - "custom": { - "modmenu": { - "badges": ["library"], - "parent": "hotbarsplus" - } - } -} diff --git a/1_19/src/main/resources/hotbarsplus.1_19.mixins.json b/1_19/src/main/resources/hotbarsplus.1_19.mixins.json deleted file mode 100644 index 8bc5328..0000000 --- a/1_19/src/main/resources/hotbarsplus.1_19.mixins.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.videogamesm12.hotbarsplus.v1_19.mixin", - "compatibilityLevel": "JAVA_8", - "mixins": [ - "CreativeInvScreenMixin", - "CreativeInvScreenMixin$CISAccessor", - "HSAccessor" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/1_19_3/build.gradle b/1_19_3/build.gradle deleted file mode 100644 index de41bd5..0000000 --- a/1_19_3/build.gradle +++ /dev/null @@ -1,7 +0,0 @@ -group 'me.videogamesm12' - -dependencies { - minecraft "com.mojang:minecraft:1.19.3" - mappings "net.fabricmc:yarn:1.19.3+build.5:v2" - modImplementation "net.fabricmc.fabric-api:fabric-api:0.74.0+1.19.3" -} \ No newline at end of file diff --git a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/HotbarsPlus.java b/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/HotbarsPlus.java deleted file mode 100644 index 8290cc2..0000000 --- a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/HotbarsPlus.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_19; - -import me.videogamesm12.hotbarsplus.api.event.navigation.HotbarNavigateEvent; -import me.videogamesm12.hotbarsplus.core.HBPCore; -import me.videogamesm12.hotbarsplus.v1_19.manager.CommandManager; -import me.videogamesm12.hotbarsplus.v1_19.manager.CustomToastManager; -import me.videogamesm12.hotbarsplus.v1_19.manager.KeybindManager; -import me.videogamesm12.hotbarsplus.v1_19.mixin.CreativeInvScreenAccessor; -import net.fabricmc.api.ClientModInitializer; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemGroups; -import net.minecraft.util.ActionResult; - -import java.math.BigInteger; - -public class HotbarsPlus implements ClientModInitializer, HotbarNavigateEvent -{ - @Override - public void onInitializeClient() - { - HBPCore.COMMANDS = new CommandManager(); - HBPCore.KEYBINDS = new KeybindManager(); - HBPCore.TOASTS = new CustomToastManager(); - //-- - HotbarNavigateEvent.EVENT.register(this); - } - - @Override - public ActionResult onNavigate(BigInteger page) - { - MinecraftClient client = MinecraftClient.getInstance(); - Screen openScreen = client.currentScreen; - - if (openScreen == null) - { - return ActionResult.PASS; - } - - // Refreshes the menu if it is currently open; - if (!(openScreen instanceof CreativeInventoryScreen)) { - return ActionResult.PASS; - } - - CreativeInventoryScreen creativeScreen = (CreativeInventoryScreen) openScreen; - CreativeInvScreenAccessor accessor = (CreativeInvScreenAccessor) creativeScreen; - ItemGroup currentTab = accessor.getSelectedTab(); - - if (currentTab != ItemGroups.HOTBAR) { - return ActionResult.PASS; - } - - accessor.invokeSetSelectedTab(ItemGroups.HOTBAR); - - return ActionResult.PASS; - } -} diff --git a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/gui/CustomButtons.java b/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/gui/CustomButtons.java deleted file mode 100644 index cbb330d..0000000 --- a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/gui/CustomButtons.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_19.gui; - -import me.videogamesm12.hotbarsplus.api.util.Util; -import me.videogamesm12.hotbarsplus.core.HBPCore; -import net.kyori.adventure.key.Key; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.Style; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.text.Text; - -public class CustomButtons -{ - public static class BackupButton extends ButtonWidget - { - private static final Text label = Util.advToNative(Component.text("\uD83D\uDCBE").style(Style.style().font( - Key.key("hotbarsplus", "default")).build())); - - public BackupButton(int x, int y) - { - super(x, y, 16, 12, label, - button -> HBPCore.UBL.backupHotbar(), - supplier -> Util.advToNative(Component.translatable("gui.hotbarsplus.cis.backup_button.tooltip")).copy()); - } - } - - public static class NextButton extends ButtonWidget - { - public NextButton(int x, int y) - { - super(x, y, 16, 12, Util.advToNative(Component.text("→")), - button -> HBPCore.UPL.incrementPage(), - supplier -> Util.advToNative(Component.translatable("gui.hotbarsplus.cis.next_button.tooltip")).copy()); - } - } - - public static class PreviousButton extends ButtonWidget - { - public PreviousButton(int x, int y) - { - super(x, y, 16, 12, Util.advToNative(Component.text("←")), - button -> HBPCore.UPL.decrementPage(), - supplier -> Util.advToNative(Component.translatable("gui.hotbarsplus.cis.previous_button.tooltip")).copy()); - } - } -} diff --git a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CommandManager.java b/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CommandManager.java deleted file mode 100644 index c63949c..0000000 --- a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CommandManager.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_19.manager; - -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.LongArgumentType; -import com.mojang.brigadier.tree.LiteralCommandNode; -import me.videogamesm12.hotbarsplus.api.manager.ICommandManager; -import me.videogamesm12.hotbarsplus.core.commands.*; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; -import net.minecraft.command.CommandRegistryAccess; - -public class CommandManager implements ICommandManager, ClientCommandRegistrationCallback -{ - private LiteralCommandNode hotbarsPlusCommand; - - public CommandManager() - { - ClientCommandRegistrationCallback.EVENT.register(this); - } - - @Override - public void register() - { - // Unused, Fabric API v2 removed the original method of registering commands - } - - @Override - public LiteralCommandNode getCommandNode() - { - return hotbarsPlusCommand; - } - - @Override - public void register(CommandDispatcher dispatcher, CommandRegistryAccess registryAccess) - { - hotbarsPlusCommand = dispatcher.register( - ClientCommandManager.literal("hotbars+").then( - ClientCommandManager.literal("backup").executes(BackupCommand.impl()) - ).then( - ClientCommandManager.literal("next").executes(NextCommand.impl()) - ).then( - ClientCommandManager.literal("previous").executes(PreviousCommand.impl()) - ).then( - ClientCommandManager.literal("goto").then( - ClientCommandManager.argument("page", LongArgumentType.longArg()).executes(GoToCommand.impl()) - ) - ).then( - ClientCommandManager.literal("cache").then( - ClientCommandManager.literal("list").executes(CacheCommand.ListCommand.impl()) - ).then( - ClientCommandManager.literal("clear").executes(CacheCommand.ClearCommand.impl()) - ) - ) - ); - } -} diff --git a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CustomToastManager.java b/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CustomToastManager.java deleted file mode 100644 index a3f17fa..0000000 --- a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CustomToastManager.java +++ /dev/null @@ -1,117 +0,0 @@ -package me.videogamesm12.hotbarsplus.v1_19.manager; - -import com.mojang.blaze3d.systems.RenderSystem; -import lombok.Getter; -import lombok.Setter; -import me.videogamesm12.hotbarsplus.api.manager.IToastManager; -import me.videogamesm12.hotbarsplus.core.universal.NotificationManager; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawableHelper; -import net.minecraft.client.toast.Toast; -import net.minecraft.client.toast.ToastManager; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.Text; - -public class CustomToastManager implements IToastManager -{ - @Override - public HotbarToast getToastFrom(NotificationManager.NotificationType type, Text... texts) - { - Text title; - Text description; - - switch (texts.length) - { - case 0: - { - throw new IllegalArgumentException("Fuck you"); - } - case 1: - { - title = texts[0]; - description = null; - break; - } - default: - case 2: - { - title = texts[0]; - description = texts[1]; - break; - } - } - - return new HotbarToast(title, description, type); - } - - @Override - public void showToast(IHotbarToast toast) - { - HotbarToast instance = MinecraftClient.getInstance().getToastManager().getToast(HotbarToast.class, toast.getType()); - if (instance == null) - { - MinecraftClient.getInstance().getToastManager().add((HotbarToast) toast); - } - else - { - HotbarToast hToast = (HotbarToast) toast; - //-- - instance.setTitle(hToast.getTitle()); - instance.setDescription(hToast.getDescription()); - instance.setJustUpdated(true); - } - } - - @Getter - @Setter - public static class HotbarToast implements IHotbarToast, Toast - { - private Text title; - private Text description; - //-- - private NotificationManager.NotificationType type; - private long time; - //-- - private boolean justUpdated = true; - - public HotbarToast(Text title, Text description, NotificationManager.NotificationType type) - { - this.title = title; - this.description = description; - this.type = type; - } - - @Override - public Visibility draw(MatrixStack stack, ToastManager manager, long currentTime) - { - if (justUpdated) - { - this.time = currentTime; - justUpdated = false; - } - - RenderSystem.setShaderTexture(0, IToastManager.TEXTURE); - RenderSystem.setShaderColor(1F, 1F, 1F, 1F); - - DrawableHelper.drawTexture(stack, 0, 0, 0, 20, 160, 32, 160, 52); - //-- - DrawableHelper.drawTexture(stack, 6, 6, 20 * type.ordinal(), 0, 20, 20, 160, 52); - //-- - int titleY = description == null ? 12 : 7; - MinecraftClient.getInstance().textRenderer.draw(stack, title.getString(), 30, titleY, type.getColor()); - - if (description != null) - { - MinecraftClient.getInstance().textRenderer.draw(stack, description.getString(), 30, 18, 0xFFFFFF); - } - - return currentTime - time >= 5000 ? Visibility.HIDE : Visibility.SHOW; - } - - @Override - public NotificationManager.NotificationType getType() - { - return type; - } - } -} diff --git a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/KeybindManager.java b/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/KeybindManager.java deleted file mode 100644 index 16c8576..0000000 --- a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/KeybindManager.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_19.manager; - -import me.videogamesm12.hotbarsplus.api.manager.IKeybindManager; -import me.videogamesm12.hotbarsplus.api.event.keybind.BackupBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.NextBindPressEvent; -import me.videogamesm12.hotbarsplus.api.event.keybind.PreviousBindPressEvent; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; -import org.lwjgl.glfw.GLFW; - -public class KeybindManager implements IKeybindManager, ClientTickEvents.EndTick -{ - public KeyBinding backup = new KeyBinding("key.hotbarsplus.backup", InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_UNKNOWN, "category.hotbarsplus.navigation"); - public KeyBinding next = new KeyBinding("key.hotbarsplus.next", InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_RIGHT_BRACKET, "category.hotbarsplus.navigation"); - public KeyBinding previous = new KeyBinding("key.hotbarsplus.previous", InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_LEFT_BRACKET, "category.hotbarsplus.navigation"); - - public KeybindManager() - { - registerKeybinds(); - } - - @Override - public void registerKeybinds() - { - backup = KeyBindingHelper.registerKeyBinding(backup); - next = KeyBindingHelper.registerKeyBinding(next); - previous = KeyBindingHelper.registerKeyBinding(previous); - //-- - ClientTickEvents.END_CLIENT_TICK.register(this); - } - - @Override - public void onEndTick(MinecraftClient client) - { - if (backup.wasPressed()) - { - BackupBindPressEvent.EVENT.invoker().onBackupPress(); - } - - if (next.wasPressed()) - { - NextBindPressEvent.EVENT.invoker().onNextPress(); - } - else if (previous.wasPressed()) - { - PreviousBindPressEvent.EVENT.invoker().onPreviousPress(); - } - } -} diff --git a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/CreativeInvScreenAccessor.java b/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/CreativeInvScreenAccessor.java deleted file mode 100644 index 6c392ac..0000000 --- a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/CreativeInvScreenAccessor.java +++ /dev/null @@ -1,17 +0,0 @@ -package me.videogamesm12.hotbarsplus.v1_19.mixin; - -import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; -import net.minecraft.item.ItemGroup; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; -import org.spongepowered.asm.mixin.gen.Invoker; - -@Mixin(CreativeInventoryScreen.class) -public interface CreativeInvScreenAccessor -{ - @Accessor("selectedTab") - ItemGroup getSelectedTab(); - - @Invoker - void invokeSetSelectedTab(ItemGroup group); -} diff --git a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/CreativeInvScreenMixin.java b/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/CreativeInvScreenMixin.java deleted file mode 100644 index 5806560..0000000 --- a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/CreativeInvScreenMixin.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.v1_19.mixin; - -import me.videogamesm12.hotbarsplus.core.HBPCore; -import me.videogamesm12.hotbarsplus.v1_19.gui.CustomButtons; -import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen; -import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemGroups; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(CreativeInventoryScreen.class) -public abstract class CreativeInvScreenMixin extends AbstractInventoryScreen - implements CreativeInvScreenAccessor, HandledScreenAccessor -{ - public CustomButtons.NextButton next; - public CustomButtons.BackupButton backup; - public CustomButtons.PreviousButton previous; - - public CreativeInvScreenMixin(CreativeInventoryScreen.CreativeScreenHandler screenHandler, PlayerInventory playerInventory, Text text) - { - super(screenHandler, playerInventory, text); - } - - @Inject(method = "init", at = @At("RETURN")) - public void injInit(CallbackInfo ci) - { - // Offset - int x = this.getX() + 159; - int y = this.getY() + 4; - - // Initialize buttons - this.next = new CustomButtons.NextButton(x + 16, y); - this.backup = new CustomButtons.BackupButton(x, y); - this.previous = new CustomButtons.PreviousButton(x - 16, y); - - // Modify buttons - if (getSelectedTab() != ItemGroups.HOTBAR) - { - next.visible = false; - backup.visible = false; - previous.visible = false; - } - - backup.active = HBPCore.UPL.hotbarPageExists(); - - // Adding buttons - addDrawableChild(next); - addDrawableChild(backup); - addDrawableChild(previous); - } - - @Inject(method = "setSelectedTab", at = @At("HEAD")) - public void injSetCreativeTab(ItemGroup group, CallbackInfo ci) - { - if (next != null && backup != null && previous != null) - { - if (group == ItemGroups.HOTBAR) - { - next.visible = true; - backup.visible = true; - previous.visible = true; - } - else - { - next.visible = false; - backup.visible = false; - previous.visible = false; - } - - backup.active = HBPCore.UPL.hotbarPageExists(); - } - } -} \ No newline at end of file diff --git a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/HandledScreenAccessor.java b/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/HandledScreenAccessor.java deleted file mode 100644 index e8bb9b2..0000000 --- a/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/HandledScreenAccessor.java +++ /dev/null @@ -1,14 +0,0 @@ -package me.videogamesm12.hotbarsplus.v1_19.mixin; - -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(HandledScreen.class) -public interface HandledScreenAccessor { - @Accessor("x") - int getX(); - - @Accessor("y") - int getY(); -} diff --git a/1_19_3/src/main/resources/fabric.mod.json b/1_19_3/src/main/resources/fabric.mod.json deleted file mode 100644 index a7d8ba2..0000000 --- a/1_19_3/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "schemaVersion": 1, - "id": "hotbarsplus-1_19_3", - "version": "${version}", - "name": "Hooks for 1.19.3+", - "description": "Hooks specific to 1.19.3 - 1.19.4 for Hotbars+.", - "authors": ["videogamesm12"], - "contact": { - "issues": "https://github.com/VideoGameSmash12/HotbarsPlus/issues", - "homepage": "https://github.com/VideoGameSmash12/HotbarsPlus", - "sources": "https://github.com/VideoGameSmash12/HotbarsPlus" - }, - "license": "MIT", - "icon": "assets/hotbarsplus/icon.png", - "environment": "client", - "entrypoints": { - "client": [ - "me.videogamesm12.hotbarsplus.v1_19.HotbarsPlus" - ] - }, - "mixins": [ - "hotbarsplus.1_19.mixins.json" - ], - "depends": { - "fabricloader": ">=0.12.12", - "minecraft": ["1.19.3", "1.19.4"] - }, - "breaks": { - "multihotbar": "*" - }, - "custom": { - "modmenu": { - "badges": ["library"], - "parent": "hotbarsplus" - } - } -} diff --git a/1_19_3/src/main/resources/hotbarsplus.1_19.mixins.json b/1_19_3/src/main/resources/hotbarsplus.1_19.mixins.json deleted file mode 100644 index 6530f82..0000000 --- a/1_19_3/src/main/resources/hotbarsplus.1_19.mixins.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.videogamesm12.hotbarsplus.v1_19.mixin", - "compatibilityLevel": "JAVA_8", - "mixins": [ - "CreativeInvScreenMixin" - ], - "injectors": { - "defaultRequire": 1 - }, - "client": [ - "CreativeInvScreenAccessor", - "HandledScreenAccessor" - ] -} diff --git a/1_20/build.gradle b/1_20/build.gradle index 56ad951..89d3387 100644 --- a/1_20/build.gradle +++ b/1_20/build.gradle @@ -1,7 +1,7 @@ group 'me.videogamesm12' dependencies { - minecraft "com.mojang:minecraft:1.20" - mappings "net.fabricmc:yarn:1.20+build.1:v2" - modImplementation "net.fabricmc.fabric-api:fabric-api:0.83.0+1.20" + minecraft "com.mojang:minecraft:1.20.3" + mappings "net.fabricmc:yarn:1.20.3+build.1:v2" + modImplementation "net.fabricmc.fabric-api:fabric-api:0.91.1+1.20.3" } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 923f8b1..a4f6410 100644 --- a/build.gradle +++ b/build.gradle @@ -13,10 +13,10 @@ repositories { } dependencies { - minecraft "com.mojang:minecraft:1.17.1" - mappings "net.fabricmc:yarn:1.17.1+build.65:v2" + minecraft "com.mojang:minecraft:1.20.3" + mappings "net.fabricmc:yarn:1.20.3+build.1:v2" - modImplementation "net.fabricmc.fabric-api:fabric-api:0.46.0+1.17" + modImplementation "net.fabricmc.fabric-api:fabric-api:0.91.1+1.20.3" // Text components implementation include("net.kyori:adventure-text-serializer-gson:4.9.3") diff --git a/readme.md b/readme.md index e9951af..e243e24 100644 --- a/readme.md +++ b/readme.md @@ -7,13 +7,8 @@ The mod works by hijacking the saved hotbar system Minecraft uses to use a diffe ### What is required to use the mod? The requirements depend on the version of Minecraft you're using. To help guide you, here's a table: -| Version | Fabric Loader | Fabric API | Cotton Client Commands | -|--------------------| ------------- | ---------- | ---------------------- | -| 1.14.4 - 1.15.x | Yes | Yes | Optional* | -| 1.16.1 - 1.16.4 | Yes | Yes | Optional* | -| 1.16.5 | Yes | Yes | No | -| 1.17.x - 1.18.2 | Yes | Yes | No | -| 1.19 - 1.19.4 | Yes | Yes | No | -| 1.20 - 1.20.2 | Yes | Yes | No | +| Version | Fabric Loader | Fabric API | Cotton Client Commands | +|-----------------| ------------- | ---------- | ---------------------- | +| 1.20.3 - 1.20.4 | Yes | Yes | No | \* = The mod will still launch without it, but you won't be able to run client-side commands like /hotbars+. diff --git a/settings.gradle b/settings.gradle index 797679e..9b66489 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,9 +8,4 @@ pluginManagement { } } rootProject.name = 'Hotbars+' -include '1_14' -include '1_16' -include '1_17' -include '1_19' -include '1_19_3' include '1_20' diff --git a/src/main/java/me/videogamesm12/hotbarsplus/api/util/Util.java b/src/main/java/me/videogamesm12/hotbarsplus/api/util/Util.java index 1e13ca6..ca77918 100644 --- a/src/main/java/me/videogamesm12/hotbarsplus/api/util/Util.java +++ b/src/main/java/me/videogamesm12/hotbarsplus/api/util/Util.java @@ -66,11 +66,7 @@ public static String getHotbarFilename(BigInteger page) public static Text advToNative(Component component) { JsonElement element = kyori.serializeToTree(component); - - if (HBPCore.VHOOKS != null) - return HBPCore.VHOOKS.convertFromJson(element); - else - return Text.Serializer.fromJson(element); + return Text.Serialization.fromJsonTree(element); } public static void msg(Component component) diff --git a/src/main/java/me/videogamesm12/hotbarsplus/core/HotbarsPlusStorage.java b/src/main/java/me/videogamesm12/hotbarsplus/core/HotbarsPlusStorage.java index b1992ce..b2e0034 100644 --- a/src/main/java/me/videogamesm12/hotbarsplus/core/HotbarsPlusStorage.java +++ b/src/main/java/me/videogamesm12/hotbarsplus/core/HotbarsPlusStorage.java @@ -32,6 +32,6 @@ public class HotbarsPlusStorage extends HotbarStorage implements IHotbarsPlusSto public HotbarsPlusStorage(BigInteger page) { - super(Util.getHotbarFile(page), MinecraftClient.getInstance().getDataFixer()); + super(Util.getHotbarFile(page).toPath(), MinecraftClient.getInstance().getDataFixer()); } } diff --git a/src/main/java/me/videogamesm12/hotbarsplus/core/gui/CustomButtons.java b/src/main/java/me/videogamesm12/hotbarsplus/core/gui/CustomButtons.java deleted file mode 100644 index f4ff18b..0000000 --- a/src/main/java/me/videogamesm12/hotbarsplus/core/gui/CustomButtons.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2022 Video - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights 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: - * - * The above copyright notice and this permission notice shall be included in all 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. - */ - -package me.videogamesm12.hotbarsplus.core.gui; - -import me.videogamesm12.hotbarsplus.core.HBPCore; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.text.LiteralText; -import net.minecraft.text.Style; -import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; -import net.minecraft.util.Identifier; - -public class CustomButtons -{ - public static class BackupButton extends ButtonWidget - { - public static Text label = new LiteralText("\uD83D\uDCBE").setStyle(Style.EMPTY.withFont( - new Identifier("hotbarsplus", "default"))); - - public BackupButton(int x, int y) - { - super(x, y, 16, 12, label, - (button) -> HBPCore.UBL.backupHotbar(), - (button, stack, mx, my) -> new TranslatableText("gui.hotbarsplus.cis.backup_button.tooltip")); - } - } - - public static class NextButton extends ButtonWidget - { - public NextButton(int x, int y) - { - super(x, y, 16, 12, new LiteralText("→"), (button) -> HBPCore.UPL.incrementPage(), - (button, stack, mx, my) -> new TranslatableText("gui.hotbarsplus.cis.next_button.tooltip")); - } - } - - public static class PreviousButton extends ButtonWidget - { - public PreviousButton(int x, int y) - { - super(x, y, 16, 12, new LiteralText("←"), (button) -> HBPCore.UPL.decrementPage(), - (button, stack, mx, my) -> new TranslatableText("gui.hotbarsplus.cis.previous_button.tooltip")); - } - } -} diff --git a/src/main/java/me/videogamesm12/hotbarsplus/core/mixin/HotbarStorageMixin.java b/src/main/java/me/videogamesm12/hotbarsplus/core/mixin/HotbarStorageMixin.java index 5e2f9c1..ec68e6d 100644 --- a/src/main/java/me/videogamesm12/hotbarsplus/core/mixin/HotbarStorageMixin.java +++ b/src/main/java/me/videogamesm12/hotbarsplus/core/mixin/HotbarStorageMixin.java @@ -26,6 +26,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.io.File; +import java.nio.file.Path; /** * HotbarStorageMixin @@ -41,7 +42,7 @@ public class HotbarStorageMixin * @param file File */ @Inject(method = "", at = @At(value = "TAIL")) - private void inject(File file, DataFixer dataFixer, CallbackInfo ci) + private void inject(Path file, DataFixer dataFixer, CallbackInfo ci) { if (HotbarsPlusStorage.class.isAssignableFrom(getClass())) { @@ -53,9 +54,9 @@ private void inject(File file, DataFixer dataFixer, CallbackInfo ci) public interface HSAccessor { @Accessor - File getFile(); + Path getFile(); @Accessor - void setFile(File file); + void setFile(Path file); } } \ No newline at end of file diff --git a/src/main/java/me/videogamesm12/hotbarsplus/core/universal/BackupManager.java b/src/main/java/me/videogamesm12/hotbarsplus/core/universal/BackupManager.java index 246b711..5aa6b29 100644 --- a/src/main/java/me/videogamesm12/hotbarsplus/core/universal/BackupManager.java +++ b/src/main/java/me/videogamesm12/hotbarsplus/core/universal/BackupManager.java @@ -78,7 +78,7 @@ public synchronized void backupHotbar(File file) public synchronized void backupHotbar() { - backupHotbar(((HotbarStorageMixin.HSAccessor) HBPCore.UPL.getHotbarPage()).getFile()); + backupHotbar(((HotbarStorageMixin.HSAccessor) HBPCore.UPL.getHotbarPage()).getFile().toFile()); } public File getBackupFolder() diff --git a/src/main/java/me/videogamesm12/hotbarsplus/core/universal/PageManager.java b/src/main/java/me/videogamesm12/hotbarsplus/core/universal/PageManager.java index a21e67f..75caf09 100644 --- a/src/main/java/me/videogamesm12/hotbarsplus/core/universal/PageManager.java +++ b/src/main/java/me/videogamesm12/hotbarsplus/core/universal/PageManager.java @@ -88,7 +88,7 @@ public HotbarStorage getHotbarPage(BigInteger page) if (!cache.containsKey(page)) { HotbarStorage storage = page.equals(BigInteger.ZERO) ? - new HotbarStorage(MinecraftClient.getInstance().runDirectory, MinecraftClient.getInstance().getDataFixer()) : + new HotbarStorage(MinecraftClient.getInstance().runDirectory.toPath(), MinecraftClient.getInstance().getDataFixer()) : new HotbarsPlusStorage(page); cache.put(page, storage); @@ -104,7 +104,7 @@ public HotbarStorage getHotbarPage() public boolean hotbarPageExists() { - return ((HotbarStorageMixin.HSAccessor) getHotbarPage()).getFile().exists(); + return ((HotbarStorageMixin.HSAccessor) getHotbarPage()).getFile().toFile().exists(); } @Override diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 3d2de21..c5539b4 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -26,7 +26,7 @@ ], "depends": { "fabric": "*", - "minecraft": ">=1.14.4" + "minecraft": ">=1.20.3" }, "accessWidener": "hotbarsplus.accesswidener", "breaks": { diff --git a/src/main/resources/hotbarsplus.accesswidener b/src/main/resources/hotbarsplus.accesswidener index 513d963..4b17e94 100644 --- a/src/main/resources/hotbarsplus.accesswidener +++ b/src/main/resources/hotbarsplus.accesswidener @@ -1,2 +1,2 @@ accessWidener v1 named -mutable field net/minecraft/client/option/HotbarStorage file Ljava/io/File; \ No newline at end of file +mutable field net/minecraft/client/option/HotbarStorage file Ljava/nio/file/Path; \ No newline at end of file