├── jitpack.yml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── src
└── main
│ ├── resources
│ ├── assets
│ │ └── hotbarsplus
│ │ │ ├── icon.png
│ │ │ ├── textures
│ │ │ ├── toasts.png
│ │ │ └── font
│ │ │ │ └── backup_icon.png
│ │ │ ├── font
│ │ │ └── default.json
│ │ │ └── lang
│ │ │ └── en_us.json
│ ├── hotbarsplus.accesswidener
│ ├── hotbarsplus.mixin.json
│ └── fabric.mod.json
│ └── java
│ └── me
│ └── videogamesm12
│ └── hotbarsplus
│ ├── core
│ ├── notifications
│ │ ├── ToastNotification.java
│ │ └── ActionBarNotification.java
│ ├── commands
│ │ ├── NextCommand.java
│ │ ├── PreviousCommand.java
│ │ ├── GoToCommand.java
│ │ ├── BackupCommand.java
│ │ └── CacheCommand.java
│ ├── HotbarsPlusStorage.java
│ ├── provider
│ │ └── NotificationRouteProvider.java
│ ├── mixin
│ │ ├── MinecraftClientMixin.java
│ │ └── HotbarStorageMixin.java
│ ├── gui
│ │ └── CustomButtons.java
│ ├── HBPCore.java
│ └── universal
│ │ ├── BackupManager.java
│ │ ├── ConfigurationManager.java
│ │ └── PageManager.java
│ └── api
│ ├── manager
│ ├── IKeybindManager.java
│ ├── ICommandManager.java
│ └── IToastManager.java
│ ├── IHotbarsPlusStorage.java
│ ├── IVersionHook.java
│ ├── event
│ ├── keybind
│ │ ├── NextBindPressEvent.java
│ │ ├── BackupBindPressEvent.java
│ │ └── PreviousBindPressEvent.java
│ ├── notification
│ │ └── NotificationTypeRegistered.java
│ ├── failures
│ │ └── BackupFailEvent.java
│ ├── success
│ │ └── BackupSuccessEvent.java
│ └── navigation
│ │ └── HotbarNavigateEvent.java
│ ├── provider
│ └── INotificationRouteProvider.java
│ ├── util
│ └── Util.java
│ └── config
│ └── Configuration.java
├── 1_16
├── src
│ └── main
│ │ ├── resources
│ │ ├── assets
│ │ │ └── hotbarsplus-1_16
│ │ │ │ └── icon.png
│ │ ├── hotbarsplus.1_16.mixins.json
│ │ └── fabric.mod.json
│ │ └── java
│ │ └── me
│ │ └── videogamesm12
│ │ └── hotbarsplus
│ │ └── v1_16
│ │ ├── mixin
│ │ └── HSAccessor.java
│ │ ├── manager
│ │ ├── CommandManager.java
│ │ ├── KeybindManager.java
│ │ ├── FallbackCommandManager.java
│ │ └── CustomToastManager.java
│ │ └── HotbarsPlus.java
└── build.gradle
├── 1_17
├── src
│ └── main
│ │ ├── resources
│ │ ├── assets
│ │ │ └── hotbarsplus-1_17
│ │ │ │ └── icon.png
│ │ ├── hotbarsplus.1_17.mixins.json
│ │ └── fabric.mod.json
│ │ └── java
│ │ └── me
│ │ └── videogamesm12
│ │ └── hotbarsplus
│ │ └── v1_17
│ │ ├── mixin
│ │ └── HSAccessor.java
│ │ ├── HotbarsPlus.java
│ │ └── manager
│ │ ├── CommandManager.java
│ │ ├── KeybindManager.java
│ │ └── CustomToastManager.java
└── build.gradle
├── 1_14
├── src
│ └── main
│ │ ├── resources
│ │ ├── assets
│ │ │ └── hotbarsplus-legacy
│ │ │ │ └── icon.png
│ │ ├── hotbarsplus.legacy.mixins.json
│ │ └── fabric.mod.json
│ │ └── java
│ │ └── me
│ │ └── videogamesm12
│ │ └── hotbarsplus
│ │ └── legacy
│ │ ├── mixin
│ │ └── CSAccessor.java
│ │ ├── FourteenHooks.java
│ │ ├── gui
│ │ └── CustomButtons.java
│ │ ├── manager
│ │ ├── CommandManager.java
│ │ ├── KeybindManager.java
│ │ └── CustomToastManager.java
│ │ └── HotbarsPlus.java
└── build.gradle
├── 1_19
├── build.gradle
└── src
│ └── main
│ ├── resources
│ ├── hotbarsplus.1_19.mixins.json
│ └── fabric.mod.json
│ └── java
│ └── me
│ └── videogamesm12
│ └── hotbarsplus
│ └── v1_19
│ ├── mixin
│ └── HSAccessor.java
│ ├── gui
│ └── CustomButtons.java
│ ├── HotbarsPlus.java
│ └── manager
│ ├── KeybindManager.java
│ ├── CommandManager.java
│ └── CustomToastManager.java
├── 1_20
├── build.gradle
└── src
│ └── main
│ ├── resources
│ ├── hotbarsplus.1_20.mixins.json
│ └── fabric.mod.json
│ └── java
│ └── me
│ └── videogamesm12
│ └── hotbarsplus
│ └── v1_20
│ ├── mixin
│ ├── HandledScreenAccessor.java
│ ├── CreativeInvScreenAccessor.java
│ └── CreativeInvScreenMixin.java
│ ├── gui
│ └── CustomButtons.java
│ ├── manager
│ ├── KeybindManager.java
│ ├── CommandManager.java
│ └── CustomToastManager.java
│ └── HotbarsPlus.java
├── 1_19_3
├── build.gradle
└── src
│ └── main
│ ├── resources
│ ├── hotbarsplus.1_19.mixins.json
│ └── fabric.mod.json
│ └── java
│ └── me
│ └── videogamesm12
│ └── hotbarsplus
│ └── v1_19
│ ├── mixin
│ ├── HandledScreenAccessor.java
│ ├── CreativeInvScreenAccessor.java
│ └── CreativeInvScreenMixin.java
│ ├── gui
│ └── CustomButtons.java
│ ├── HotbarsPlus.java
│ └── manager
│ ├── KeybindManager.java
│ ├── CommandManager.java
│ └── CustomToastManager.java
├── settings.gradle
├── .gitignore
├── .github
└── workflows
│ └── gradle.yml
├── license.md
├── readme.md
└── gradlew.bat
/jitpack.yml:
--------------------------------------------------------------------------------
1 | jdk:
2 | - openjdk17
3 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx3G
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VideoGameSmash12/HotbarsPlus/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/src/main/resources/assets/hotbarsplus/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VideoGameSmash12/HotbarsPlus/HEAD/src/main/resources/assets/hotbarsplus/icon.png
--------------------------------------------------------------------------------
/src/main/resources/hotbarsplus.accesswidener:
--------------------------------------------------------------------------------
1 | accessWidener v1 named
2 | mutable field net/minecraft/client/option/HotbarStorage file Ljava/io/File;
--------------------------------------------------------------------------------
/1_16/src/main/resources/assets/hotbarsplus-1_16/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VideoGameSmash12/HotbarsPlus/HEAD/1_16/src/main/resources/assets/hotbarsplus-1_16/icon.png
--------------------------------------------------------------------------------
/1_17/src/main/resources/assets/hotbarsplus-1_17/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VideoGameSmash12/HotbarsPlus/HEAD/1_17/src/main/resources/assets/hotbarsplus-1_17/icon.png
--------------------------------------------------------------------------------
/src/main/resources/assets/hotbarsplus/textures/toasts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VideoGameSmash12/HotbarsPlus/HEAD/src/main/resources/assets/hotbarsplus/textures/toasts.png
--------------------------------------------------------------------------------
/1_14/src/main/resources/assets/hotbarsplus-legacy/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VideoGameSmash12/HotbarsPlus/HEAD/1_14/src/main/resources/assets/hotbarsplus-legacy/icon.png
--------------------------------------------------------------------------------
/src/main/resources/assets/hotbarsplus/textures/font/backup_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VideoGameSmash12/HotbarsPlus/HEAD/src/main/resources/assets/hotbarsplus/textures/font/backup_icon.png
--------------------------------------------------------------------------------
/1_19/build.gradle:
--------------------------------------------------------------------------------
1 | group 'me.videogamesm12'
2 |
3 | dependencies {
4 | minecraft "com.mojang:minecraft:1.19"
5 | mappings "net.fabricmc:yarn:1.19+build.2:v2"
6 | modImplementation "net.fabricmc.fabric-api:fabric-api:0.56.0+1.19"
7 | }
--------------------------------------------------------------------------------
/1_20/build.gradle:
--------------------------------------------------------------------------------
1 | group 'me.videogamesm12'
2 |
3 | dependencies {
4 | minecraft "com.mojang:minecraft:1.20"
5 | mappings "net.fabricmc:yarn:1.20+build.1:v2"
6 | modImplementation "net.fabricmc.fabric-api:fabric-api:0.83.0+1.20"
7 | }
--------------------------------------------------------------------------------
/1_17/build.gradle:
--------------------------------------------------------------------------------
1 | group 'me.videogamesm12'
2 |
3 | dependencies {
4 | minecraft "com.mojang:minecraft:1.17.1"
5 | mappings "net.fabricmc:yarn:1.17.1+build.65:v2"
6 | modImplementation "net.fabricmc.fabric-api:fabric-api:0.46.1+1.17"
7 | }
--------------------------------------------------------------------------------
/1_19_3/build.gradle:
--------------------------------------------------------------------------------
1 | group 'me.videogamesm12'
2 |
3 | dependencies {
4 | minecraft "com.mojang:minecraft:1.19.3"
5 | mappings "net.fabricmc:yarn:1.19.3+build.5:v2"
6 | modImplementation "net.fabricmc.fabric-api:fabric-api:0.74.0+1.19.3"
7 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | maven {
4 | name = 'Fabric'
5 | url = 'https://maven.fabricmc.net/'
6 | }
7 | gradlePluginPortal()
8 | }
9 | }
10 | rootProject.name = 'Hotbars+'
11 | include '1_14'
12 | include '1_16'
13 | include '1_17'
14 | include '1_19'
15 | include '1_19_3'
16 | include '1_20'
17 |
--------------------------------------------------------------------------------
/src/main/resources/assets/hotbarsplus/font/default.json:
--------------------------------------------------------------------------------
1 | {
2 | "providers":
3 | [
4 | {
5 | "type": "bitmap",
6 | "file": "hotbarsplus:font/backup_icon.png",
7 | "ascent": 7,
8 | "height": 9,
9 | "chars":
10 | [
11 | "\uD83D\uDCBE"
12 | ]
13 | }
14 | ]
15 | }
--------------------------------------------------------------------------------
/src/main/resources/hotbarsplus.mixin.json:
--------------------------------------------------------------------------------
1 | {
2 | "required": true,
3 | "minVersion": "0.8",
4 | "package": "me.videogamesm12.hotbarsplus.core.mixin",
5 | "compatibilityLevel": "JAVA_8",
6 | "mixins": [
7 | "HotbarStorageMixin",
8 | "HotbarStorageMixin$HSAccessor",
9 | "MinecraftClientMixin"
10 | ],
11 | "injectors": {
12 | "defaultRequire": 1
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/1_17/src/main/resources/hotbarsplus.1_17.mixins.json:
--------------------------------------------------------------------------------
1 | {
2 | "required": true,
3 | "minVersion": "0.8",
4 | "package": "me.videogamesm12.hotbarsplus.v1_17.mixin",
5 | "compatibilityLevel": "JAVA_8",
6 | "mixins": [
7 | "CreativeInvScreenMixin",
8 | "CreativeInvScreenMixin$CISAccessor",
9 | "HSAccessor"
10 | ],
11 | "injectors": {
12 | "defaultRequire": 1
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/1_19/src/main/resources/hotbarsplus.1_19.mixins.json:
--------------------------------------------------------------------------------
1 | {
2 | "required": true,
3 | "minVersion": "0.8",
4 | "package": "me.videogamesm12.hotbarsplus.v1_19.mixin",
5 | "compatibilityLevel": "JAVA_8",
6 | "mixins": [
7 | "CreativeInvScreenMixin",
8 | "CreativeInvScreenMixin$CISAccessor",
9 | "HSAccessor"
10 | ],
11 | "injectors": {
12 | "defaultRequire": 1
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/1_20/src/main/resources/hotbarsplus.1_20.mixins.json:
--------------------------------------------------------------------------------
1 | {
2 | "required": true,
3 | "minVersion": "0.8",
4 | "package": "me.videogamesm12.hotbarsplus.v1_20.mixin",
5 | "compatibilityLevel": "JAVA_8",
6 | "mixins": [],
7 | "injectors": {
8 | "defaultRequire": 1
9 | },
10 | "client": [
11 | "CreativeInvScreenAccessor",
12 | "HandledScreenAccessor",
13 | "CreativeInvScreenMixin"
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/1_16/src/main/resources/hotbarsplus.1_16.mixins.json:
--------------------------------------------------------------------------------
1 | {
2 | "required": true,
3 | "minVersion": "0.8",
4 | "package": "me.videogamesm12.hotbarsplus.v1_16.mixin",
5 | "compatibilityLevel": "JAVA_8",
6 | "mixins": [
7 | "CreativeInvScreenMixin",
8 | "CreativeInvScreenMixin$CISAccessor",
9 | "HSAccessor"
10 | ],
11 | "client": [
12 | ],
13 | "injectors": {
14 | "defaultRequire": 1
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/1_14/src/main/resources/hotbarsplus.legacy.mixins.json:
--------------------------------------------------------------------------------
1 | {
2 | "required": true,
3 | "minVersion": "0.8",
4 | "package": "me.videogamesm12.hotbarsplus.legacy.mixin",
5 | "compatibilityLevel": "JAVA_8",
6 | "mixins": [
7 | ],
8 | "client": [
9 | "CreativeInvScreenMixin",
10 | "CreativeInvScreenMixin$CISAccessor",
11 | "CSAccessor"
12 | ],
13 | "injectors": {
14 | "defaultRequire": 1
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/1_19_3/src/main/resources/hotbarsplus.1_19.mixins.json:
--------------------------------------------------------------------------------
1 | {
2 | "required": true,
3 | "minVersion": "0.8",
4 | "package": "me.videogamesm12.hotbarsplus.v1_19.mixin",
5 | "compatibilityLevel": "JAVA_8",
6 | "mixins": [
7 | "CreativeInvScreenMixin"
8 | ],
9 | "injectors": {
10 | "defaultRequire": 1
11 | },
12 | "client": [
13 | "CreativeInvScreenAccessor",
14 | "HandledScreenAccessor"
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/1_20/src/main/java/me/videogamesm12/hotbarsplus/v1_20/mixin/HandledScreenAccessor.java:
--------------------------------------------------------------------------------
1 | package me.videogamesm12.hotbarsplus.v1_20.mixin;
2 |
3 | import net.minecraft.client.gui.screen.ingame.HandledScreen;
4 | import org.spongepowered.asm.mixin.Mixin;
5 | import org.spongepowered.asm.mixin.gen.Accessor;
6 |
7 | @Mixin(HandledScreen.class)
8 | public interface HandledScreenAccessor {
9 | @Accessor("x")
10 | int getX();
11 |
12 | @Accessor("y")
13 | int getY();
14 | }
15 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 | replay_pid*
25 |
26 | # Intellij
27 | .idea/
28 | *.iml
29 |
30 | # Gradle
31 | .gradle/
32 | build/
--------------------------------------------------------------------------------
/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/HandledScreenAccessor.java:
--------------------------------------------------------------------------------
1 | package me.videogamesm12.hotbarsplus.v1_19.mixin;
2 |
3 | import net.minecraft.client.gui.screen.ingame.HandledScreen;
4 | import org.spongepowered.asm.mixin.Mixin;
5 | import org.spongepowered.asm.mixin.gen.Accessor;
6 |
7 | @Mixin(HandledScreen.class)
8 | public interface HandledScreenAccessor {
9 | @Accessor("x")
10 | int getX();
11 |
12 | @Accessor("y")
13 | int getY();
14 | }
15 |
--------------------------------------------------------------------------------
/1_16/build.gradle:
--------------------------------------------------------------------------------
1 | group 'me.videogamesm12'
2 |
3 | repositories {
4 | exclusiveContent {
5 | forRepository {
6 | maven {
7 | name = "Modrinth"
8 | url = "https://api.modrinth.com/maven"
9 | }
10 | }
11 | filter {
12 | includeGroup "maven.modrinth"
13 | }
14 | }
15 | }
16 |
17 | dependencies {
18 | minecraft "com.mojang:minecraft:1.16.5"
19 | mappings "net.fabricmc:yarn:1.16.5+build.10:v2"
20 | modImplementation "net.fabricmc.fabric-api:fabric-api:0.42.0+1.16"
21 |
22 | modImplementation "maven.modrinth:cotton-client-commands:1.0.1"
23 | }
--------------------------------------------------------------------------------
/1_20/src/main/java/me/videogamesm12/hotbarsplus/v1_20/mixin/CreativeInvScreenAccessor.java:
--------------------------------------------------------------------------------
1 | package me.videogamesm12.hotbarsplus.v1_20.mixin;
2 |
3 | import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
4 | import net.minecraft.item.ItemGroup;
5 | import org.spongepowered.asm.mixin.Mixin;
6 | import org.spongepowered.asm.mixin.gen.Accessor;
7 | import org.spongepowered.asm.mixin.gen.Invoker;
8 |
9 | @Mixin(CreativeInventoryScreen.class)
10 | public interface CreativeInvScreenAccessor
11 | {
12 | @Accessor("selectedTab")
13 | ItemGroup getSelectedTab();
14 |
15 | @Invoker
16 | void invokeSetSelectedTab(ItemGroup group);
17 | }
18 |
--------------------------------------------------------------------------------
/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/CreativeInvScreenAccessor.java:
--------------------------------------------------------------------------------
1 | package me.videogamesm12.hotbarsplus.v1_19.mixin;
2 |
3 | import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
4 | import net.minecraft.item.ItemGroup;
5 | import org.spongepowered.asm.mixin.Mixin;
6 | import org.spongepowered.asm.mixin.gen.Accessor;
7 | import org.spongepowered.asm.mixin.gen.Invoker;
8 |
9 | @Mixin(CreativeInventoryScreen.class)
10 | public interface CreativeInvScreenAccessor
11 | {
12 | @Accessor("selectedTab")
13 | ItemGroup getSelectedTab();
14 |
15 | @Invoker
16 | void invokeSetSelectedTab(ItemGroup group);
17 | }
18 |
--------------------------------------------------------------------------------
/.github/workflows/gradle.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Gradle
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3 |
4 | name: Java CI with Gradle
5 |
6 | on:
7 | push:
8 | branches: [ development ]
9 | pull_request:
10 | branches: [ development ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v2
19 | - name: Set up JDK 17
20 | uses: actions/setup-java@v2
21 | with:
22 | java-version: '17'
23 | distribution: 'adopt'
24 | - name: Grant execute permission for gradlew
25 | run: chmod +x gradlew
26 | - name: Build with Gradle
27 | run: ./gradlew build
28 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/notifications/ToastNotification.java:
--------------------------------------------------------------------------------
1 | package me.videogamesm12.hotbarsplus.core.notifications;
2 |
3 | import me.videogamesm12.hotbarsplus.core.HBPCore;
4 | import me.videogamesm12.hotbarsplus.core.universal.NotificationManager;
5 | import net.minecraft.text.Text;
6 | import net.minecraft.util.Identifier;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | public class ToastNotification implements NotificationManager.NotificationRoute
10 | {
11 | @Override
12 | public void display(NotificationManager.NotificationType type, Text... text)
13 | {
14 | if (HBPCore.TOASTS != null)
15 | HBPCore.TOASTS.showToast(type, text);
16 | }
17 |
18 | @Override
19 | public @NotNull Identifier getId()
20 | {
21 | return new Identifier("hotbarsplus", "toast");
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/1_17/src/main/resources/fabric.mod.json:
--------------------------------------------------------------------------------
1 | {
2 | "schemaVersion": 1,
3 | "id": "hotbarsplus-1_17",
4 | "version": "${version}",
5 | "name": "Hooks for 1.17.x/1.18.x",
6 | "description": "Hooks specific to 1.17.x/1.18.x for Hotbars+.",
7 | "authors": ["videogamesm12"],
8 | "contact": {
9 | "issues": "https://github.com/VideoGameSmash12/HotbarsPlus/issues",
10 | "homepage": "https://github.com/VideoGameSmash12/HotbarsPlus",
11 | "sources": "https://github.com/VideoGameSmash12/HotbarsPlus"
12 | },
13 | "license": "MIT",
14 | "icon": "assets/hotbarsplus-1_17/icon.png",
15 | "environment": "client",
16 | "entrypoints": {
17 | "client": [
18 | "me.videogamesm12.hotbarsplus.v1_17.HotbarsPlus"
19 | ]
20 | },
21 | "mixins": [
22 | "hotbarsplus.1_17.mixins.json"
23 | ],
24 | "depends": {
25 | "minecraft": ["1.17.x", "1.18.x"]
26 | },
27 | "custom": {
28 | "modmenu": {
29 | "badges": ["library"],
30 | "parent": "hotbarsplus"
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/1_14/build.gradle:
--------------------------------------------------------------------------------
1 | group 'me.videogamesm12'
2 |
3 | repositories {
4 | exclusiveContent {
5 | forRepository {
6 | maven {
7 | name = "Modrinth"
8 | url = "https://api.modrinth.com/maven"
9 | }
10 | }
11 | filter {
12 | includeGroup "maven.modrinth"
13 | }
14 | }
15 | }
16 |
17 | dependencies {
18 | minecraft "com.mojang:minecraft:1.14.4"
19 | mappings "net.fabricmc:yarn:1.14.4+build.18:v2"
20 | modImplementation "net.fabricmc.fabric-api:fabric-api:0.28.5+1.14"
21 |
22 | // 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
23 | // when the Fabric API developers decided a client command API was necessary. Thing is, they never back-ported it
24 | // 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
25 | // trick. Fucking shit!
26 | modImplementation "maven.modrinth:cotton-client-commands:1.0.1"
27 | }
--------------------------------------------------------------------------------
/1_14/src/main/resources/fabric.mod.json:
--------------------------------------------------------------------------------
1 | {
2 | "schemaVersion": 1,
3 | "id": "hotbarsplus-legacy",
4 | "version": "${version}",
5 | "name": "Legacy Hooks",
6 | "description": "Hooks specific to 1.14.x/1.15.x for Hotbars+.",
7 | "authors": ["videogamesm12"],
8 | "contact": {
9 | "issues": "https://github.com/VideoGameSmash12/HotbarsPlus/issues",
10 | "homepage": "https://github.com/VideoGameSmash12/HotbarsPlus",
11 | "sources": "https://github.com/VideoGameSmash12/HotbarsPlus"
12 | },
13 | "license": "MIT",
14 | "icon": "assets/hotbarsplus-legacy/icon.png",
15 | "environment": "client",
16 | "entrypoints": {
17 | "client": ["me.videogamesm12.hotbarsplus.legacy.HotbarsPlus"],
18 | "cotton-client-commands": ["me.videogamesm12.hotbarsplus.legacy.manager.CommandManager"]
19 | },
20 | "mixins": [
21 | "hotbarsplus.legacy.mixins.json"
22 | ],
23 | "depends": {
24 | "minecraft": ["1.14.x", "1.15.x"]
25 | },
26 | "custom": {
27 | "modmenu:api": true,
28 | "modmenu:parent": "hotbarsplus"
29 | }
30 | }
--------------------------------------------------------------------------------
/1_20/src/main/resources/fabric.mod.json:
--------------------------------------------------------------------------------
1 | {
2 | "schemaVersion": 1,
3 | "id": "hotbarsplus-1_20",
4 | "version": "${version}",
5 | "name": "Hooks for 1.20+",
6 | "description": "Hooks specific to 1.20+ for Hotbars+.",
7 | "authors": ["videogamesm12"],
8 | "contact": {
9 | "issues": "https://github.com/VideoGameSmash12/HotbarsPlus/issues",
10 | "homepage": "https://github.com/VideoGameSmash12/HotbarsPlus",
11 | "sources": "https://github.com/VideoGameSmash12/HotbarsPlus"
12 | },
13 | "license": "MIT",
14 | "icon": "assets/hotbarsplus/icon.png",
15 | "environment": "client",
16 | "entrypoints": {
17 | "client": [
18 | "me.videogamesm12.hotbarsplus.v1_20.HotbarsPlus"
19 | ]
20 | },
21 | "mixins": [
22 | "hotbarsplus.1_20.mixins.json"
23 | ],
24 | "depends": {
25 | "fabricloader": ">=0.12.12",
26 | "minecraft": ">=1.20"
27 | },
28 | "breaks": {
29 | "multihotbar": "*"
30 | },
31 | "custom": {
32 | "modmenu": {
33 | "badges": ["library"],
34 | "parent": "hotbarsplus"
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/resources/fabric.mod.json:
--------------------------------------------------------------------------------
1 | {
2 | "schemaVersion": 1,
3 | "id": "hotbarsplus",
4 | "version": "${version}",
5 | "name": "Hotbars+",
6 | "description": "Get more use out of your saved hotbars!",
7 | "authors": ["videogamesm12"],
8 | "contact": {
9 | "issues": "https://github.com/VideoGameSmash12/HotbarsPlus/issues",
10 | "homepage": "https://github.com/VideoGameSmash12/HotbarsPlus",
11 | "sources": "https://github.com/VideoGameSmash12/HotbarsPlus"
12 | },
13 | "license": "MIT",
14 | "icon": "assets/hotbarsplus/icon.png",
15 | "environment": "client",
16 | "entrypoints": {
17 | "client": [
18 | "me.videogamesm12.hotbarsplus.core.HBPCore"
19 | ],
20 | "hotbarsplus": [
21 | "me.videogamesm12.hotbarsplus.core.provider.NotificationRouteProvider"
22 | ]
23 | },
24 | "mixins": [
25 | "hotbarsplus.mixin.json"
26 | ],
27 | "depends": {
28 | "fabric": "*",
29 | "minecraft": ">=1.14.4"
30 | },
31 | "accessWidener": "hotbarsplus.accesswidener",
32 | "breaks": {
33 | "multihotbar": "*"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/1_19/src/main/resources/fabric.mod.json:
--------------------------------------------------------------------------------
1 | {
2 | "schemaVersion": 1,
3 | "id": "hotbarsplus-1_19",
4 | "version": "${version}",
5 | "name": "Hooks for 1.19+",
6 | "description": "Hooks specific to 1.19+ for Hotbars+.",
7 | "authors": ["videogamesm12"],
8 | "contact": {
9 | "issues": "https://github.com/VideoGameSmash12/HotbarsPlus/issues",
10 | "homepage": "https://github.com/VideoGameSmash12/HotbarsPlus",
11 | "sources": "https://github.com/VideoGameSmash12/HotbarsPlus"
12 | },
13 | "license": "MIT",
14 | "icon": "assets/hotbarsplus/icon.png",
15 | "environment": "client",
16 | "entrypoints": {
17 | "client": [
18 | "me.videogamesm12.hotbarsplus.v1_19.HotbarsPlus"
19 | ]
20 | },
21 | "mixins": [
22 | "hotbarsplus.1_19.mixins.json"
23 | ],
24 | "depends": {
25 | "fabricloader": ">=0.12.12",
26 | "minecraft": ">=1.19 <1.19.3"
27 | },
28 | "breaks": {
29 | "multihotbar": "*"
30 | },
31 | "custom": {
32 | "modmenu": {
33 | "badges": ["library"],
34 | "parent": "hotbarsplus"
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/1_19_3/src/main/resources/fabric.mod.json:
--------------------------------------------------------------------------------
1 | {
2 | "schemaVersion": 1,
3 | "id": "hotbarsplus-1_19_3",
4 | "version": "${version}",
5 | "name": "Hooks for 1.19.3+",
6 | "description": "Hooks specific to 1.19.3 - 1.19.4 for Hotbars+.",
7 | "authors": ["videogamesm12"],
8 | "contact": {
9 | "issues": "https://github.com/VideoGameSmash12/HotbarsPlus/issues",
10 | "homepage": "https://github.com/VideoGameSmash12/HotbarsPlus",
11 | "sources": "https://github.com/VideoGameSmash12/HotbarsPlus"
12 | },
13 | "license": "MIT",
14 | "icon": "assets/hotbarsplus/icon.png",
15 | "environment": "client",
16 | "entrypoints": {
17 | "client": [
18 | "me.videogamesm12.hotbarsplus.v1_19.HotbarsPlus"
19 | ]
20 | },
21 | "mixins": [
22 | "hotbarsplus.1_19.mixins.json"
23 | ],
24 | "depends": {
25 | "fabricloader": ">=0.12.12",
26 | "minecraft": ["1.19.3", "1.19.4"]
27 | },
28 | "breaks": {
29 | "multihotbar": "*"
30 | },
31 | "custom": {
32 | "modmenu": {
33 | "badges": ["library"],
34 | "parent": "hotbarsplus"
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/1_16/src/main/resources/fabric.mod.json:
--------------------------------------------------------------------------------
1 | {
2 | "schemaVersion": 1,
3 | "id": "hotbarsplus-1_16",
4 | "version": "${version}",
5 | "name": "Hooks for 1.16",
6 | "description": "Hooks specific to 1.16.x for Hotbars+.",
7 | "authors": ["videogamesm12"],
8 | "contact": {
9 | "issues": "https://github.com/VideoGameSmash12/HotbarsPlus/issues",
10 | "homepage": "https://github.com/VideoGameSmash12/HotbarsPlus",
11 | "sources": "https://github.com/VideoGameSmash12/HotbarsPlus"
12 | },
13 | "license": "MIT",
14 | "icon": "assets/hotbarsplus-1_16/icon.png",
15 | "environment": "client",
16 | "entrypoints": {
17 | "client": [
18 | "me.videogamesm12.hotbarsplus.v1_16.HotbarsPlus"
19 | ],
20 | "cotton-client-commands": [
21 | "me.videogamesm12.hotbarsplus.v1_16.manager.FallbackCommandManager"
22 | ]
23 | },
24 | "mixins": [
25 | "hotbarsplus.1_16.mixins.json"
26 | ],
27 | "depends": {
28 | "minecraft": "1.16.x"
29 | },
30 | "custom": {
31 | "modmenu": {
32 | "badges": ["library"],
33 | "parent": "hotbarsplus"
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/license.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Video
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | ## Hotbars+
2 | Hotbars+ (also known as "MultiHotbar" in earlier versions) is a mod for Minecraft that dramatically increases how many hotbars can be saved by paginating the vanilla hotbar storage system.
3 |
4 | ### How does it work?
5 | The mod works by hijacking the saved hotbar system Minecraft uses to use a different file to load and save from in place of the traditional `hotbar.nbt`, hot-swapping files for each page.
6 |
7 | ### What is required to use the mod?
8 | The requirements depend on the version of Minecraft you're using. To help guide you, here's a table:
9 |
10 | | Version | Fabric Loader | Fabric API | Cotton Client Commands |
11 | |--------------------| ------------- | ---------- | ---------------------- |
12 | | 1.14.4 - 1.15.x | Yes | Yes | Optional* |
13 | | 1.16.1 - 1.16.4 | Yes | Yes | Optional* |
14 | | 1.16.5 | Yes | Yes | No |
15 | | 1.17.x - 1.18.2 | Yes | Yes | No |
16 | | 1.19 - 1.19.4 | Yes | Yes | No |
17 | | 1.20 - 1.20.2 | Yes | Yes | No |
18 |
19 | \* = The mod will still launch without it, but you won't be able to run client-side commands like /hotbars+.
20 |
--------------------------------------------------------------------------------
/src/main/resources/assets/hotbarsplus/lang/en_us.json:
--------------------------------------------------------------------------------
1 | {
2 | "category.hotbarsplus.navigation": "Hotbars+",
3 |
4 | "command.backup.file_does_not_exist": "The currently selected hotbar page does not exist.",
5 | "command.cache.clear.success": "Cache cleared.",
6 | "command.cache.list.amount": "There are currently %d hotbar pages cached in memory.",
7 | "command.cache.list.entries": "Cached pages: %s",
8 |
9 | "gui.hotbarsplus.cis.backup_button.tooltip": "Backup this page",
10 | "gui.hotbarsplus.cis.next_button.tooltip": "Next Page",
11 | "gui.hotbarsplus.cis.previous_button.tooltip": "Previous Page",
12 |
13 | "key.hotbarsplus.backup": "Backup Page",
14 | "key.hotbarsplus.next": "Next Page",
15 | "key.hotbarsplus.previous": "Previous Page",
16 |
17 | "notif.hotbarsplus.backup.failed": "Backup failed",
18 | "notif.hotbarsplus.backup.failed.mini": "Backup failed: %s",
19 | "notif.hotbarsplus.backup.success": "Backup complete",
20 | "notif.hotbarsplus.backup.success.mini": "Backed up %s to %s",
21 | "notif.hotbarsplus.load.failed": "Load failed",
22 | "notif.hotbarsplus.load.failed.body": "Check the logs.",
23 | "notif.hotbarsplus.load.failed.mini": "Load failed",
24 | "notif.hotbarsplus.save.failed": "Save failed",
25 | "notif.hotbarsplus.save.failed.body": "Check the logs.",
26 | "notif.hotbarsplus.save.failed.mini": "Save failed",
27 |
28 | "notif.hotbarsplus.navigation.selected": "Page selected",
29 | "notif.hotbarsplus.navigation.selected.mini": "Page selected: %s"
30 | }
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/api/manager/IKeybindManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.api.manager;
19 |
20 | /**
21 | *
IKeybindManager
22 | * Interface for version-specific keybind management.
23 | * @param KeyBinding
24 | */
25 | public interface IKeybindManager
26 | {
27 | /**
28 | * Registers all the various keybinds.
29 | */
30 | void registerKeybinds();
31 | }
--------------------------------------------------------------------------------
/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/mixin/HSAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_16.mixin;
19 |
20 | import net.minecraft.client.gui.screen.ingame.HandledScreen;
21 | import org.spongepowered.asm.mixin.Mixin;
22 | import org.spongepowered.asm.mixin.gen.Accessor;
23 |
24 | @Mixin(HandledScreen.class)
25 | public interface HSAccessor
26 | {
27 | @Accessor("x")
28 | int getX();
29 |
30 | @Accessor("y")
31 | int getY();
32 | }
33 |
--------------------------------------------------------------------------------
/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/mixin/HSAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_17.mixin;
19 |
20 | import net.minecraft.client.gui.screen.ingame.HandledScreen;
21 | import org.spongepowered.asm.mixin.Mixin;
22 | import org.spongepowered.asm.mixin.gen.Accessor;
23 |
24 | @Mixin(HandledScreen.class)
25 | public interface HSAccessor
26 | {
27 | @Accessor("x")
28 | int getX();
29 |
30 | @Accessor("y")
31 | int getY();
32 | }
33 |
--------------------------------------------------------------------------------
/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/mixin/CSAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.legacy.mixin;
19 |
20 | import net.minecraft.client.gui.screen.ingame.ContainerScreen;
21 | import org.spongepowered.asm.mixin.Mixin;
22 | import org.spongepowered.asm.mixin.gen.Accessor;
23 |
24 | @Mixin(ContainerScreen.class)
25 | public interface CSAccessor
26 | {
27 | @Accessor("x")
28 | int getX();
29 |
30 | @Accessor("y")
31 | int getY();
32 | }
33 |
--------------------------------------------------------------------------------
/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/HSAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_19.mixin;
19 |
20 | import net.minecraft.client.gui.screen.ingame.HandledScreen;
21 | import org.spongepowered.asm.mixin.Mixin;
22 | import org.spongepowered.asm.mixin.gen.Accessor;
23 |
24 | @Mixin(HandledScreen.class)
25 | public interface HSAccessor
26 | {
27 | @Accessor("x")
28 | public int getX();
29 |
30 | @Accessor("y")
31 | public int getY();
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/api/IHotbarsPlusStorage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.api;
19 |
20 | import java.math.BigInteger;
21 |
22 | /**
23 | * IHotbarsPlusStorage
24 | * Interface for anything wrapping HotbarStorage instances.
25 | */
26 | public interface IHotbarsPlusStorage
27 | {
28 | /**
29 | * Gets the page number that the instance belongs to.
30 | * @return BigInteger
31 | */
32 | BigInteger getPage();
33 | }
34 |
--------------------------------------------------------------------------------
/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/FourteenHooks.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.legacy;
19 |
20 | import com.google.gson.JsonElement;
21 | import me.videogamesm12.hotbarsplus.api.IVersionHook;
22 | import net.minecraft.text.Text;
23 |
24 | /**
25 | * FourteenHooks
26 | * Hooks specific to 1.14.x - 1.15.x
27 | */
28 | public class FourteenHooks implements IVersionHook
29 | {
30 | @Override
31 | public Text convertFromJson(JsonElement tree)
32 | {
33 | return Text.Serializer.fromJson(tree);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/api/manager/ICommandManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.api.manager;
19 |
20 | import com.mojang.brigadier.tree.LiteralCommandNode;
21 |
22 | /**
23 | * ICommandManager
24 | * Interface for version-specific implementations of client commands.
25 | * @param Instance of CommandSource, such as FabricClientCommandSource
26 | */
27 | public interface ICommandManager
28 | {
29 | /**
30 | * Registers all the mod's commands.
31 | */
32 | void register();
33 |
34 | LiteralCommandNode getCommandNode();
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/commands/NextCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.core.commands;
19 |
20 | import com.mojang.brigadier.Command;
21 | import com.mojang.brigadier.context.CommandContext;
22 | import me.videogamesm12.hotbarsplus.core.HBPCore;
23 |
24 | public interface NextCommand extends Command
25 | {
26 | @Override
27 | default int run(CommandContext context)
28 | {
29 | HBPCore.UPL.incrementPage();
30 | return 1;
31 | };
32 |
33 | static NextCommand impl()
34 | {
35 | return new NextCommand() {};
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/commands/PreviousCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.core.commands;
19 |
20 | import com.mojang.brigadier.Command;
21 | import com.mojang.brigadier.context.CommandContext;
22 | import me.videogamesm12.hotbarsplus.core.HBPCore;
23 |
24 | public interface PreviousCommand extends Command
25 | {
26 | @Override
27 | default int run(CommandContext context)
28 | {
29 | HBPCore.UPL.decrementPage();
30 | return 1;
31 | };
32 |
33 | static PreviousCommand impl()
34 | {
35 | return new PreviousCommand() {};
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/api/IVersionHook.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.api;
19 |
20 | import com.google.gson.JsonElement;
21 | import net.minecraft.text.Text;
22 |
23 | /**
24 | * IVersionHook
25 | * Interface for version-specific code that aren't available in one version but is available in another.
26 | */
27 | public interface IVersionHook
28 | {
29 | /**
30 | * Converts JsonElement instances from Adventure components to native Minecraft components.
31 | * @param tree JsonElement
32 | * @return Text
33 | */
34 | Text convertFromJson(JsonElement tree);
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/HotbarsPlusStorage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.core;
19 |
20 | import lombok.Getter;
21 | import me.videogamesm12.hotbarsplus.api.IHotbarsPlusStorage;
22 | import me.videogamesm12.hotbarsplus.api.util.Util;
23 | import net.minecraft.client.MinecraftClient;
24 | import net.minecraft.client.option.HotbarStorage;
25 |
26 | import java.math.BigInteger;
27 |
28 | public class HotbarsPlusStorage extends HotbarStorage implements IHotbarsPlusStorage
29 | {
30 | @Getter
31 | private BigInteger page;
32 |
33 | public HotbarsPlusStorage(BigInteger page)
34 | {
35 | super(Util.getHotbarFile(page), MinecraftClient.getInstance().getDataFixer());
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/api/event/keybind/NextBindPressEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.api.event.keybind;
19 |
20 | import net.fabricmc.fabric.api.event.Event;
21 | import net.fabricmc.fabric.api.event.EventFactory;
22 |
23 | import java.util.Arrays;
24 |
25 | /**
26 | * NextBindPressEvent
27 | * An event that is called when the player presses the keybind for going to the next hotbar page.
28 | */
29 | public interface NextBindPressEvent
30 | {
31 | Event EVENT = EventFactory.createArrayBacked(NextBindPressEvent.class,
32 | (listeners) -> () -> Arrays.stream(listeners).forEach(NextBindPressEvent::onNextPress)
33 | );
34 |
35 | void onNextPress();
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/api/event/keybind/BackupBindPressEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.api.event.keybind;
19 |
20 | import net.fabricmc.fabric.api.event.Event;
21 | import net.fabricmc.fabric.api.event.EventFactory;
22 |
23 | import java.util.Arrays;
24 |
25 | /**
26 | * BackupBindPressEvent
27 | * An event that is called when the player presses the keybind for making a backup of the current page.
28 | */
29 | public interface BackupBindPressEvent
30 | {
31 | Event EVENT = EventFactory.createArrayBacked(BackupBindPressEvent.class,
32 | (listeners) -> () -> Arrays.stream(listeners).forEach(BackupBindPressEvent::onBackupPress)
33 | );
34 |
35 | void onBackupPress();
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/api/provider/INotificationRouteProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.api.provider;
19 |
20 | import me.videogamesm12.hotbarsplus.core.universal.NotificationManager;
21 |
22 | import java.util.List;
23 |
24 | /**
25 | * INotificationRouteProvider
26 | * Hotbars+'s new way of registering notification routes as of v2.0-pre10.
27 | * To use this, implement this interface in your project as a provider and have it return a list of route classes. Then, add a path to the class in your fabric.mod.json file as an entrypoint for "hotbarsplus".
28 | */
29 | public interface INotificationRouteProvider
30 | {
31 | List> getNotificationRoutes();
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/api/event/keybind/PreviousBindPressEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.api.event.keybind;
19 |
20 | import net.fabricmc.fabric.api.event.Event;
21 | import net.fabricmc.fabric.api.event.EventFactory;
22 |
23 | import java.util.Arrays;
24 |
25 | /**
26 | * PreviousBindPressEvent
27 | * An event that is called when the player presses the keybind for going to the previous hotbar page.
28 | */
29 | public interface PreviousBindPressEvent
30 | {
31 | Event EVENT = EventFactory.createArrayBacked(PreviousBindPressEvent.class,
32 | (listeners) -> () -> Arrays.stream(listeners).forEach(PreviousBindPressEvent::onPreviousPress)
33 | );
34 |
35 | void onPreviousPress();
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/commands/GoToCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.core.commands;
19 |
20 | import com.mojang.brigadier.Command;
21 | import com.mojang.brigadier.arguments.LongArgumentType;
22 | import com.mojang.brigadier.context.CommandContext;
23 | import me.videogamesm12.hotbarsplus.core.HBPCore;
24 |
25 | import java.math.BigInteger;
26 |
27 | public interface GoToCommand extends Command
28 | {
29 | @Override
30 | default int run(CommandContext context)
31 | {
32 | HBPCore.UPL.goToPage(BigInteger.valueOf(LongArgumentType.getLong(context, "page")));
33 | return 1;
34 | };
35 |
36 | static GoToCommand impl()
37 | {
38 | return new GoToCommand() {};
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/api/event/notification/NotificationTypeRegistered.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.api.event.notification;
19 |
20 | import me.videogamesm12.hotbarsplus.core.universal.NotificationManager;
21 | import net.fabricmc.fabric.api.event.Event;
22 | import net.fabricmc.fabric.api.event.EventFactory;
23 |
24 | import java.util.Arrays;
25 |
26 | /**
27 | * NotificationTypeRegistered
28 | * An event that is called when a notification route is successfully registered.
29 | */
30 | public interface NotificationTypeRegistered
31 | {
32 | Event EVENT = EventFactory.createArrayBacked(NotificationTypeRegistered.class,
33 | (listeners) -> (type) -> Arrays.stream(listeners).forEach(listener -> listener.onTypeRegistered(type)));
34 |
35 | void onTypeRegistered(NotificationManager.NotificationRoute type);
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/api/manager/IToastManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.api.manager;
19 |
20 | import me.videogamesm12.hotbarsplus.core.universal.NotificationManager;
21 | import net.minecraft.text.Text;
22 | import net.minecraft.util.Identifier;
23 |
24 | /**
25 | * IToastManager
26 | * Interface for version-specific toast notification management.
27 | */
28 | public interface IToastManager
29 | {
30 | Identifier TEXTURE = new Identifier("hotbarsplus", "textures/toasts.png");
31 |
32 | IHotbarToast getToastFrom(NotificationManager.NotificationType type, Text... texts);
33 |
34 | void showToast(IHotbarToast toast);
35 |
36 | default void showToast(NotificationManager.NotificationType type, Text... texts)
37 | {
38 | showToast(getToastFrom(type, texts));
39 | }
40 |
41 | interface IHotbarToast
42 | {
43 | NotificationManager.NotificationType getType();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/provider/NotificationRouteProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.core.provider;
19 |
20 | import me.videogamesm12.hotbarsplus.api.provider.INotificationRouteProvider;
21 | import me.videogamesm12.hotbarsplus.core.notifications.ActionBarNotification;
22 | import me.videogamesm12.hotbarsplus.core.notifications.ToastNotification;
23 | import me.videogamesm12.hotbarsplus.core.universal.NotificationManager;
24 |
25 | import java.util.Arrays;
26 | import java.util.List;
27 |
28 | /**
29 | * NotificationRouteProvider
30 | * Registers Hotbars+'s built-in notification routes (action bar and toast notifications)
31 | */
32 | public class NotificationRouteProvider implements INotificationRouteProvider
33 | {
34 | @Override
35 | public List> getNotificationRoutes()
36 | {
37 | return Arrays.asList(ActionBarNotification.class, ToastNotification.class);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/commands/BackupCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.core.commands;
19 |
20 | import com.mojang.brigadier.Command;
21 | import com.mojang.brigadier.context.CommandContext;
22 | import me.videogamesm12.hotbarsplus.api.util.Util;
23 | import me.videogamesm12.hotbarsplus.core.HBPCore;
24 | import net.kyori.adventure.text.Component;
25 | import net.kyori.adventure.text.format.NamedTextColor;
26 |
27 | public interface BackupCommand extends Command
28 | {
29 | @Override
30 | default int run(CommandContext context)
31 | {
32 | if (!HBPCore.UPL.hotbarPageExists())
33 | {
34 | Util.msg(Component.translatable("command.backup.file_does_not_exist", NamedTextColor.RED));
35 | return 1;
36 | }
37 |
38 | HBPCore.UBL.backupHotbar();
39 | return 1;
40 | };
41 |
42 | static BackupCommand impl()
43 | {
44 | return new BackupCommand() {};
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/mixin/MinecraftClientMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.core.mixin;
19 |
20 | import me.videogamesm12.hotbarsplus.core.HBPCore;
21 | import net.minecraft.client.MinecraftClient;
22 | import net.minecraft.client.option.HotbarStorage;
23 | import org.spongepowered.asm.mixin.Mixin;
24 | import org.spongepowered.asm.mixin.injection.At;
25 | import org.spongepowered.asm.mixin.injection.Inject;
26 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
27 |
28 | /**
29 | * MinecraftClientMixin
30 | * Hijacks calls made to get the Creative Hotbar Storage and replaces them with what Hotbars+ has.
31 | */
32 | @Mixin(MinecraftClient.class)
33 | public class MinecraftClientMixin
34 | {
35 | @Inject(method = "getCreativeHotbarStorage", at = @At("HEAD"), cancellable = true)
36 | public void getCreativeHotbarStorage(CallbackInfoReturnable cir)
37 | {
38 | cir.setReturnValue(HBPCore.UPL.getHotbarPage());
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/api/event/failures/BackupFailEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.api.event.failures;
19 |
20 | import net.fabricmc.fabric.api.event.Event;
21 | import net.fabricmc.fabric.api.event.EventFactory;
22 | import net.minecraft.util.ActionResult;
23 |
24 | /**
25 | * BackupFailEvent
26 | * An event that is called when the backup process for a given hotbar page fails.
27 | */
28 | public interface BackupFailEvent
29 | {
30 | Event EVENT = EventFactory.createArrayBacked(BackupFailEvent.class,
31 | (listeners) -> (ex) ->
32 | {
33 | for (BackupFailEvent listener : listeners)
34 | {
35 | ActionResult result = listener.onBackupFailure(ex);
36 |
37 | if (result != ActionResult.PASS)
38 | {
39 | return result;
40 | }
41 | }
42 |
43 | return ActionResult.SUCCESS;
44 | }
45 | );
46 |
47 | ActionResult onBackupFailure(Exception ex);
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/api/event/success/BackupSuccessEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.api.event.success;
19 |
20 | import net.fabricmc.fabric.api.event.Event;
21 | import net.fabricmc.fabric.api.event.EventFactory;
22 | import net.minecraft.util.ActionResult;
23 |
24 | import java.io.File;
25 |
26 | /**
27 | * BackupSuccessEvent
28 | * An event that is called when a backup is successful.
29 | */
30 | public interface BackupSuccessEvent
31 | {
32 | Event EVENT = EventFactory.createArrayBacked(BackupSuccessEvent.class,
33 | (listeners) -> (from, to) ->
34 | {
35 | for (BackupSuccessEvent listener : listeners)
36 | {
37 | ActionResult result = listener.onBackupSuccess(from, to);
38 |
39 | if (result != ActionResult.PASS)
40 | {
41 | return result;
42 | }
43 | }
44 |
45 | return ActionResult.SUCCESS;
46 | }
47 | );
48 |
49 | ActionResult onBackupSuccess(File from, File to);
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/api/event/navigation/HotbarNavigateEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.api.event.navigation;
19 |
20 | import net.fabricmc.fabric.api.event.Event;
21 | import net.fabricmc.fabric.api.event.EventFactory;
22 | import net.minecraft.util.ActionResult;
23 |
24 | import java.math.BigInteger;
25 |
26 | /**
27 | * HotbarNavigateEvent
28 | * An event that is called when the player navigates to another hotbar page.
29 | */
30 | public interface HotbarNavigateEvent
31 | {
32 | Event EVENT = EventFactory.createArrayBacked(HotbarNavigateEvent.class,
33 | (listeners) -> (page) ->
34 | {
35 | for (HotbarNavigateEvent listener : listeners)
36 | {
37 | ActionResult result = listener.onNavigate(page);
38 |
39 | if (result != ActionResult.PASS)
40 | {
41 | return result;
42 | }
43 | }
44 |
45 | return ActionResult.SUCCESS;
46 | }
47 | );
48 |
49 | ActionResult onNavigate(BigInteger page);
50 | }
--------------------------------------------------------------------------------
/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/gui/CustomButtons.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.legacy.gui;
19 |
20 | import me.videogamesm12.hotbarsplus.core.HBPCore;
21 | import net.minecraft.client.gui.widget.ButtonWidget;
22 |
23 | /**
24 | * CustomButtons
25 | * Custom buttons for the mod specific to 1.14.x.
26 | * --
27 | * @implNote This is here because 1.14 doesn't support custom fonts in text components.
28 | */
29 | public class CustomButtons
30 | {
31 | public static class BackupButton extends ButtonWidget
32 | {
33 | public BackupButton(int x, int y)
34 | {
35 | super(x, y, 16, 12, "✍",
36 | (button) -> HBPCore.UBL.backupHotbar());
37 | }
38 | }
39 |
40 | public static class NextButton extends ButtonWidget
41 | {
42 | public NextButton(int x, int y)
43 | {
44 | super(x, y, 16, 12, "→", (button) -> HBPCore.UPL.incrementPage());
45 | }
46 | }
47 |
48 | public static class PreviousButton extends ButtonWidget
49 | {
50 | public PreviousButton(int x, int y)
51 | {
52 | super(x, y, 16, 12, "←", (button) -> HBPCore.UPL.decrementPage());
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/notifications/ActionBarNotification.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.core.notifications;
19 |
20 | import me.videogamesm12.hotbarsplus.core.universal.NotificationManager;
21 | import net.minecraft.client.MinecraftClient;
22 | import net.minecraft.text.Text;
23 | import net.minecraft.util.Identifier;
24 | import org.jetbrains.annotations.NotNull;
25 |
26 | public class ActionBarNotification implements NotificationManager.NotificationRoute
27 | {
28 | @Override
29 | public void display(NotificationManager.NotificationType type, Text... text)
30 | {
31 | if (MinecraftClient.getInstance().player == null)
32 | {
33 | return;
34 | }
35 |
36 | Text txt;
37 |
38 | // Use the miniature component.
39 | if (text.length > 2)
40 | {
41 | txt = text[2];
42 | }
43 | // Fallback, use the title instead
44 | else if (text.length > 0)
45 | {
46 | txt = text[0];
47 | }
48 | // If there isn't anything to display, don't even bother;
49 | else
50 | {
51 | return;
52 | }
53 |
54 | MinecraftClient.getInstance().player.sendMessage(txt, true);
55 | }
56 |
57 | @Override
58 | public @NotNull Identifier getId()
59 | {
60 | return new Identifier("hotbarsplus", "actionbar");
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/mixin/HotbarStorageMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.core.mixin;
19 |
20 | import com.mojang.datafixers.DataFixer;
21 | import me.videogamesm12.hotbarsplus.core.HotbarsPlusStorage;
22 | import net.minecraft.client.option.HotbarStorage;
23 | import org.spongepowered.asm.mixin.Mixin;
24 | import org.spongepowered.asm.mixin.gen.Accessor;
25 | import org.spongepowered.asm.mixin.injection.*;
26 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
27 |
28 | import java.io.File;
29 |
30 | /**
31 | * HotbarStorageMixin
32 | * Controls where hotbar files are stored.
33 | */
34 | @Mixin(HotbarStorage.class)
35 | public class HotbarStorageMixin
36 | {
37 | /**
38 | * Hijacks what is used as the location by HotbarStorage on initialization.
39 | * @param ci CallbackInfo
40 | * @param dataFixer DataFixer
41 | * @param file File
42 | */
43 | @Inject(method = "", at = @At(value = "TAIL"))
44 | private void inject(File file, DataFixer dataFixer, CallbackInfo ci)
45 | {
46 | if (HotbarsPlusStorage.class.isAssignableFrom(getClass()))
47 | {
48 | ((HSAccessor) this).setFile(file);
49 | }
50 | }
51 |
52 | @Mixin(HotbarStorage.class)
53 | public interface HSAccessor
54 | {
55 | @Accessor
56 | File getFile();
57 |
58 | @Accessor
59 | void setFile(File file);
60 | }
61 | }
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/gui/CustomButtons.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.core.gui;
19 |
20 | import me.videogamesm12.hotbarsplus.core.HBPCore;
21 | import net.minecraft.client.gui.widget.ButtonWidget;
22 | import net.minecraft.text.LiteralText;
23 | import net.minecraft.text.Style;
24 | import net.minecraft.text.Text;
25 | import net.minecraft.text.TranslatableText;
26 | import net.minecraft.util.Identifier;
27 |
28 | public class CustomButtons
29 | {
30 | public static class BackupButton extends ButtonWidget
31 | {
32 | public static Text label = new LiteralText("\uD83D\uDCBE").setStyle(Style.EMPTY.withFont(
33 | new Identifier("hotbarsplus", "default")));
34 |
35 | public BackupButton(int x, int y)
36 | {
37 | super(x, y, 16, 12, label,
38 | (button) -> HBPCore.UBL.backupHotbar(),
39 | (button, stack, mx, my) -> new TranslatableText("gui.hotbarsplus.cis.backup_button.tooltip"));
40 | }
41 | }
42 |
43 | public static class NextButton extends ButtonWidget
44 | {
45 | public NextButton(int x, int y)
46 | {
47 | super(x, y, 16, 12, new LiteralText("→"), (button) -> HBPCore.UPL.incrementPage(),
48 | (button, stack, mx, my) -> new TranslatableText("gui.hotbarsplus.cis.next_button.tooltip"));
49 | }
50 | }
51 |
52 | public static class PreviousButton extends ButtonWidget
53 | {
54 | public PreviousButton(int x, int y)
55 | {
56 | super(x, y, 16, 12, new LiteralText("←"), (button) -> HBPCore.UPL.decrementPage(),
57 | (button, stack, mx, my) -> new TranslatableText("gui.hotbarsplus.cis.previous_button.tooltip"));
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/gui/CustomButtons.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_19.gui;
19 |
20 | import me.videogamesm12.hotbarsplus.api.util.Util;
21 | import me.videogamesm12.hotbarsplus.core.HBPCore;
22 | import net.kyori.adventure.key.Key;
23 | import net.kyori.adventure.text.Component;
24 | import net.kyori.adventure.text.format.Style;
25 | import net.minecraft.client.gui.widget.ButtonWidget;
26 | import net.minecraft.text.Text;
27 |
28 | public class CustomButtons
29 | {
30 | public static class BackupButton extends ButtonWidget
31 | {
32 | public static Text label = Util.advToNative(Component.text("\uD83D\uDCBE").style(Style.style().font(
33 | Key.key("hotbarsplus", "default")).build()));
34 |
35 | public BackupButton(int x, int y)
36 | {
37 | super(x, y, 16, 12, label,
38 | (button) -> HBPCore.UBL.backupHotbar(),
39 | (button, stack, mx, my) -> Util.advToNative(Component.translatable("gui.hotbarsplus.cis.backup_button.tooltip")));
40 | }
41 | }
42 |
43 | public static class NextButton extends ButtonWidget
44 | {
45 | public NextButton(int x, int y)
46 | {
47 | super(x, y, 16, 12, Util.advToNative(Component.text("→")), (button) -> HBPCore.UPL.incrementPage(),
48 | (button, stack, mx, my) -> Util.advToNative(Component.translatable("gui.hotbarsplus.cis.next_button.tooltip")));
49 | }
50 | }
51 |
52 | public static class PreviousButton extends ButtonWidget
53 | {
54 | public PreviousButton(int x, int y)
55 | {
56 | super(x, y, 16, 12, Util.advToNative(Component.text("←")), (button) -> HBPCore.UPL.decrementPage(),
57 | (button, stack, mx, my) -> Util.advToNative(Component.translatable("gui.hotbarsplus.cis.previous_button.tooltip")));
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/HotbarsPlus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_17;
19 |
20 | import me.videogamesm12.hotbarsplus.api.event.navigation.HotbarNavigateEvent;
21 | import me.videogamesm12.hotbarsplus.core.HBPCore;
22 | import me.videogamesm12.hotbarsplus.v1_17.manager.CommandManager;
23 | import me.videogamesm12.hotbarsplus.v1_17.manager.CustomToastManager;
24 | import me.videogamesm12.hotbarsplus.v1_17.manager.KeybindManager;
25 | import me.videogamesm12.hotbarsplus.v1_17.mixin.CreativeInvScreenMixin;
26 | import net.fabricmc.api.ClientModInitializer;
27 | import net.minecraft.client.MinecraftClient;
28 | import net.minecraft.client.gui.screen.Screen;
29 | import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
30 | import net.minecraft.item.ItemGroup;
31 | import net.minecraft.util.ActionResult;
32 |
33 | import java.math.BigInteger;
34 |
35 | public class HotbarsPlus implements ClientModInitializer, HotbarNavigateEvent
36 | {
37 | @Override
38 | public void onInitializeClient()
39 | {
40 | HBPCore.KEYBINDS = new KeybindManager();
41 | HBPCore.COMMANDS = new CommandManager();
42 | HBPCore.TOASTS = new CustomToastManager();
43 | //--
44 | HotbarNavigateEvent.EVENT.register(this);
45 | }
46 |
47 | @Override
48 | public ActionResult onNavigate(BigInteger page)
49 | {
50 | // Refreshes the menu if it is currently open;
51 | if (MinecraftClient.getInstance().currentScreen instanceof CreativeInventoryScreen)
52 | {
53 | Screen screen = MinecraftClient.getInstance().currentScreen;
54 |
55 | if (((CreativeInventoryScreen) screen).getSelectedTab() == ItemGroup.HOTBAR.getIndex())
56 | {
57 | ((CreativeInvScreenMixin.CISAccessor) screen).setSelectedTab(ItemGroup.HOTBAR);
58 | }
59 | }
60 |
61 | return ActionResult.PASS;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/HotbarsPlus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_19;
19 |
20 | import me.videogamesm12.hotbarsplus.api.event.navigation.HotbarNavigateEvent;
21 | import me.videogamesm12.hotbarsplus.core.HBPCore;
22 | import me.videogamesm12.hotbarsplus.v1_19.manager.CommandManager;
23 | import me.videogamesm12.hotbarsplus.v1_19.manager.CustomToastManager;
24 | import me.videogamesm12.hotbarsplus.v1_19.manager.KeybindManager;
25 | import me.videogamesm12.hotbarsplus.v1_19.mixin.CreativeInvScreenMixin;
26 | import net.fabricmc.api.ClientModInitializer;
27 | import net.minecraft.client.MinecraftClient;
28 | import net.minecraft.client.gui.screen.Screen;
29 | import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
30 | import net.minecraft.item.ItemGroup;
31 | import net.minecraft.util.ActionResult;
32 |
33 | import java.math.BigInteger;
34 |
35 | public class HotbarsPlus implements ClientModInitializer, HotbarNavigateEvent
36 | {
37 | @Override
38 | public void onInitializeClient()
39 | {
40 | HBPCore.COMMANDS = new CommandManager();
41 | HBPCore.KEYBINDS = new KeybindManager();
42 | HBPCore.TOASTS = new CustomToastManager();
43 | //--
44 | HotbarNavigateEvent.EVENT.register(this);
45 | }
46 |
47 | @Override
48 | public ActionResult onNavigate(BigInteger page)
49 | {
50 | // Refreshes the menu if it is currently open;
51 | if (MinecraftClient.getInstance().currentScreen instanceof CreativeInventoryScreen)
52 | {
53 | Screen screen = MinecraftClient.getInstance().currentScreen;
54 |
55 | if (((CreativeInventoryScreen) screen).getSelectedTab() == ItemGroup.HOTBAR.getIndex())
56 | {
57 | ((CreativeInvScreenMixin.CISAccessor) screen).setSelectedTab(ItemGroup.HOTBAR);
58 | }
59 | }
60 |
61 | return ActionResult.PASS;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/gui/CustomButtons.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_19.gui;
19 |
20 | import me.videogamesm12.hotbarsplus.api.util.Util;
21 | import me.videogamesm12.hotbarsplus.core.HBPCore;
22 | import net.kyori.adventure.key.Key;
23 | import net.kyori.adventure.text.Component;
24 | import net.kyori.adventure.text.format.Style;
25 | import net.minecraft.client.gui.widget.ButtonWidget;
26 | import net.minecraft.text.Text;
27 |
28 | public class CustomButtons
29 | {
30 | public static class BackupButton extends ButtonWidget
31 | {
32 | private static final Text label = Util.advToNative(Component.text("\uD83D\uDCBE").style(Style.style().font(
33 | Key.key("hotbarsplus", "default")).build()));
34 |
35 | public BackupButton(int x, int y)
36 | {
37 | super(x, y, 16, 12, label,
38 | button -> HBPCore.UBL.backupHotbar(),
39 | supplier -> Util.advToNative(Component.translatable("gui.hotbarsplus.cis.backup_button.tooltip")).copy());
40 | }
41 | }
42 |
43 | public static class NextButton extends ButtonWidget
44 | {
45 | public NextButton(int x, int y)
46 | {
47 | super(x, y, 16, 12, Util.advToNative(Component.text("→")),
48 | button -> HBPCore.UPL.incrementPage(),
49 | supplier -> Util.advToNative(Component.translatable("gui.hotbarsplus.cis.next_button.tooltip")).copy());
50 | }
51 | }
52 |
53 | public static class PreviousButton extends ButtonWidget
54 | {
55 | public PreviousButton(int x, int y)
56 | {
57 | super(x, y, 16, 12, Util.advToNative(Component.text("←")),
58 | button -> HBPCore.UPL.decrementPage(),
59 | supplier -> Util.advToNative(Component.translatable("gui.hotbarsplus.cis.previous_button.tooltip")).copy());
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/1_20/src/main/java/me/videogamesm12/hotbarsplus/v1_20/gui/CustomButtons.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_20.gui;
19 |
20 | import me.videogamesm12.hotbarsplus.api.util.Util;
21 | import me.videogamesm12.hotbarsplus.core.HBPCore;
22 | import net.kyori.adventure.key.Key;
23 | import net.kyori.adventure.text.Component;
24 | import net.kyori.adventure.text.format.Style;
25 | import net.minecraft.client.gui.widget.ButtonWidget;
26 | import net.minecraft.text.Text;
27 |
28 | public class CustomButtons
29 | {
30 | public static class BackupButton extends ButtonWidget
31 | {
32 | private static final Text label = Util.advToNative(Component.text("\uD83D\uDCBE").style(Style.style().font(
33 | Key.key("hotbarsplus", "default")).build()));
34 |
35 | public BackupButton(int x, int y)
36 | {
37 | super(x, y, 16, 12, label,
38 | button -> HBPCore.UBL.backupHotbar(),
39 | supplier -> Util.advToNative(Component.translatable("gui.hotbarsplus.cis.backup_button.tooltip")).copy());
40 | }
41 | }
42 |
43 | public static class NextButton extends ButtonWidget
44 | {
45 | public NextButton(int x, int y)
46 | {
47 | super(x, y, 16, 12, Util.advToNative(Component.text("→")),
48 | button -> HBPCore.UPL.incrementPage(),
49 | supplier -> Util.advToNative(Component.translatable("gui.hotbarsplus.cis.next_button.tooltip")).copy());
50 | }
51 | }
52 |
53 | public static class PreviousButton extends ButtonWidget
54 | {
55 | public PreviousButton(int x, int y)
56 | {
57 | super(x, y, 16, 12, Util.advToNative(Component.text("←")),
58 | button -> HBPCore.UPL.decrementPage(),
59 | supplier -> Util.advToNative(Component.translatable("gui.hotbarsplus.cis.previous_button.tooltip")).copy());
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/CommandManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_16.manager;
19 |
20 | import com.mojang.brigadier.arguments.LongArgumentType;
21 | import com.mojang.brigadier.tree.LiteralCommandNode;
22 | import me.videogamesm12.hotbarsplus.api.manager.ICommandManager;
23 | import me.videogamesm12.hotbarsplus.core.commands.*;
24 | import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
25 | import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
26 |
27 | public class CommandManager implements ICommandManager
28 | {
29 | private LiteralCommandNode hotbarsPlusCommand;
30 |
31 | public CommandManager()
32 | {
33 | register();
34 | }
35 |
36 | @Override
37 | public void register()
38 | {
39 | hotbarsPlusCommand = ClientCommandManager.DISPATCHER.register(
40 | ClientCommandManager.literal("hotbars+").then(
41 | ClientCommandManager.literal("backup").executes(BackupCommand.impl())
42 | ).then(
43 | ClientCommandManager.literal("next").executes(NextCommand.impl())
44 | ).then(
45 | ClientCommandManager.literal("previous").executes(PreviousCommand.impl())
46 | ).then(
47 | ClientCommandManager.literal("goto").then(
48 | ClientCommandManager.argument("page", LongArgumentType.longArg()).executes(GoToCommand.impl())
49 | )
50 | ).then(
51 | ClientCommandManager.literal("cache").then(
52 | ClientCommandManager.literal("list").executes(CacheCommand.ListCommand.impl())
53 | ).then(
54 | ClientCommandManager.literal("clear").executes(CacheCommand.ClearCommand.impl())
55 | )
56 | )
57 | );
58 | }
59 |
60 | @Override
61 | public LiteralCommandNode getCommandNode()
62 | {
63 | return hotbarsPlusCommand;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/manager/CommandManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_17.manager;
19 |
20 | import com.mojang.brigadier.arguments.LongArgumentType;
21 | import com.mojang.brigadier.tree.LiteralCommandNode;
22 | import me.videogamesm12.hotbarsplus.api.manager.ICommandManager;
23 | import me.videogamesm12.hotbarsplus.core.commands.*;
24 | import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
25 | import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
26 |
27 | public class CommandManager implements ICommandManager
28 | {
29 | private LiteralCommandNode hotbarsPlusCommand;
30 |
31 | public CommandManager()
32 | {
33 | register();
34 | }
35 |
36 | @Override
37 | public void register()
38 | {
39 | hotbarsPlusCommand = ClientCommandManager.DISPATCHER.register(
40 | ClientCommandManager.literal("hotbars+").then(
41 | ClientCommandManager.literal("backup").executes(BackupCommand.impl())
42 | ).then(
43 | ClientCommandManager.literal("next").executes(NextCommand.impl())
44 | ).then(
45 | ClientCommandManager.literal("previous").executes(PreviousCommand.impl())
46 | ).then(
47 | ClientCommandManager.literal("goto").then(
48 | ClientCommandManager.argument("page", LongArgumentType.longArg()).executes(GoToCommand.impl())
49 | )
50 | ).then(
51 | ClientCommandManager.literal("cache").then(
52 | ClientCommandManager.literal("list").executes(CacheCommand.ListCommand.impl())
53 | ).then(
54 | ClientCommandManager.literal("clear").executes(CacheCommand.ClearCommand.impl())
55 | )
56 | )
57 | );
58 | }
59 |
60 | @Override
61 | public LiteralCommandNode getCommandNode()
62 | {
63 | return hotbarsPlusCommand;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/HBPCore.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.core;
19 |
20 | import me.videogamesm12.hotbarsplus.api.manager.ICommandManager;
21 | import me.videogamesm12.hotbarsplus.api.manager.IKeybindManager;
22 | import me.videogamesm12.hotbarsplus.api.IVersionHook;
23 | import me.videogamesm12.hotbarsplus.api.manager.IToastManager;
24 | import me.videogamesm12.hotbarsplus.core.notifications.ActionBarNotification;
25 | import me.videogamesm12.hotbarsplus.core.notifications.ToastNotification;
26 | import me.videogamesm12.hotbarsplus.core.universal.BackupManager;
27 | import me.videogamesm12.hotbarsplus.core.universal.ConfigurationManager;
28 | import me.videogamesm12.hotbarsplus.core.universal.NotificationManager;
29 | import me.videogamesm12.hotbarsplus.core.universal.PageManager;
30 | import net.fabricmc.api.ClientModInitializer;
31 | import org.apache.logging.log4j.LogManager;
32 | import org.apache.logging.log4j.Logger;
33 |
34 | /**
35 | * HBPCore
36 | * Hotbars+'s surface-level mod initializer. Handles anything that can be done universally.
37 | */
38 | public class HBPCore implements ClientModInitializer
39 | {
40 | // UTILITIES
41 | public static Logger LOGGER = LogManager.getLogger("Hotbars+");
42 |
43 | // VERSION SPECIFIC
44 | public static IKeybindManager> KEYBINDS = null;
45 | public static ICommandManager> COMMANDS = null;
46 | public static IToastManager TOASTS = null;
47 | public static IVersionHook VHOOKS = null;
48 |
49 | // UNIVERSAL
50 | public static PageManager UPL = new PageManager();
51 | public static BackupManager UBL = new BackupManager();
52 | public static ConfigurationManager UCL = new ConfigurationManager();
53 | public static NotificationManager UNL = new NotificationManager();
54 |
55 | @Override
56 | public void onInitializeClient()
57 | {
58 | // LAST HOTBAR PAGE TRACKING
59 | //------------------------------------------------------------------------
60 | if (UCL.getConfig().getLastHotbarPage().isEnabled())
61 | UPL.goToPageQuietly(UCL.getConfig().getLastHotbarPage().getPage());
62 | }
63 | }
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/commands/CacheCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.core.commands;
19 |
20 | import com.mojang.brigadier.Command;
21 | import com.mojang.brigadier.context.CommandContext;
22 | import me.videogamesm12.hotbarsplus.api.util.Util;
23 | import me.videogamesm12.hotbarsplus.core.HBPCore;
24 | import net.kyori.adventure.text.Component;
25 | import net.kyori.adventure.text.JoinConfiguration;
26 | import net.minecraft.client.MinecraftClient;
27 |
28 | import java.util.ArrayList;
29 | import java.util.List;
30 |
31 | public interface CacheCommand
32 | {
33 | interface ListCommand extends Command
34 | {
35 | @Override
36 | default int run(CommandContext context)
37 | {
38 | if (MinecraftClient.getInstance().player == null)
39 | {
40 | // WTF?
41 | return 1;
42 | }
43 |
44 | Util.msg(Component.translatable("command.cache.list.amount", Component.text(HBPCore.UPL.getCacheSize())));
45 |
46 | List texts = new ArrayList<>();
47 | HBPCore.UPL.getCache().keySet().stream().sorted().forEach((key) -> texts.add(Component.text(Util.getHotbarFilename(key))));
48 |
49 | Util.msg(Component.translatable("command.cache.list.entries",
50 | Component.join(JoinConfiguration.builder().separator(Component.text(", ")).build(), texts)));
51 | return 1;
52 | }
53 |
54 | static ListCommand impl()
55 | {
56 | return new ListCommand() {};
57 | }
58 | }
59 |
60 | interface ClearCommand extends Command
61 | {
62 | @Override
63 | default int run(CommandContext context)
64 | {
65 | if (MinecraftClient.getInstance().player == null)
66 | {
67 | // WTF?
68 | return 1;
69 | }
70 |
71 | HBPCore.UPL.getCache().clear();
72 |
73 | Util.msg(Component.translatable("command.cache.clear.success"));
74 | return 1;
75 | }
76 |
77 | static ClearCommand impl()
78 | {
79 | return new ClearCommand() {};
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/api/util/Util.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.api.util;
19 |
20 | import com.google.gson.JsonElement;
21 | import me.videogamesm12.hotbarsplus.core.HBPCore;
22 | import net.kyori.adventure.text.Component;
23 | import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
24 | import net.minecraft.client.MinecraftClient;
25 | import net.minecraft.text.Text;
26 |
27 | import java.io.File;
28 | import java.math.BigInteger;
29 |
30 | public class Util
31 | {
32 | private static final GsonComponentSerializer kyori = GsonComponentSerializer.builder().build();
33 |
34 | public static File getHotbarFolder()
35 | {
36 | File folder = new File(MinecraftClient.getInstance().runDirectory, "hotbars");
37 |
38 | if (!folder.isDirectory())
39 | {
40 | folder.mkdir();
41 | }
42 |
43 | return folder;
44 | }
45 |
46 | public static File getHotbarFolderForPage(BigInteger page)
47 | {
48 | return page.equals(BigInteger.ZERO) ? MinecraftClient.getInstance().runDirectory : getHotbarFolder();
49 | }
50 |
51 | public static File getHotbarFile(BigInteger page)
52 | {
53 | return new File(getHotbarFolderForPage(page), getHotbarFilename(page));
54 | }
55 |
56 | public static String getHotbarFilename(BigInteger page)
57 | {
58 | return page.equals(BigInteger.ZERO) ? "hotbar.nbt" : "hotbar." + page + ".nbt";
59 | }
60 |
61 | /**
62 | * Uses GSON magic to convert Adventure components to native Minecraft components.
63 | * @param component Component
64 | * @return Text
65 | */
66 | public static Text advToNative(Component component)
67 | {
68 | JsonElement element = kyori.serializeToTree(component);
69 |
70 | if (HBPCore.VHOOKS != null)
71 | return HBPCore.VHOOKS.convertFromJson(element);
72 | else
73 | return Text.Serializer.fromJson(element);
74 | }
75 |
76 | public static void msg(Component component)
77 | {
78 | if (MinecraftClient.getInstance().player == null)
79 | {
80 | return;
81 | }
82 |
83 | MinecraftClient.getInstance().player.sendMessage(advToNative(component), false);
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/manager/CommandManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.legacy.manager;
19 |
20 | import com.mojang.brigadier.CommandDispatcher;
21 | import com.mojang.brigadier.arguments.LongArgumentType;
22 | import com.mojang.brigadier.tree.LiteralCommandNode;
23 | import io.github.cottonmc.clientcommands.ArgumentBuilders;
24 | import io.github.cottonmc.clientcommands.ClientCommandPlugin;
25 | import io.github.cottonmc.clientcommands.CottonClientCommandSource;
26 | import me.videogamesm12.hotbarsplus.api.manager.ICommandManager;
27 | import me.videogamesm12.hotbarsplus.core.commands.*;
28 |
29 | public class CommandManager implements ICommandManager, ClientCommandPlugin
30 | {
31 | private LiteralCommandNode hotbarsPlusCommand;
32 |
33 | @Override
34 | public void register()
35 | {
36 | // Don't do anything here as Cotton Client Commands does the work for us
37 | }
38 |
39 | @Override
40 | public LiteralCommandNode getCommandNode()
41 | {
42 | return hotbarsPlusCommand;
43 | }
44 |
45 | @Override
46 | public void registerCommands(CommandDispatcher dispatcher)
47 | {
48 | hotbarsPlusCommand = dispatcher.register(
49 | ArgumentBuilders.literal("hotbars+").then(
50 | ArgumentBuilders.literal("backup").executes(BackupCommand.impl())
51 | ).then(
52 | ArgumentBuilders.literal("next").executes(NextCommand.impl())
53 | ).then(
54 | ArgumentBuilders.literal("previous").executes(PreviousCommand.impl())
55 | ).then(
56 | ArgumentBuilders.literal("goto").then(
57 | ArgumentBuilders.argument("page", LongArgumentType.longArg()).executes(GoToCommand.impl())
58 | )
59 | ).then(
60 | ArgumentBuilders.literal("cache").then(
61 | ArgumentBuilders.literal("list").executes(CacheCommand.ListCommand.impl())
62 | ).then(
63 | ArgumentBuilders.literal("clear").executes(CacheCommand.ClearCommand.impl())
64 | )
65 | )
66 | );
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/HotbarsPlus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_19;
19 |
20 | import me.videogamesm12.hotbarsplus.api.event.navigation.HotbarNavigateEvent;
21 | import me.videogamesm12.hotbarsplus.core.HBPCore;
22 | import me.videogamesm12.hotbarsplus.v1_19.manager.CommandManager;
23 | import me.videogamesm12.hotbarsplus.v1_19.manager.CustomToastManager;
24 | import me.videogamesm12.hotbarsplus.v1_19.manager.KeybindManager;
25 | import me.videogamesm12.hotbarsplus.v1_19.mixin.CreativeInvScreenAccessor;
26 | import net.fabricmc.api.ClientModInitializer;
27 | import net.minecraft.client.MinecraftClient;
28 | import net.minecraft.client.gui.screen.Screen;
29 | import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
30 | import net.minecraft.item.ItemGroup;
31 | import net.minecraft.item.ItemGroups;
32 | import net.minecraft.util.ActionResult;
33 |
34 | import java.math.BigInteger;
35 |
36 | public class HotbarsPlus implements ClientModInitializer, HotbarNavigateEvent
37 | {
38 | @Override
39 | public void onInitializeClient()
40 | {
41 | HBPCore.COMMANDS = new CommandManager();
42 | HBPCore.KEYBINDS = new KeybindManager();
43 | HBPCore.TOASTS = new CustomToastManager();
44 | //--
45 | HotbarNavigateEvent.EVENT.register(this);
46 | }
47 |
48 | @Override
49 | public ActionResult onNavigate(BigInteger page)
50 | {
51 | MinecraftClient client = MinecraftClient.getInstance();
52 | Screen openScreen = client.currentScreen;
53 |
54 | if (openScreen == null)
55 | {
56 | return ActionResult.PASS;
57 | }
58 |
59 | // Refreshes the menu if it is currently open;
60 | if (!(openScreen instanceof CreativeInventoryScreen)) {
61 | return ActionResult.PASS;
62 | }
63 |
64 | CreativeInventoryScreen creativeScreen = (CreativeInventoryScreen) openScreen;
65 | CreativeInvScreenAccessor accessor = (CreativeInvScreenAccessor) creativeScreen;
66 | ItemGroup currentTab = accessor.getSelectedTab();
67 |
68 | if (currentTab != ItemGroups.HOTBAR) {
69 | return ActionResult.PASS;
70 | }
71 |
72 | accessor.invokeSetSelectedTab(ItemGroups.HOTBAR);
73 |
74 | return ActionResult.PASS;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/HotbarsPlus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.legacy;
19 |
20 | import me.videogamesm12.hotbarsplus.api.event.navigation.HotbarNavigateEvent;
21 | import me.videogamesm12.hotbarsplus.core.HBPCore;
22 | import me.videogamesm12.hotbarsplus.legacy.manager.CommandManager;
23 | import me.videogamesm12.hotbarsplus.legacy.manager.CustomToastManager;
24 | import me.videogamesm12.hotbarsplus.legacy.manager.KeybindManager;
25 | import me.videogamesm12.hotbarsplus.legacy.mixin.CreativeInvScreenMixin;
26 | import net.fabricmc.api.ClientModInitializer;
27 | import net.fabricmc.loader.api.FabricLoader;
28 | import net.minecraft.client.MinecraftClient;
29 | import net.minecraft.client.gui.screen.Screen;
30 | import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
31 | import net.minecraft.item.ItemGroup;
32 | import net.minecraft.util.ActionResult;
33 |
34 | import java.math.BigInteger;
35 |
36 | public class HotbarsPlus implements ClientModInitializer, HotbarNavigateEvent
37 | {
38 | @Override
39 | public void onInitializeClient()
40 | {
41 | HBPCore.KEYBINDS = new KeybindManager();
42 | //--
43 | if (FabricLoader.getInstance().isModLoaded("cotton-client-commands"))
44 | {
45 | HBPCore.COMMANDS = new CommandManager();
46 | }
47 | else
48 | {
49 | HBPCore.LOGGER.warn("Cotton Client Commands was not found. In-game commands will not work.");
50 | }
51 | //--
52 | HBPCore.TOASTS = new CustomToastManager();
53 | HBPCore.VHOOKS = new FourteenHooks();
54 | //--
55 | HotbarNavigateEvent.EVENT.register(this);
56 | }
57 |
58 | @Override
59 | public ActionResult onNavigate(BigInteger page)
60 | {
61 | // Refreshes the menu if it is currently open;
62 | if (MinecraftClient.getInstance().currentScreen instanceof CreativeInventoryScreen)
63 | {
64 | Screen screen = MinecraftClient.getInstance().currentScreen;
65 |
66 | if (((CreativeInvScreenMixin.CISAccessor) screen).getSelectedTab() == ItemGroup.HOTBAR.getIndex())
67 | {
68 | ((CreativeInvScreenMixin.CISAccessor) screen).setSelectedTab(ItemGroup.HOTBAR);
69 | }
70 | }
71 |
72 | return ActionResult.PASS;
73 | }
74 | }
--------------------------------------------------------------------------------
/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/KeybindManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_16.manager;
19 |
20 | import me.videogamesm12.hotbarsplus.api.manager.IKeybindManager;
21 | import me.videogamesm12.hotbarsplus.api.event.keybind.BackupBindPressEvent;
22 | import me.videogamesm12.hotbarsplus.api.event.keybind.NextBindPressEvent;
23 | import me.videogamesm12.hotbarsplus.api.event.keybind.PreviousBindPressEvent;
24 | import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
25 | import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
26 | import net.minecraft.client.MinecraftClient;
27 | import net.minecraft.client.option.KeyBinding;
28 | import net.minecraft.client.util.InputUtil;
29 | import org.lwjgl.glfw.GLFW;
30 |
31 | public class KeybindManager implements IKeybindManager, ClientTickEvents.EndTick
32 | {
33 | public KeyBinding backup = new KeyBinding("key.hotbarsplus.backup", InputUtil.Type.KEYSYM,
34 | GLFW.GLFW_KEY_UNKNOWN, "category.hotbarsplus.navigation");
35 | public KeyBinding next = new KeyBinding("key.hotbarsplus.next", InputUtil.Type.KEYSYM,
36 | GLFW.GLFW_KEY_RIGHT_BRACKET, "category.hotbarsplus.navigation");
37 | public KeyBinding previous = new KeyBinding("key.hotbarsplus.previous", InputUtil.Type.KEYSYM,
38 | GLFW.GLFW_KEY_LEFT_BRACKET, "category.hotbarsplus.navigation");
39 |
40 | public KeybindManager()
41 | {
42 | registerKeybinds();
43 | }
44 |
45 | @Override
46 | public void registerKeybinds()
47 | {
48 | backup = KeyBindingHelper.registerKeyBinding(backup);
49 | next = KeyBindingHelper.registerKeyBinding(next);
50 | previous = KeyBindingHelper.registerKeyBinding(previous);
51 | //--
52 | ClientTickEvents.END_CLIENT_TICK.register(this);
53 | }
54 |
55 | @Override
56 | public void onEndTick(MinecraftClient client)
57 | {
58 | if (backup.wasPressed())
59 | {
60 | BackupBindPressEvent.EVENT.invoker().onBackupPress();
61 | }
62 |
63 | if (next.wasPressed())
64 | {
65 | NextBindPressEvent.EVENT.invoker().onNextPress();
66 | }
67 | else if (previous.wasPressed())
68 | {
69 | PreviousBindPressEvent.EVENT.invoker().onPreviousPress();
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/manager/KeybindManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_17.manager;
19 |
20 | import me.videogamesm12.hotbarsplus.api.manager.IKeybindManager;
21 | import me.videogamesm12.hotbarsplus.api.event.keybind.BackupBindPressEvent;
22 | import me.videogamesm12.hotbarsplus.api.event.keybind.NextBindPressEvent;
23 | import me.videogamesm12.hotbarsplus.api.event.keybind.PreviousBindPressEvent;
24 | import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
25 | import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
26 | import net.minecraft.client.MinecraftClient;
27 | import net.minecraft.client.option.KeyBinding;
28 | import net.minecraft.client.util.InputUtil;
29 | import org.lwjgl.glfw.GLFW;
30 |
31 | public class KeybindManager implements IKeybindManager, ClientTickEvents.EndTick
32 | {
33 | public KeyBinding backup = new KeyBinding("key.hotbarsplus.backup", InputUtil.Type.KEYSYM,
34 | GLFW.GLFW_KEY_UNKNOWN, "category.hotbarsplus.navigation");
35 | public KeyBinding next = new KeyBinding("key.hotbarsplus.next", InputUtil.Type.KEYSYM,
36 | GLFW.GLFW_KEY_RIGHT_BRACKET, "category.hotbarsplus.navigation");
37 | public KeyBinding previous = new KeyBinding("key.hotbarsplus.previous", InputUtil.Type.KEYSYM,
38 | GLFW.GLFW_KEY_LEFT_BRACKET, "category.hotbarsplus.navigation");
39 |
40 | public KeybindManager()
41 | {
42 | registerKeybinds();
43 | }
44 |
45 | @Override
46 | public void registerKeybinds()
47 | {
48 | backup = KeyBindingHelper.registerKeyBinding(backup);
49 | next = KeyBindingHelper.registerKeyBinding(next);
50 | previous = KeyBindingHelper.registerKeyBinding(previous);
51 | //--
52 | ClientTickEvents.END_CLIENT_TICK.register(this);
53 | }
54 |
55 | @Override
56 | public void onEndTick(MinecraftClient client)
57 | {
58 | if (backup.wasPressed())
59 | {
60 | BackupBindPressEvent.EVENT.invoker().onBackupPress();
61 | }
62 |
63 | if (next.wasPressed())
64 | {
65 | NextBindPressEvent.EVENT.invoker().onNextPress();
66 | }
67 | else if (previous.wasPressed())
68 | {
69 | PreviousBindPressEvent.EVENT.invoker().onPreviousPress();
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/KeybindManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_19.manager;
19 |
20 | import me.videogamesm12.hotbarsplus.api.manager.IKeybindManager;
21 | import me.videogamesm12.hotbarsplus.api.event.keybind.BackupBindPressEvent;
22 | import me.videogamesm12.hotbarsplus.api.event.keybind.NextBindPressEvent;
23 | import me.videogamesm12.hotbarsplus.api.event.keybind.PreviousBindPressEvent;
24 | import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
25 | import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
26 | import net.minecraft.client.MinecraftClient;
27 | import net.minecraft.client.option.KeyBinding;
28 | import net.minecraft.client.util.InputUtil;
29 | import org.lwjgl.glfw.GLFW;
30 |
31 | public class KeybindManager implements IKeybindManager, ClientTickEvents.EndTick
32 | {
33 | public KeyBinding backup = new KeyBinding("key.hotbarsplus.backup", InputUtil.Type.KEYSYM,
34 | GLFW.GLFW_KEY_UNKNOWN, "category.hotbarsplus.navigation");
35 | public KeyBinding next = new KeyBinding("key.hotbarsplus.next", InputUtil.Type.KEYSYM,
36 | GLFW.GLFW_KEY_RIGHT_BRACKET, "category.hotbarsplus.navigation");
37 | public KeyBinding previous = new KeyBinding("key.hotbarsplus.previous", InputUtil.Type.KEYSYM,
38 | GLFW.GLFW_KEY_LEFT_BRACKET, "category.hotbarsplus.navigation");
39 |
40 | public KeybindManager()
41 | {
42 | registerKeybinds();
43 | }
44 |
45 | @Override
46 | public void registerKeybinds()
47 | {
48 | backup = KeyBindingHelper.registerKeyBinding(backup);
49 | next = KeyBindingHelper.registerKeyBinding(next);
50 | previous = KeyBindingHelper.registerKeyBinding(previous);
51 | //--
52 | ClientTickEvents.END_CLIENT_TICK.register(this);
53 | }
54 |
55 | @Override
56 | public void onEndTick(MinecraftClient client)
57 | {
58 | if (backup.wasPressed())
59 | {
60 | BackupBindPressEvent.EVENT.invoker().onBackupPress();
61 | }
62 |
63 | if (next.wasPressed())
64 | {
65 | NextBindPressEvent.EVENT.invoker().onNextPress();
66 | }
67 | else if (previous.wasPressed())
68 | {
69 | PreviousBindPressEvent.EVENT.invoker().onPreviousPress();
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/1_20/src/main/java/me/videogamesm12/hotbarsplus/v1_20/manager/KeybindManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_20.manager;
19 |
20 | import me.videogamesm12.hotbarsplus.api.event.keybind.BackupBindPressEvent;
21 | import me.videogamesm12.hotbarsplus.api.event.keybind.NextBindPressEvent;
22 | import me.videogamesm12.hotbarsplus.api.event.keybind.PreviousBindPressEvent;
23 | import me.videogamesm12.hotbarsplus.api.manager.IKeybindManager;
24 | import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
25 | import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
26 | import net.minecraft.client.MinecraftClient;
27 | import net.minecraft.client.option.KeyBinding;
28 | import net.minecraft.client.util.InputUtil;
29 | import org.lwjgl.glfw.GLFW;
30 |
31 | public class KeybindManager implements IKeybindManager, ClientTickEvents.EndTick
32 | {
33 | public KeyBinding backup = new KeyBinding("key.hotbarsplus.backup", InputUtil.Type.KEYSYM,
34 | GLFW.GLFW_KEY_UNKNOWN, "category.hotbarsplus.navigation");
35 | public KeyBinding next = new KeyBinding("key.hotbarsplus.next", InputUtil.Type.KEYSYM,
36 | GLFW.GLFW_KEY_RIGHT_BRACKET, "category.hotbarsplus.navigation");
37 | public KeyBinding previous = new KeyBinding("key.hotbarsplus.previous", InputUtil.Type.KEYSYM,
38 | GLFW.GLFW_KEY_LEFT_BRACKET, "category.hotbarsplus.navigation");
39 |
40 | public KeybindManager()
41 | {
42 | registerKeybinds();
43 | }
44 |
45 | @Override
46 | public void registerKeybinds()
47 | {
48 | backup = KeyBindingHelper.registerKeyBinding(backup);
49 | next = KeyBindingHelper.registerKeyBinding(next);
50 | previous = KeyBindingHelper.registerKeyBinding(previous);
51 | //--
52 | ClientTickEvents.END_CLIENT_TICK.register(this);
53 | }
54 |
55 | @Override
56 | public void onEndTick(MinecraftClient client)
57 | {
58 | if (backup.wasPressed())
59 | {
60 | BackupBindPressEvent.EVENT.invoker().onBackupPress();
61 | }
62 |
63 | if (next.wasPressed())
64 | {
65 | NextBindPressEvent.EVENT.invoker().onNextPress();
66 | }
67 | else if (previous.wasPressed())
68 | {
69 | PreviousBindPressEvent.EVENT.invoker().onPreviousPress();
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/manager/KeybindManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.legacy.manager;
19 |
20 | import me.videogamesm12.hotbarsplus.api.manager.IKeybindManager;
21 | import me.videogamesm12.hotbarsplus.api.event.keybind.BackupBindPressEvent;
22 | import me.videogamesm12.hotbarsplus.api.event.keybind.NextBindPressEvent;
23 | import me.videogamesm12.hotbarsplus.api.event.keybind.PreviousBindPressEvent;
24 | import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
25 | import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
26 | import net.minecraft.client.MinecraftClient;
27 | import net.minecraft.client.options.KeyBinding;
28 | import net.minecraft.client.util.InputUtil;
29 | import org.lwjgl.glfw.GLFW;
30 |
31 | public class KeybindManager implements IKeybindManager, ClientTickEvents.EndTick
32 | {
33 | public KeyBinding backup = new KeyBinding("key.hotbarsplus.backup", InputUtil.Type.KEYSYM,
34 | GLFW.GLFW_KEY_UNKNOWN, "category.hotbarsplus.navigation");
35 | public KeyBinding next = new KeyBinding("key.hotbarsplus.next", InputUtil.Type.KEYSYM,
36 | GLFW.GLFW_KEY_RIGHT_BRACKET, "category.hotbarsplus.navigation");
37 | public KeyBinding previous = new KeyBinding("key.hotbarsplus.previous", InputUtil.Type.KEYSYM,
38 | GLFW.GLFW_KEY_LEFT_BRACKET, "category.hotbarsplus.navigation");
39 |
40 | public KeybindManager()
41 | {
42 | registerKeybinds();
43 | }
44 |
45 | @Override
46 | public void registerKeybinds()
47 | {
48 | backup = KeyBindingHelper.registerKeyBinding(backup);
49 | next = KeyBindingHelper.registerKeyBinding(next);
50 | previous = KeyBindingHelper.registerKeyBinding(previous);
51 | //--
52 | ClientTickEvents.END_CLIENT_TICK.register(this);
53 | }
54 |
55 | @Override
56 | public void onEndTick(MinecraftClient client)
57 | {
58 | if (backup.wasPressed())
59 | {
60 | BackupBindPressEvent.EVENT.invoker().onBackupPress();
61 | }
62 |
63 | if (next.wasPressed())
64 | {
65 | NextBindPressEvent.EVENT.invoker().onNextPress();
66 | }
67 | else if (previous.wasPressed())
68 | {
69 | PreviousBindPressEvent.EVENT.invoker().onPreviousPress();
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/KeybindManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_19.manager;
19 |
20 | import me.videogamesm12.hotbarsplus.api.manager.IKeybindManager;
21 | import me.videogamesm12.hotbarsplus.api.event.keybind.BackupBindPressEvent;
22 | import me.videogamesm12.hotbarsplus.api.event.keybind.NextBindPressEvent;
23 | import me.videogamesm12.hotbarsplus.api.event.keybind.PreviousBindPressEvent;
24 | import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
25 | import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
26 | import net.minecraft.client.MinecraftClient;
27 | import net.minecraft.client.option.KeyBinding;
28 | import net.minecraft.client.util.InputUtil;
29 | import org.lwjgl.glfw.GLFW;
30 |
31 | public class KeybindManager implements IKeybindManager, ClientTickEvents.EndTick
32 | {
33 | public KeyBinding backup = new KeyBinding("key.hotbarsplus.backup", InputUtil.Type.KEYSYM,
34 | GLFW.GLFW_KEY_UNKNOWN, "category.hotbarsplus.navigation");
35 | public KeyBinding next = new KeyBinding("key.hotbarsplus.next", InputUtil.Type.KEYSYM,
36 | GLFW.GLFW_KEY_RIGHT_BRACKET, "category.hotbarsplus.navigation");
37 | public KeyBinding previous = new KeyBinding("key.hotbarsplus.previous", InputUtil.Type.KEYSYM,
38 | GLFW.GLFW_KEY_LEFT_BRACKET, "category.hotbarsplus.navigation");
39 |
40 | public KeybindManager()
41 | {
42 | registerKeybinds();
43 | }
44 |
45 | @Override
46 | public void registerKeybinds()
47 | {
48 | backup = KeyBindingHelper.registerKeyBinding(backup);
49 | next = KeyBindingHelper.registerKeyBinding(next);
50 | previous = KeyBindingHelper.registerKeyBinding(previous);
51 | //--
52 | ClientTickEvents.END_CLIENT_TICK.register(this);
53 | }
54 |
55 | @Override
56 | public void onEndTick(MinecraftClient client)
57 | {
58 | if (backup.wasPressed())
59 | {
60 | BackupBindPressEvent.EVENT.invoker().onBackupPress();
61 | }
62 |
63 | if (next.wasPressed())
64 | {
65 | NextBindPressEvent.EVENT.invoker().onNextPress();
66 | }
67 | else if (previous.wasPressed())
68 | {
69 | PreviousBindPressEvent.EVENT.invoker().onPreviousPress();
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/FallbackCommandManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 |
19 | package me.videogamesm12.hotbarsplus.v1_16.manager;
20 |
21 | import com.mojang.brigadier.CommandDispatcher;
22 | import com.mojang.brigadier.arguments.LongArgumentType;
23 | import com.mojang.brigadier.tree.LiteralCommandNode;
24 | import io.github.cottonmc.clientcommands.ArgumentBuilders;
25 | import io.github.cottonmc.clientcommands.ClientCommandPlugin;
26 | import io.github.cottonmc.clientcommands.CottonClientCommandSource;
27 | import me.videogamesm12.hotbarsplus.api.manager.ICommandManager;
28 | import me.videogamesm12.hotbarsplus.core.commands.*;
29 |
30 | public class FallbackCommandManager implements ICommandManager, ClientCommandPlugin
31 | {
32 | private LiteralCommandNode hotbarsPlusCommand;
33 |
34 | @Override
35 | public void register()
36 | {
37 | // Unused, Cotton Client Commands does all the magic for us
38 | }
39 |
40 | @Override
41 | public LiteralCommandNode getCommandNode()
42 | {
43 | return hotbarsPlusCommand;
44 | }
45 |
46 | @Override
47 | public void registerCommands(CommandDispatcher dispatcher)
48 | {
49 | hotbarsPlusCommand = dispatcher.register(
50 | ArgumentBuilders.literal("hotbars+").then(
51 | ArgumentBuilders.literal("backup").executes(BackupCommand.impl())
52 | ).then(
53 | ArgumentBuilders.literal("next").executes(NextCommand.impl())
54 | ).then(
55 | ArgumentBuilders.literal("previous").executes(PreviousCommand.impl())
56 | ).then(
57 | ArgumentBuilders.literal("goto").then(
58 | ArgumentBuilders.argument("page", LongArgumentType.longArg()).executes(GoToCommand.impl())
59 | )
60 | ).then(
61 | ArgumentBuilders.literal("cache").then(
62 | ArgumentBuilders.literal("list").executes(CacheCommand.ListCommand.impl())
63 | ).then(
64 | ArgumentBuilders.literal("clear").executes(CacheCommand.ClearCommand.impl())
65 | )
66 | )
67 | );
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/1_20/src/main/java/me/videogamesm12/hotbarsplus/v1_20/HotbarsPlus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_20;
19 |
20 | import me.videogamesm12.hotbarsplus.api.event.navigation.HotbarNavigateEvent;
21 | import me.videogamesm12.hotbarsplus.core.HBPCore;
22 | import me.videogamesm12.hotbarsplus.v1_20.manager.CommandManager;
23 | import me.videogamesm12.hotbarsplus.v1_20.manager.CustomToastManager;
24 | import me.videogamesm12.hotbarsplus.v1_20.manager.KeybindManager;
25 | import me.videogamesm12.hotbarsplus.v1_20.mixin.CreativeInvScreenAccessor;
26 | import net.fabricmc.api.ClientModInitializer;
27 | import net.minecraft.client.MinecraftClient;
28 | import net.minecraft.client.gui.screen.Screen;
29 | import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
30 | import net.minecraft.item.ItemGroup;
31 | import net.minecraft.item.ItemGroups;
32 | import net.minecraft.registry.Registries;
33 | import net.minecraft.util.ActionResult;
34 |
35 | import java.math.BigInteger;
36 |
37 | public class HotbarsPlus implements ClientModInitializer, HotbarNavigateEvent
38 | {
39 | @Override
40 | public void onInitializeClient()
41 | {
42 | HBPCore.COMMANDS = new CommandManager();
43 | HBPCore.KEYBINDS = new KeybindManager();
44 | HBPCore.TOASTS = new CustomToastManager();
45 | //--
46 | HotbarNavigateEvent.EVENT.register(this);
47 | }
48 |
49 | @Override
50 | public ActionResult onNavigate(BigInteger page)
51 | {
52 | MinecraftClient client = MinecraftClient.getInstance();
53 | Screen openScreen = client.currentScreen;
54 |
55 | if (openScreen == null)
56 | {
57 | return ActionResult.PASS;
58 | }
59 |
60 | // Refreshes the menu if it is currently open
61 | if (!(openScreen instanceof CreativeInventoryScreen))
62 | {
63 | return ActionResult.PASS;
64 | }
65 |
66 | CreativeInventoryScreen creativeScreen = (CreativeInventoryScreen) openScreen;
67 | CreativeInvScreenAccessor accessor = (CreativeInvScreenAccessor) creativeScreen;
68 | ItemGroup currentTab = accessor.getSelectedTab();
69 |
70 | if (currentTab.getType() != ItemGroup.Type.HOTBAR)
71 | {
72 | return ActionResult.PASS;
73 | }
74 |
75 | accessor.invokeSetSelectedTab(Registries.ITEM_GROUP.get(ItemGroups.HOTBAR));
76 |
77 | return ActionResult.PASS;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/universal/BackupManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.core.universal;
19 |
20 | import me.videogamesm12.hotbarsplus.api.event.failures.BackupFailEvent;
21 | import me.videogamesm12.hotbarsplus.api.event.keybind.BackupBindPressEvent;
22 | import me.videogamesm12.hotbarsplus.api.event.success.BackupSuccessEvent;
23 | import me.videogamesm12.hotbarsplus.api.util.Util;
24 | import me.videogamesm12.hotbarsplus.core.HBPCore;
25 | import me.videogamesm12.hotbarsplus.core.mixin.HotbarStorageMixin;
26 | import org.apache.commons.io.FileUtils;
27 |
28 | import java.io.File;
29 | import java.text.SimpleDateFormat;
30 | import java.util.Date;
31 |
32 | public class BackupManager extends Thread implements BackupBindPressEvent
33 | {
34 | private final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH.mm.ss z");
35 |
36 | public BackupManager()
37 | {
38 | start();
39 | }
40 |
41 | @Override
42 | public void run()
43 | {
44 | BackupBindPressEvent.EVENT.register(this);
45 | }
46 |
47 | @Override
48 | public synchronized void onBackupPress()
49 | {
50 | if (!HBPCore.UPL.hotbarPageExists())
51 | {
52 | return;
53 | }
54 |
55 | backupHotbar();
56 | }
57 |
58 | public synchronized void backupHotbar(File file)
59 | {
60 | String name = String.format("%s [%s].nbt", file.getName(), FORMAT.format(new Date()));
61 | File destination = new File(getBackupFolder(), name);
62 |
63 | // Let's try to copy the file from one place to the next. If that works call the event that indicates such.
64 | try
65 | {
66 | FileUtils.copyFile(file, destination);
67 |
68 | BackupSuccessEvent.EVENT.invoker().onBackupSuccess(file, destination);
69 | }
70 | // Well shit that didn't work. Call the event that indicates the failure
71 | catch (Exception ex)
72 | {
73 | BackupFailEvent.EVENT.invoker().onBackupFailure(ex);
74 |
75 | HBPCore.LOGGER.error("Failed to backup hotbar file", ex);
76 | }
77 | }
78 |
79 | public synchronized void backupHotbar()
80 | {
81 | backupHotbar(((HotbarStorageMixin.HSAccessor) HBPCore.UPL.getHotbarPage()).getFile());
82 | }
83 |
84 | public File getBackupFolder()
85 | {
86 | File folder = new File(Util.getHotbarFolder(), "backups");
87 |
88 | if (!folder.isDirectory())
89 | {
90 | folder.mkdirs();
91 | }
92 |
93 | return folder;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/api/config/Configuration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.api.config;
19 |
20 | import lombok.Getter;
21 | import lombok.Setter;
22 | import me.videogamesm12.hotbarsplus.api.event.navigation.HotbarNavigateEvent;
23 | import me.videogamesm12.hotbarsplus.api.event.notification.NotificationTypeRegistered;
24 | import me.videogamesm12.hotbarsplus.core.HBPCore;
25 | import me.videogamesm12.hotbarsplus.core.universal.NotificationManager;
26 | import net.fabricmc.loader.api.FabricLoader;
27 | import net.minecraft.util.ActionResult;
28 | import net.minecraft.util.Identifier;
29 |
30 | import java.io.File;
31 | import java.math.BigInteger;
32 | import java.util.HashMap;
33 | import java.util.Map;
34 |
35 | /**
36 | * Configuration
37 | * The configuration class for Hotbars+. Note that this doesn't control the configuration, it just stores the data from it.
38 | */
39 | public class Configuration
40 | {
41 | @Getter
42 | private static final File location = new File(FabricLoader.getInstance().getConfigDir().toFile(), "hotbarsplus.json");
43 |
44 | @Getter
45 | private Notifications notificationConfig = new Notifications();
46 |
47 | @Getter
48 | private LastHotbarPage lastHotbarPage = new LastHotbarPage();
49 |
50 | @Getter
51 | public static class Notifications implements NotificationTypeRegistered
52 | {
53 | @Setter
54 | private boolean enabled = true;
55 |
56 | private Map types = new HashMap<>();
57 |
58 | /**
59 | * Returns whether a given notification route is enabled
60 | * @param id Identifier
61 | * @return True if the notification route is enabled
62 | */
63 | public boolean isTypeEnabled(Identifier id)
64 | {
65 | return types.getOrDefault(id.toString(), true);
66 | }
67 |
68 | @Override
69 | public void onTypeRegistered(NotificationManager.NotificationRoute type)
70 | {
71 | if (!types.containsKey(type.getId().toString()))
72 | types.put(type.getId().toString(), true);
73 | }
74 | }
75 |
76 | @Getter
77 | @Setter
78 | public static class LastHotbarPage implements HotbarNavigateEvent
79 | {
80 | private boolean enabled = true;
81 |
82 | private BigInteger page = HBPCore.UPL.getCurrentPage();
83 |
84 | @Override
85 | public ActionResult onNavigate(BigInteger page)
86 | {
87 | if (isEnabled())
88 | {
89 | this.page = page;
90 | }
91 |
92 | return ActionResult.PASS;
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CommandManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_19.manager;
19 |
20 | import com.mojang.brigadier.CommandDispatcher;
21 | import com.mojang.brigadier.arguments.LongArgumentType;
22 | import com.mojang.brigadier.tree.LiteralCommandNode;
23 | import me.videogamesm12.hotbarsplus.api.manager.ICommandManager;
24 | import me.videogamesm12.hotbarsplus.core.commands.*;
25 | import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
26 | import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
27 | import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
28 | import net.minecraft.command.CommandRegistryAccess;
29 |
30 | public class CommandManager implements ICommandManager, ClientCommandRegistrationCallback
31 | {
32 | private LiteralCommandNode hotbarsPlusCommand;
33 |
34 | public CommandManager()
35 | {
36 | ClientCommandRegistrationCallback.EVENT.register(this);
37 | }
38 |
39 | @Override
40 | public void register()
41 | {
42 | // Unused, Fabric API v2 removed the original method of registering commands
43 | }
44 |
45 | @Override
46 | public LiteralCommandNode getCommandNode()
47 | {
48 | return hotbarsPlusCommand;
49 | }
50 |
51 | @Override
52 | public void register(CommandDispatcher dispatcher, CommandRegistryAccess registryAccess)
53 | {
54 | hotbarsPlusCommand = dispatcher.register(
55 | ClientCommandManager.literal("hotbars+").then(
56 | ClientCommandManager.literal("backup").executes(BackupCommand.impl())
57 | ).then(
58 | ClientCommandManager.literal("next").executes(NextCommand.impl())
59 | ).then(
60 | ClientCommandManager.literal("previous").executes(PreviousCommand.impl())
61 | ).then(
62 | ClientCommandManager.literal("goto").then(
63 | ClientCommandManager.argument("page", LongArgumentType.longArg()).executes(GoToCommand.impl())
64 | )
65 | ).then(
66 | ClientCommandManager.literal("cache").then(
67 | ClientCommandManager.literal("list").executes(CacheCommand.ListCommand.impl())
68 | ).then(
69 | ClientCommandManager.literal("clear").executes(CacheCommand.ClearCommand.impl())
70 | )
71 | )
72 | );
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CommandManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_19.manager;
19 |
20 | import com.mojang.brigadier.CommandDispatcher;
21 | import com.mojang.brigadier.arguments.LongArgumentType;
22 | import com.mojang.brigadier.tree.LiteralCommandNode;
23 | import me.videogamesm12.hotbarsplus.api.manager.ICommandManager;
24 | import me.videogamesm12.hotbarsplus.core.commands.*;
25 | import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
26 | import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
27 | import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
28 | import net.minecraft.command.CommandRegistryAccess;
29 |
30 | public class CommandManager implements ICommandManager, ClientCommandRegistrationCallback
31 | {
32 | private LiteralCommandNode hotbarsPlusCommand;
33 |
34 | public CommandManager()
35 | {
36 | ClientCommandRegistrationCallback.EVENT.register(this);
37 | }
38 |
39 | @Override
40 | public void register()
41 | {
42 | // Unused, Fabric API v2 removed the original method of registering commands
43 | }
44 |
45 | @Override
46 | public LiteralCommandNode getCommandNode()
47 | {
48 | return hotbarsPlusCommand;
49 | }
50 |
51 | @Override
52 | public void register(CommandDispatcher dispatcher, CommandRegistryAccess registryAccess)
53 | {
54 | hotbarsPlusCommand = dispatcher.register(
55 | ClientCommandManager.literal("hotbars+").then(
56 | ClientCommandManager.literal("backup").executes(BackupCommand.impl())
57 | ).then(
58 | ClientCommandManager.literal("next").executes(NextCommand.impl())
59 | ).then(
60 | ClientCommandManager.literal("previous").executes(PreviousCommand.impl())
61 | ).then(
62 | ClientCommandManager.literal("goto").then(
63 | ClientCommandManager.argument("page", LongArgumentType.longArg()).executes(GoToCommand.impl())
64 | )
65 | ).then(
66 | ClientCommandManager.literal("cache").then(
67 | ClientCommandManager.literal("list").executes(CacheCommand.ListCommand.impl())
68 | ).then(
69 | ClientCommandManager.literal("clear").executes(CacheCommand.ClearCommand.impl())
70 | )
71 | )
72 | );
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/1_20/src/main/java/me/videogamesm12/hotbarsplus/v1_20/manager/CommandManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_20.manager;
19 |
20 | import com.mojang.brigadier.CommandDispatcher;
21 | import com.mojang.brigadier.arguments.LongArgumentType;
22 | import com.mojang.brigadier.tree.LiteralCommandNode;
23 | import me.videogamesm12.hotbarsplus.api.manager.ICommandManager;
24 | import me.videogamesm12.hotbarsplus.core.commands.*;
25 | import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
26 | import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
27 | import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
28 | import net.minecraft.command.CommandRegistryAccess;
29 |
30 | public class CommandManager implements ICommandManager, ClientCommandRegistrationCallback
31 | {
32 | private LiteralCommandNode hotbarsPlusCommand;
33 |
34 | public CommandManager()
35 | {
36 | ClientCommandRegistrationCallback.EVENT.register(this);
37 | }
38 |
39 | @Override
40 | public void register()
41 | {
42 | // Unused, Fabric API v2 removed the original method of registering commands
43 | }
44 |
45 | @Override
46 | public LiteralCommandNode getCommandNode()
47 | {
48 | return hotbarsPlusCommand;
49 | }
50 |
51 | @Override
52 | public void register(CommandDispatcher dispatcher, CommandRegistryAccess registryAccess)
53 | {
54 | hotbarsPlusCommand = dispatcher.register(
55 | ClientCommandManager.literal("hotbars+").then(
56 | ClientCommandManager.literal("backup").executes(BackupCommand.impl())
57 | ).then(
58 | ClientCommandManager.literal("next").executes(NextCommand.impl())
59 | ).then(
60 | ClientCommandManager.literal("previous").executes(PreviousCommand.impl())
61 | ).then(
62 | ClientCommandManager.literal("goto").then(
63 | ClientCommandManager.argument("page", LongArgumentType.longArg()).executes(GoToCommand.impl())
64 | )
65 | ).then(
66 | ClientCommandManager.literal("cache").then(
67 | ClientCommandManager.literal("list").executes(CacheCommand.ListCommand.impl())
68 | ).then(
69 | ClientCommandManager.literal("clear").executes(CacheCommand.ClearCommand.impl())
70 | )
71 | )
72 | );
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/1_20/src/main/java/me/videogamesm12/hotbarsplus/v1_20/manager/CustomToastManager.java:
--------------------------------------------------------------------------------
1 | package me.videogamesm12.hotbarsplus.v1_20.manager;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 | import me.videogamesm12.hotbarsplus.api.manager.IToastManager;
6 | import me.videogamesm12.hotbarsplus.core.universal.NotificationManager;
7 | import net.minecraft.client.MinecraftClient;
8 | import net.minecraft.client.gui.DrawContext;
9 | import net.minecraft.client.toast.Toast;
10 | import net.minecraft.client.toast.ToastManager;
11 | import net.minecraft.text.Text;
12 |
13 | public class CustomToastManager implements IToastManager
14 | {
15 | @Override
16 | public HotbarToast getToastFrom(NotificationManager.NotificationType type, Text... texts)
17 | {
18 | Text title;
19 | Text description;
20 |
21 | switch (texts.length)
22 | {
23 | case 0:
24 | {
25 | throw new IllegalArgumentException("Fuck you");
26 | }
27 | case 1:
28 | {
29 | title = texts[0];
30 | description = null;
31 | break;
32 | }
33 | default:
34 | case 2:
35 | {
36 | title = texts[0];
37 | description = texts[1];
38 | break;
39 | }
40 | }
41 |
42 | return new HotbarToast(title, description, type);
43 | }
44 |
45 | @Override
46 | public void showToast(IHotbarToast toast)
47 | {
48 | HotbarToast instance = MinecraftClient.getInstance().getToastManager().getToast(HotbarToast.class, toast.getType());
49 | if (instance == null)
50 | {
51 | MinecraftClient.getInstance().getToastManager().add((HotbarToast) toast);
52 | }
53 | else
54 | {
55 | HotbarToast hToast = (HotbarToast) toast;
56 | //--
57 | instance.setTitle(hToast.getTitle());
58 | instance.setDescription(hToast.getDescription());
59 | instance.setJustUpdated(true);
60 | }
61 | }
62 |
63 | @Getter
64 | @Setter
65 | public static class HotbarToast implements IHotbarToast, Toast
66 | {
67 | private Text title;
68 | private Text description;
69 | //--
70 | private NotificationManager.NotificationType type;
71 | private long time;
72 | //--
73 | private boolean justUpdated = true;
74 |
75 | public HotbarToast(Text title, Text description, NotificationManager.NotificationType type)
76 | {
77 | this.title = title;
78 | this.description = description;
79 | this.type = type;
80 | }
81 |
82 | @Override
83 | public Visibility draw(DrawContext context, ToastManager manager, long startTime)
84 | {
85 | if (justUpdated)
86 | {
87 | this.time = startTime;
88 | justUpdated = false;
89 | }
90 |
91 | context.drawTexture(IToastManager.TEXTURE, 0, 0, 0, 20, 160, 32, 160, 52);
92 | context.drawTexture(IToastManager.TEXTURE, 6, 6, 20 * type.ordinal(), 0, 20, 20, 160, 52);
93 | //--
94 | int titleY = description == null ? 12 : 7;
95 | context.drawText(MinecraftClient.getInstance().textRenderer, title, 30, titleY, type.getColor(), false);
96 |
97 | if (description != null)
98 | {
99 | context.drawText(MinecraftClient.getInstance().textRenderer, description.getString(), 30, 18, 0xFFFFFF, false);
100 | }
101 |
102 | return startTime - time >= 5000 ? Visibility.HIDE : Visibility.SHOW;
103 | }
104 |
105 | @Override
106 | public NotificationManager.NotificationType getType()
107 | {
108 | return type;
109 | }
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/1_14/src/main/java/me/videogamesm12/hotbarsplus/legacy/manager/CustomToastManager.java:
--------------------------------------------------------------------------------
1 | package me.videogamesm12.hotbarsplus.legacy.manager;
2 |
3 | import com.mojang.blaze3d.platform.GlStateManager;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import me.videogamesm12.hotbarsplus.api.manager.IToastManager;
7 | import me.videogamesm12.hotbarsplus.core.universal.NotificationManager;
8 | import net.minecraft.client.MinecraftClient;
9 | import net.minecraft.client.gui.DrawableHelper;
10 | import net.minecraft.client.toast.Toast;
11 | import net.minecraft.client.toast.ToastManager;
12 | import net.minecraft.text.Text;
13 |
14 | public class CustomToastManager implements IToastManager
15 | {
16 | @Override
17 | public HotbarToast getToastFrom(NotificationManager.NotificationType type, Text... texts)
18 | {
19 | Text title;
20 | Text description;
21 |
22 | switch (texts.length)
23 | {
24 | case 0:
25 | {
26 | throw new IllegalArgumentException("Fuck you");
27 | }
28 | case 1:
29 | {
30 | title = texts[0];
31 | description = null;
32 | break;
33 | }
34 | default:
35 | case 2:
36 | {
37 | title = texts[0];
38 | description = texts[1];
39 | break;
40 | }
41 | }
42 |
43 | return new HotbarToast(title, description, type);
44 | }
45 |
46 | @Override
47 | public void showToast(IHotbarToast toast)
48 | {
49 | HotbarToast instance = MinecraftClient.getInstance().getToastManager().getToast(HotbarToast.class, toast.getType());
50 | if (instance == null)
51 | {
52 | MinecraftClient.getInstance().getToastManager().add((HotbarToast) toast);
53 | }
54 | else
55 | {
56 | HotbarToast hToast = (HotbarToast) toast;
57 | //--
58 | instance.setTitle(hToast.getTitle());
59 | instance.setDescription(hToast.getDescription());
60 | instance.setJustUpdated(true);
61 | }
62 | }
63 |
64 | @Getter
65 | @Setter
66 | public static class HotbarToast implements IHotbarToast, Toast
67 | {
68 | private Text title;
69 | private Text description;
70 | //--
71 | private NotificationManager.NotificationType type;
72 | private long time;
73 | //--
74 | private boolean justUpdated = true;
75 |
76 | public HotbarToast(Text title, Text description, NotificationManager.NotificationType type)
77 | {
78 | this.title = title;
79 | this.description = description;
80 | this.type = type;
81 | }
82 |
83 | @Override
84 | public Visibility draw(ToastManager manager, long currentTime)
85 | {
86 | if (justUpdated)
87 | {
88 | this.time = currentTime;
89 | justUpdated = false;
90 | }
91 |
92 | MinecraftClient.getInstance().getTextureManager().bindTexture(TEXTURE);
93 | GlStateManager.color3f(1, 1, 1);
94 | DrawableHelper.blit(0, 0, 0, 20, 160, 32, 160, 52);
95 | //--
96 | GlStateManager.enableBlend();
97 | DrawableHelper.blit(6, 6, 20 * type.ordinal(), 0, 20, 20, 160, 52);
98 | GlStateManager.disableBlend();
99 | //--
100 | int titleY = description == null ? 12 : 7;
101 | MinecraftClient.getInstance().textRenderer.draw(title.asString(), 30, titleY, type.getColor());
102 |
103 | if (description != null)
104 | {
105 | MinecraftClient.getInstance().textRenderer.draw(description.asString(), 30, 18, 0xFFFFFF);
106 | }
107 |
108 | return currentTime - time >= 5000 ? Visibility.HIDE : Visibility.SHOW;
109 | }
110 |
111 | @Override
112 | public NotificationManager.NotificationType getType()
113 | {
114 | return type;
115 | }
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/1_17/src/main/java/me/videogamesm12/hotbarsplus/v1_17/manager/CustomToastManager.java:
--------------------------------------------------------------------------------
1 | package me.videogamesm12.hotbarsplus.v1_17.manager;
2 |
3 | import com.mojang.blaze3d.systems.RenderSystem;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import me.videogamesm12.hotbarsplus.api.manager.IToastManager;
7 | import me.videogamesm12.hotbarsplus.core.universal.NotificationManager;
8 | import net.minecraft.client.MinecraftClient;
9 | import net.minecraft.client.gui.DrawableHelper;
10 | import net.minecraft.client.toast.Toast;
11 | import net.minecraft.client.toast.ToastManager;
12 | import net.minecraft.client.util.math.MatrixStack;
13 | import net.minecraft.text.Text;
14 |
15 | public class CustomToastManager implements IToastManager
16 | {
17 | @Override
18 | public HotbarToast getToastFrom(NotificationManager.NotificationType type, Text... texts)
19 | {
20 | Text title;
21 | Text description;
22 |
23 | switch (texts.length)
24 | {
25 | case 0:
26 | {
27 | throw new IllegalArgumentException("Fuck you");
28 | }
29 | case 1:
30 | {
31 | title = texts[0];
32 | description = null;
33 | break;
34 | }
35 | default:
36 | case 2:
37 | {
38 | title = texts[0];
39 | description = texts[1];
40 | break;
41 | }
42 | }
43 |
44 | return new HotbarToast(title, description, type);
45 | }
46 |
47 | @Override
48 | public void showToast(IHotbarToast toast)
49 | {
50 | HotbarToast instance = MinecraftClient.getInstance().getToastManager().getToast(HotbarToast.class, toast.getType());
51 | if (instance == null)
52 | {
53 | MinecraftClient.getInstance().getToastManager().add((HotbarToast) toast);
54 | }
55 | else
56 | {
57 | HotbarToast hToast = (HotbarToast) toast;
58 | //--
59 | instance.setTitle(hToast.getTitle());
60 | instance.setDescription(hToast.getDescription());
61 | instance.setJustUpdated(true);
62 | }
63 | }
64 |
65 | @Getter
66 | @Setter
67 | public static class HotbarToast implements IHotbarToast, Toast
68 | {
69 | private Text title;
70 | private Text description;
71 | //--
72 | private NotificationManager.NotificationType type;
73 | private long time;
74 | //--
75 | private boolean justUpdated = true;
76 |
77 | public HotbarToast(Text title, Text description, NotificationManager.NotificationType type)
78 | {
79 | this.title = title;
80 | this.description = description;
81 | this.type = type;
82 | }
83 |
84 | @Override
85 | public Visibility draw(MatrixStack stack, ToastManager manager, long currentTime)
86 | {
87 | if (justUpdated)
88 | {
89 | this.time = currentTime;
90 | justUpdated = false;
91 | }
92 |
93 | RenderSystem.setShaderTexture(0, IToastManager.TEXTURE);
94 | RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
95 |
96 | DrawableHelper.drawTexture(stack, 0, 0, 0, 20, 160, 32, 160, 52);
97 | //--
98 | DrawableHelper.drawTexture(stack, 6, 6, 20 * type.ordinal(), 0, 20, 20, 160, 52);
99 | //--
100 | int titleY = description == null ? 12 : 7;
101 | MinecraftClient.getInstance().textRenderer.draw(stack, title.getString(), 30, titleY, type.getColor());
102 |
103 | if (description != null)
104 | {
105 | MinecraftClient.getInstance().textRenderer.draw(stack, description.asString(), 30, 18, 0xFFFFFF);
106 | }
107 |
108 | return currentTime - time >= 5000 ? Visibility.HIDE : Visibility.SHOW;
109 | }
110 |
111 | @Override
112 | public NotificationManager.NotificationType getType()
113 | {
114 | return type;
115 | }
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/1_19/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CustomToastManager.java:
--------------------------------------------------------------------------------
1 | package me.videogamesm12.hotbarsplus.v1_19.manager;
2 |
3 | import com.mojang.blaze3d.systems.RenderSystem;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import me.videogamesm12.hotbarsplus.api.manager.IToastManager;
7 | import me.videogamesm12.hotbarsplus.core.universal.NotificationManager;
8 | import net.minecraft.client.MinecraftClient;
9 | import net.minecraft.client.gui.DrawableHelper;
10 | import net.minecraft.client.toast.Toast;
11 | import net.minecraft.client.toast.ToastManager;
12 | import net.minecraft.client.util.math.MatrixStack;
13 | import net.minecraft.text.Text;
14 |
15 | public class CustomToastManager implements IToastManager
16 | {
17 | @Override
18 | public HotbarToast getToastFrom(NotificationManager.NotificationType type, Text... texts)
19 | {
20 | Text title;
21 | Text description;
22 |
23 | switch (texts.length)
24 | {
25 | case 0:
26 | {
27 | throw new IllegalArgumentException("Fuck you");
28 | }
29 | case 1:
30 | {
31 | title = texts[0];
32 | description = null;
33 | break;
34 | }
35 | default:
36 | case 2:
37 | {
38 | title = texts[0];
39 | description = texts[1];
40 | break;
41 | }
42 | }
43 |
44 | return new HotbarToast(title, description, type);
45 | }
46 |
47 | @Override
48 | public void showToast(IHotbarToast toast)
49 | {
50 | HotbarToast instance = MinecraftClient.getInstance().getToastManager().getToast(HotbarToast.class, toast.getType());
51 | if (instance == null)
52 | {
53 | MinecraftClient.getInstance().getToastManager().add((HotbarToast) toast);
54 | }
55 | else
56 | {
57 | HotbarToast hToast = (HotbarToast) toast;
58 | //--
59 | instance.setTitle(hToast.getTitle());
60 | instance.setDescription(hToast.getDescription());
61 | instance.setJustUpdated(true);
62 | }
63 | }
64 |
65 | @Getter
66 | @Setter
67 | public static class HotbarToast implements IHotbarToast, Toast
68 | {
69 | private Text title;
70 | private Text description;
71 | //--
72 | private NotificationManager.NotificationType type;
73 | private long time;
74 | //--
75 | private boolean justUpdated = true;
76 |
77 | public HotbarToast(Text title, Text description, NotificationManager.NotificationType type)
78 | {
79 | this.title = title;
80 | this.description = description;
81 | this.type = type;
82 | }
83 |
84 | @Override
85 | public Visibility draw(MatrixStack stack, ToastManager manager, long currentTime)
86 | {
87 | if (justUpdated)
88 | {
89 | this.time = currentTime;
90 | justUpdated = false;
91 | }
92 |
93 | RenderSystem.setShaderTexture(0, IToastManager.TEXTURE);
94 | RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
95 |
96 | DrawableHelper.drawTexture(stack, 0, 0, 0, 20, 160, 32, 160, 52);
97 | //--
98 | DrawableHelper.drawTexture(stack, 6, 6, 20 * type.ordinal(), 0, 20, 20, 160, 52);
99 | //--
100 | int titleY = description == null ? 12 : 7;
101 | MinecraftClient.getInstance().textRenderer.draw(stack, title.getString(), 30, titleY, type.getColor());
102 |
103 | if (description != null)
104 | {
105 | MinecraftClient.getInstance().textRenderer.draw(stack, description.getString(), 30, 18, 0xFFFFFF);
106 | }
107 |
108 | return currentTime - time >= 5000 ? Visibility.HIDE : Visibility.SHOW;
109 | }
110 |
111 | @Override
112 | public NotificationManager.NotificationType getType()
113 | {
114 | return type;
115 | }
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/manager/CustomToastManager.java:
--------------------------------------------------------------------------------
1 | package me.videogamesm12.hotbarsplus.v1_19.manager;
2 |
3 | import com.mojang.blaze3d.systems.RenderSystem;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import me.videogamesm12.hotbarsplus.api.manager.IToastManager;
7 | import me.videogamesm12.hotbarsplus.core.universal.NotificationManager;
8 | import net.minecraft.client.MinecraftClient;
9 | import net.minecraft.client.gui.DrawableHelper;
10 | import net.minecraft.client.toast.Toast;
11 | import net.minecraft.client.toast.ToastManager;
12 | import net.minecraft.client.util.math.MatrixStack;
13 | import net.minecraft.text.Text;
14 |
15 | public class CustomToastManager implements IToastManager
16 | {
17 | @Override
18 | public HotbarToast getToastFrom(NotificationManager.NotificationType type, Text... texts)
19 | {
20 | Text title;
21 | Text description;
22 |
23 | switch (texts.length)
24 | {
25 | case 0:
26 | {
27 | throw new IllegalArgumentException("Fuck you");
28 | }
29 | case 1:
30 | {
31 | title = texts[0];
32 | description = null;
33 | break;
34 | }
35 | default:
36 | case 2:
37 | {
38 | title = texts[0];
39 | description = texts[1];
40 | break;
41 | }
42 | }
43 |
44 | return new HotbarToast(title, description, type);
45 | }
46 |
47 | @Override
48 | public void showToast(IHotbarToast toast)
49 | {
50 | HotbarToast instance = MinecraftClient.getInstance().getToastManager().getToast(HotbarToast.class, toast.getType());
51 | if (instance == null)
52 | {
53 | MinecraftClient.getInstance().getToastManager().add((HotbarToast) toast);
54 | }
55 | else
56 | {
57 | HotbarToast hToast = (HotbarToast) toast;
58 | //--
59 | instance.setTitle(hToast.getTitle());
60 | instance.setDescription(hToast.getDescription());
61 | instance.setJustUpdated(true);
62 | }
63 | }
64 |
65 | @Getter
66 | @Setter
67 | public static class HotbarToast implements IHotbarToast, Toast
68 | {
69 | private Text title;
70 | private Text description;
71 | //--
72 | private NotificationManager.NotificationType type;
73 | private long time;
74 | //--
75 | private boolean justUpdated = true;
76 |
77 | public HotbarToast(Text title, Text description, NotificationManager.NotificationType type)
78 | {
79 | this.title = title;
80 | this.description = description;
81 | this.type = type;
82 | }
83 |
84 | @Override
85 | public Visibility draw(MatrixStack stack, ToastManager manager, long currentTime)
86 | {
87 | if (justUpdated)
88 | {
89 | this.time = currentTime;
90 | justUpdated = false;
91 | }
92 |
93 | RenderSystem.setShaderTexture(0, IToastManager.TEXTURE);
94 | RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
95 |
96 | DrawableHelper.drawTexture(stack, 0, 0, 0, 20, 160, 32, 160, 52);
97 | //--
98 | DrawableHelper.drawTexture(stack, 6, 6, 20 * type.ordinal(), 0, 20, 20, 160, 52);
99 | //--
100 | int titleY = description == null ? 12 : 7;
101 | MinecraftClient.getInstance().textRenderer.draw(stack, title.getString(), 30, titleY, type.getColor());
102 |
103 | if (description != null)
104 | {
105 | MinecraftClient.getInstance().textRenderer.draw(stack, description.getString(), 30, 18, 0xFFFFFF);
106 | }
107 |
108 | return currentTime - time >= 5000 ? Visibility.HIDE : Visibility.SHOW;
109 | }
110 |
111 | @Override
112 | public NotificationManager.NotificationType getType()
113 | {
114 | return type;
115 | }
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/1_19_3/src/main/java/me/videogamesm12/hotbarsplus/v1_19/mixin/CreativeInvScreenMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_19.mixin;
19 |
20 | import me.videogamesm12.hotbarsplus.core.HBPCore;
21 | import me.videogamesm12.hotbarsplus.v1_19.gui.CustomButtons;
22 | import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen;
23 | import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
24 | import net.minecraft.entity.player.PlayerInventory;
25 | import net.minecraft.item.ItemGroup;
26 | import net.minecraft.item.ItemGroups;
27 | import net.minecraft.text.Text;
28 | import org.spongepowered.asm.mixin.Mixin;
29 | import org.spongepowered.asm.mixin.gen.Invoker;
30 | import org.spongepowered.asm.mixin.injection.At;
31 | import org.spongepowered.asm.mixin.injection.Inject;
32 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
33 |
34 | @Mixin(CreativeInventoryScreen.class)
35 | public abstract class CreativeInvScreenMixin extends AbstractInventoryScreen
36 | implements CreativeInvScreenAccessor, HandledScreenAccessor
37 | {
38 | public CustomButtons.NextButton next;
39 | public CustomButtons.BackupButton backup;
40 | public CustomButtons.PreviousButton previous;
41 |
42 | public CreativeInvScreenMixin(CreativeInventoryScreen.CreativeScreenHandler screenHandler, PlayerInventory playerInventory, Text text)
43 | {
44 | super(screenHandler, playerInventory, text);
45 | }
46 |
47 | @Inject(method = "init", at = @At("RETURN"))
48 | public void injInit(CallbackInfo ci)
49 | {
50 | // Offset
51 | int x = this.getX() + 159;
52 | int y = this.getY() + 4;
53 |
54 | // Initialize buttons
55 | this.next = new CustomButtons.NextButton(x + 16, y);
56 | this.backup = new CustomButtons.BackupButton(x, y);
57 | this.previous = new CustomButtons.PreviousButton(x - 16, y);
58 |
59 | // Modify buttons
60 | if (getSelectedTab() != ItemGroups.HOTBAR)
61 | {
62 | next.visible = false;
63 | backup.visible = false;
64 | previous.visible = false;
65 | }
66 |
67 | backup.active = HBPCore.UPL.hotbarPageExists();
68 |
69 | // Adding buttons
70 | addDrawableChild(next);
71 | addDrawableChild(backup);
72 | addDrawableChild(previous);
73 | }
74 |
75 | @Inject(method = "setSelectedTab", at = @At("HEAD"))
76 | public void injSetCreativeTab(ItemGroup group, CallbackInfo ci)
77 | {
78 | if (next != null && backup != null && previous != null)
79 | {
80 | if (group == ItemGroups.HOTBAR)
81 | {
82 | next.visible = true;
83 | backup.visible = true;
84 | previous.visible = true;
85 | }
86 | else
87 | {
88 | next.visible = false;
89 | backup.visible = false;
90 | previous.visible = false;
91 | }
92 |
93 | backup.active = HBPCore.UPL.hotbarPageExists();
94 | }
95 | }
96 | }
--------------------------------------------------------------------------------
/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/HotbarsPlus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_16;
19 |
20 | import me.videogamesm12.hotbarsplus.api.event.navigation.HotbarNavigateEvent;
21 | import me.videogamesm12.hotbarsplus.core.HBPCore;
22 | import me.videogamesm12.hotbarsplus.v1_16.manager.CommandManager;
23 | import me.videogamesm12.hotbarsplus.v1_16.manager.CustomToastManager;
24 | import me.videogamesm12.hotbarsplus.v1_16.manager.FallbackCommandManager;
25 | import me.videogamesm12.hotbarsplus.v1_16.manager.KeybindManager;
26 | import me.videogamesm12.hotbarsplus.v1_16.mixin.CreativeInvScreenMixin;
27 | import net.fabricmc.api.ClientModInitializer;
28 | import net.fabricmc.loader.api.FabricLoader;
29 | import net.minecraft.client.MinecraftClient;
30 | import net.minecraft.client.gui.screen.Screen;
31 | import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
32 | import net.minecraft.item.ItemGroup;
33 | import net.minecraft.util.ActionResult;
34 |
35 | import java.math.BigInteger;
36 |
37 | public class HotbarsPlus implements ClientModInitializer, HotbarNavigateEvent
38 | {
39 | @Override
40 | public void onInitializeClient()
41 | {
42 | HBPCore.KEYBINDS = new KeybindManager();
43 | //--
44 | /*
45 | So the issue here is that there was a period of time when both Cotton Client Commands and Fabric API's
46 | client command API were available for 1.16. However, Fabric API's client command API was only available for
47 | 1.16.5. Cotton Client Commands was available for 1.16 - 1.16.4, but probably worked on 1.16.5 too.
48 | --
49 | This is a compromise solution that allows both to work.
50 | */
51 | if (FabricLoader.getInstance().isModLoaded("cotton-client-commands"))
52 | {
53 | // Cotton Client Commands
54 | HBPCore.COMMANDS = new FallbackCommandManager();
55 | }
56 | else
57 | {
58 | // Fabric API
59 | try
60 | {
61 | HBPCore.COMMANDS = new CommandManager();
62 | }
63 | catch (Throwable ex)
64 | {
65 | HBPCore.LOGGER.warn("Neither a sufficient version of the Fabric API nor Cotton Client Commands were found. No in-game commands will work.");
66 | }
67 | }
68 | //--
69 | HBPCore.TOASTS = new CustomToastManager();
70 | //--
71 | HotbarNavigateEvent.EVENT.register(this);
72 | }
73 |
74 | @Override
75 | public ActionResult onNavigate(BigInteger page)
76 | {
77 | // Refreshes the menu if it is currently open;
78 | if (MinecraftClient.getInstance().currentScreen instanceof CreativeInventoryScreen)
79 | {
80 | Screen screen = MinecraftClient.getInstance().currentScreen;
81 |
82 | if (((CreativeInventoryScreen) screen).getSelectedTab() == ItemGroup.HOTBAR.getIndex())
83 | {
84 | ((CreativeInvScreenMixin.CISAccessor) screen).setSelectedTab(ItemGroup.HOTBAR);
85 | }
86 | }
87 |
88 | return ActionResult.PASS;
89 | }
90 | }
--------------------------------------------------------------------------------
/1_20/src/main/java/me/videogamesm12/hotbarsplus/v1_20/mixin/CreativeInvScreenMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.v1_20.mixin;
19 |
20 | import me.videogamesm12.hotbarsplus.core.HBPCore;
21 | import me.videogamesm12.hotbarsplus.v1_20.gui.CustomButtons;
22 | import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen;
23 | import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
24 | import net.minecraft.entity.player.PlayerInventory;
25 | import net.minecraft.item.ItemGroup;
26 | import net.minecraft.item.ItemGroups;
27 | import net.minecraft.registry.Registries;
28 | import net.minecraft.text.Text;
29 | import org.spongepowered.asm.mixin.Mixin;
30 | import org.spongepowered.asm.mixin.injection.At;
31 | import org.spongepowered.asm.mixin.injection.Inject;
32 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
33 |
34 | @Mixin(CreativeInventoryScreen.class)
35 | public abstract class CreativeInvScreenMixin extends AbstractInventoryScreen
36 | implements CreativeInvScreenAccessor, HandledScreenAccessor
37 | {
38 | public CustomButtons.NextButton next;
39 | public CustomButtons.BackupButton backup;
40 | public CustomButtons.PreviousButton previous;
41 |
42 | public CreativeInvScreenMixin(CreativeInventoryScreen.CreativeScreenHandler screenHandler, PlayerInventory playerInventory, Text text)
43 | {
44 | super(screenHandler, playerInventory, text);
45 | }
46 |
47 | @Inject(method = "init", at = @At("RETURN"))
48 | public void injInit(CallbackInfo ci)
49 | {
50 | // Offset
51 | int x = this.getX() + 159;
52 | int y = this.getY() + 4;
53 |
54 | // Initialize buttons
55 | this.next = new CustomButtons.NextButton(x + 16, y);
56 | this.backup = new CustomButtons.BackupButton(x, y);
57 | this.previous = new CustomButtons.PreviousButton(x - 16, y);
58 |
59 | // Modify buttons
60 | if (getSelectedTab() != Registries.ITEM_GROUP.get(ItemGroups.HOTBAR))
61 | {
62 | next.visible = false;
63 | backup.visible = false;
64 | previous.visible = false;
65 | }
66 |
67 | backup.active = HBPCore.UPL.hotbarPageExists();
68 |
69 | // Adding buttons
70 | addDrawableChild(next);
71 | addDrawableChild(backup);
72 | addDrawableChild(previous);
73 | }
74 |
75 | @Inject(method = "setSelectedTab", at = @At("HEAD"))
76 | public void injSetCreativeTab(ItemGroup group, CallbackInfo ci)
77 | {
78 | if (next != null && backup != null && previous != null)
79 | {
80 | if (group == Registries.ITEM_GROUP.get(ItemGroups.HOTBAR))
81 | {
82 | next.visible = true;
83 | backup.visible = true;
84 | previous.visible = true;
85 | }
86 | else
87 | {
88 | next.visible = false;
89 | backup.visible = false;
90 | previous.visible = false;
91 | }
92 |
93 | backup.active = HBPCore.UPL.hotbarPageExists();
94 | }
95 | }
96 | }
--------------------------------------------------------------------------------
/1_16/src/main/java/me/videogamesm12/hotbarsplus/v1_16/manager/CustomToastManager.java:
--------------------------------------------------------------------------------
1 | package me.videogamesm12.hotbarsplus.v1_16.manager;
2 |
3 | import com.mojang.blaze3d.platform.GlStateManager;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import me.videogamesm12.hotbarsplus.api.manager.IToastManager;
7 | import me.videogamesm12.hotbarsplus.core.universal.NotificationManager;
8 | import net.minecraft.client.MinecraftClient;
9 | import net.minecraft.client.gui.DrawableHelper;
10 | import net.minecraft.client.toast.Toast;
11 | import net.minecraft.client.toast.ToastManager;
12 | import net.minecraft.client.util.math.MatrixStack;
13 | import net.minecraft.text.Text;
14 | import org.lwjgl.opengl.GL11;
15 |
16 | public class CustomToastManager implements IToastManager
17 | {
18 | @Override
19 | public HotbarToast getToastFrom(NotificationManager.NotificationType type, Text... texts)
20 | {
21 | Text title;
22 | Text description;
23 |
24 | switch (texts.length)
25 | {
26 | case 0:
27 | {
28 | throw new IllegalArgumentException("Fuck you");
29 | }
30 | case 1:
31 | {
32 | title = texts[0];
33 | description = null;
34 | break;
35 | }
36 | default:
37 | case 2:
38 | {
39 | title = texts[0];
40 | description = texts[1];
41 | break;
42 | }
43 | }
44 |
45 | return new HotbarToast(title, description, type);
46 | }
47 |
48 | @Override
49 | public void showToast(IHotbarToast toast)
50 | {
51 | HotbarToast instance = MinecraftClient.getInstance().getToastManager().getToast(HotbarToast.class, toast.getType());
52 | if (instance == null)
53 | {
54 | MinecraftClient.getInstance().getToastManager().add((HotbarToast) toast);
55 | }
56 | else
57 | {
58 | HotbarToast hToast = (HotbarToast) toast;
59 | //--
60 | instance.setTitle(hToast.getTitle());
61 | instance.setDescription(hToast.getDescription());
62 | instance.setJustUpdated(true);
63 | }
64 | }
65 |
66 | @Getter
67 | @Setter
68 | public static class HotbarToast implements IHotbarToast, Toast
69 | {
70 | private Text title;
71 | private Text description;
72 | //--
73 | private NotificationManager.NotificationType type;
74 | private long time;
75 | //--
76 | private boolean justUpdated = true;
77 |
78 | public HotbarToast(Text title, Text description, NotificationManager.NotificationType type)
79 | {
80 | this.title = title;
81 | this.description = description;
82 | this.type = type;
83 | }
84 |
85 | @Override
86 | public Visibility draw(MatrixStack stack, ToastManager manager, long currentTime)
87 | {
88 | if (justUpdated)
89 | {
90 | this.time = currentTime;
91 | justUpdated = false;
92 | }
93 |
94 | MinecraftClient.getInstance().getTextureManager().bindTexture(IToastManager.TEXTURE);
95 | GL11.glColor4f(1, 1, 1, 1);
96 | DrawableHelper.drawTexture(stack, 0, 0, 0, 20, 160, 32, 160, 52);
97 | //--
98 | GlStateManager.enableBlend();
99 | DrawableHelper.drawTexture(stack, 6, 6, 20 * type.ordinal(), 0, 20, 20, 160, 52);
100 | GlStateManager.disableBlend();
101 | //--
102 | int titleY = description == null ? 12 : 7;
103 | MinecraftClient.getInstance().textRenderer.draw(stack, title.getString(), 30, titleY, type.getColor());
104 |
105 | if (description != null)
106 | {
107 | MinecraftClient.getInstance().textRenderer.draw(stack, description.asString(), 30, 18, 0xFFFFFF);
108 | }
109 |
110 | return currentTime - time >= 5000 ? Visibility.HIDE : Visibility.SHOW;
111 | }
112 |
113 | @Override
114 | public NotificationManager.NotificationType getType()
115 | {
116 | return type;
117 | }
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/universal/ConfigurationManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.core.universal;
19 |
20 | import com.google.gson.Gson;
21 | import com.google.gson.GsonBuilder;
22 | import lombok.Getter;
23 |
24 | import me.videogamesm12.hotbarsplus.api.config.Configuration;
25 | import me.videogamesm12.hotbarsplus.api.event.navigation.HotbarNavigateEvent;
26 | import me.videogamesm12.hotbarsplus.api.event.notification.NotificationTypeRegistered;
27 | import me.videogamesm12.hotbarsplus.core.HBPCore;
28 | import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
29 | import net.minecraft.client.MinecraftClient;
30 |
31 | import javax.naming.ConfigurationException;
32 | import java.io.FileReader;
33 | import java.io.FileWriter;
34 | import java.io.Writer;
35 |
36 | /**
37 | * ConfigurationManager
38 | * Controls pretty much everything about the configuration.
39 | */
40 | public class ConfigurationManager implements ClientLifecycleEvents.ClientStopping
41 | {
42 | private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
43 |
44 | @Getter
45 | private Configuration config = null;
46 |
47 | public ConfigurationManager()
48 | {
49 | load();
50 | }
51 |
52 | public void load()
53 | {
54 | // Try loading the configuration from disk.
55 | try
56 | {
57 | config = gson.fromJson(new FileReader(Configuration.getLocation()), Configuration.class);
58 |
59 | // Just for good measure...
60 | if (config == null)
61 | {
62 | throw new ConfigurationException("The configuration that was loaded in ended up being blank");
63 | }
64 | }
65 | // Failed to read the configuration. Oh well, we tried.
66 | catch (Exception ex)
67 | {
68 | // If there's not already a configuration in memory, create one from scratch.
69 | if (config == null)
70 | {
71 | config = new Configuration();
72 | }
73 |
74 | // Saves the new copy of the configuration.
75 | save();
76 | }
77 |
78 | ClientLifecycleEvents.CLIENT_STOPPING.register(this);
79 |
80 | // This is a hack to get both of these things working.
81 | HotbarNavigateEvent.EVENT.register(config.getLastHotbarPage());
82 | NotificationTypeRegistered.EVENT.register(config.getNotificationConfig());
83 | }
84 |
85 | public void save()
86 | {
87 | HBPCore.LOGGER.info("Saving configuration to disk...");
88 |
89 | // Try to save the configuration to disk
90 | try
91 | {
92 | Writer wtf = new FileWriter(Configuration.getLocation());
93 | gson.toJson(config, wtf);
94 | wtf.close();
95 | }
96 | catch (Exception ex)
97 | {
98 | HBPCore.LOGGER.error("Failed to save configuration", ex);
99 | }
100 | }
101 |
102 | @Override
103 | public void onClientStopping(MinecraftClient client)
104 | {
105 | // Automatically saves to disk.
106 | save();
107 | }
108 | }
--------------------------------------------------------------------------------
/src/main/java/me/videogamesm12/hotbarsplus/core/universal/PageManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Video
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10 | * Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 |
18 | package me.videogamesm12.hotbarsplus.core.universal;
19 |
20 | import me.videogamesm12.hotbarsplus.api.event.keybind.NextBindPressEvent;
21 | import me.videogamesm12.hotbarsplus.api.event.keybind.PreviousBindPressEvent;
22 | import me.videogamesm12.hotbarsplus.api.event.navigation.HotbarNavigateEvent;
23 | import me.videogamesm12.hotbarsplus.core.HotbarsPlusStorage;
24 | import me.videogamesm12.hotbarsplus.core.mixin.HotbarStorageMixin;
25 | import net.minecraft.client.MinecraftClient;
26 | import net.minecraft.client.option.HotbarStorage;
27 |
28 | import java.math.BigInteger;
29 | import java.util.HashMap;
30 | import java.util.Map;
31 |
32 | /**
33 | * PageManager
34 | * Version-independent storage for the current page number in Hotbars+.
35 | */
36 | public class PageManager implements NextBindPressEvent, PreviousBindPressEvent
37 | {
38 | private final Map cache = new HashMap<>();
39 | private BigInteger currentPage = BigInteger.valueOf(0);
40 |
41 | public PageManager()
42 | {
43 | NextBindPressEvent.EVENT.register(this);
44 | PreviousBindPressEvent.EVENT.register(this);
45 | }
46 |
47 | public void decrementPage()
48 | {
49 | currentPage = currentPage.subtract(BigInteger.ONE);
50 | HotbarNavigateEvent.EVENT.invoker().onNavigate(currentPage);
51 | }
52 |
53 | public void incrementPage()
54 | {
55 | currentPage = currentPage.add(BigInteger.ONE);
56 | HotbarNavigateEvent.EVENT.invoker().onNavigate(currentPage);
57 | }
58 |
59 | public void goToPage(BigInteger page)
60 | {
61 | currentPage = page;
62 | HotbarNavigateEvent.EVENT.invoker().onNavigate(currentPage);
63 | }
64 |
65 | public void goToPageQuietly(BigInteger page)
66 | {
67 | currentPage = page;
68 | }
69 |
70 | public Map getCache()
71 | {
72 | return cache;
73 | }
74 |
75 | public int getCacheSize()
76 | {
77 | return cache.size();
78 | }
79 |
80 | public BigInteger getCurrentPage()
81 | {
82 | return currentPage;
83 | }
84 |
85 | public HotbarStorage getHotbarPage(BigInteger page)
86 | {
87 | // Get from disk if not cached in memory
88 | if (!cache.containsKey(page))
89 | {
90 | HotbarStorage storage = page.equals(BigInteger.ZERO) ?
91 | new HotbarStorage(MinecraftClient.getInstance().runDirectory, MinecraftClient.getInstance().getDataFixer()) :
92 | new HotbarsPlusStorage(page);
93 |
94 | cache.put(page, storage);
95 | }
96 |
97 | return cache.get(page);
98 | }
99 |
100 | public HotbarStorage getHotbarPage()
101 | {
102 | return getHotbarPage(currentPage);
103 | }
104 |
105 | public boolean hotbarPageExists()
106 | {
107 | return ((HotbarStorageMixin.HSAccessor) getHotbarPage()).getFile().exists();
108 | }
109 |
110 | @Override
111 | public void onNextPress()
112 | {
113 | incrementPage();
114 | }
115 |
116 | @Override
117 | public void onPreviousPress()
118 | {
119 | decrementPage();
120 | }
121 | }
122 |
--------------------------------------------------------------------------------