Skip to content

Commit

Permalink
1.19.4 update
Browse files Browse the repository at this point in the history
  • Loading branch information
TacoMonkey11 committed Mar 30, 2023
1 parent 16aab61 commit 426bfb0
Show file tree
Hide file tree
Showing 55 changed files with 75 additions and 985 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<img height="70" align="right" src="./assets/icon.png">
<img height="70" align="right" src="projects/too-many-binds/src/main/resources/assets/toomanybinds/icon.png">

# Too Many Binds
[![CurseForge downloads](https://cf.way2muchnoise.eu/412915.svg)](https://www.curseforge.com/minecraft/mc-mods/too-many-binds)
Expand Down
47 changes: 34 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,40 @@ allprojects {

dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"

minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"

// Required Fabric API modules
modImplementation fabricApi.module('fabric-api-base', project.fabric_api_version)
modImplementation fabricApi.module('fabric-lifecycle-events-v1', project.fabric_api_version)
modImplementation fabricApi.module('fabric-key-binding-api-v1', project.fabric_api_version)

// Amecs API
//modImplementation "de.siphalor:amecsapi-1.19:${project.amecs_api_version}"

// ModMenu
modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
// Cloth Config
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: 'net.fabricmc.fabric-api')
}

if (project.use_third_party_mods == 'true') {
configurations {
modRuntimeOnly {
exclude module: 'fabric-lifecycle-events-v1'
exclude module: 'fabric-key-binding-api-v1'
}
}

modRuntimeOnly "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
//modRuntimeOnly "maven.modrinth:sodium:${project.sodium_version}"
//modRuntimeOnly "maven.modrinth:lithium:${project.lithium_version}"
modRuntimeOnly "maven.modrinth:starlight:${project.starlight_version}"
//modRuntimeOnly "maven.modrinth:smoothboot-fabric:${project.smoothboot_version}"
modRuntimeOnly "curse.maven:no-fade-452768:${project.no_fade_version}"
}
}


Expand Down Expand Up @@ -100,19 +134,6 @@ allprojects {
}


dependencies {
include project(path: ':toomanybinds-core', configuration: 'namedElements')
include project(path: ':toomanybinds-1.16-compat', configuration: 'namedElements')
include project(path: ':toomanybinds-1.17-compat', configuration: 'namedElements')
include project(path: ':toomanybinds-1.18.2-compat', configuration: 'namedElements')
include project(path: ':toomanybinds-1.19-compat', configuration: 'namedElements')
include project(path: ':toomanybinds-1.19.3-compat', configuration: 'namedElements')

minecraft "com.mojang:minecraft:${minecraft_version_1_19_3}"
mappings "net.fabricmc:yarn:${project.yarn_mappings_1_19_3}:v2"
}


processResources {
from("${rootDir}/assets/icon.png") {
into "assets/toomanybinds/"
Expand Down
92 changes: 9 additions & 83 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,91 +13,17 @@ mod_version = 0.3.3
maven_group = com.github.reviversmc
archives_base_name = toomanybinds

# Global Dependencies
fabric_loader_version = 0.14.14

# Module Dependencies
# 1.16
minecraft_version_1_16 = 1.16.5
yarn_mappings_1_16 = 1.16.5+build.10
fabric_api_version_1_16 = 0.42.0+1.16
amecs_api_version_1_16 = 1.3.7+mc1.16.5
modmenu_version_1_16 = 1.16.23
cloth_config_version_1_16 = 4.15.82
# 1.17
minecraft_version_1_17 = 1.17.1
yarn_mappings_1_17 = 1.17.1+build.65
fabric_api_version_1_17 = 0.46.1+1.17
amecs_api_version_1_17 = 1.3.7+mc1.17.1
nmuk_version_1_17 = 1.0.1+mc1.17
modmenu_version_1_17 = 2.0.17
cloth_config_version_1_17 = 5.3.63
# 1.18.2
minecraft_version_1_18_2 = 1.18.2
yarn_mappings_1_18_2 = 1.18.2+build.3
fabric_api_version_1_18_2 = 0.56.1+1.18.2
amecs_api_version_1_18_2 = 1.3.6+mc22w06a
modmenu_version_1_18_2 = 3.2.5
cloth_config_version_1_18_2 = 6.3.81
# 1.19
minecraft_version_1_19 = 1.19.2
yarn_mappings_1_19 = 1.19.2+build.28
fabric_api_version_1_19 = 0.70.0+1.19.2
amecs_api_version_1_19 = 1.3.7+mc22w17a
nmuk_version_1_19 = 1.0.2+mc1.19.2
modmenu_version_1_19 = 4.1.2
cloth_config_version_1_19 = 8.2.88
# 1.19.3
minecraft_version_1_19_3 = 1.19.3
yarn_mappings_1_19_3 = 1.19.3+build.5
fabric_api_version_1_19_3 = 0.73.2+1.19.3
amecs_api_version_1_19_3 = 1.3.7+mc1.19.3
nmuk_version_1_19_3 = 1.0.2+mc1.19.3
modmenu_version_1_19_3 = 5.0.2
cloth_config_version_1_19_3 = 9.0.94
minecraft_version=1.19.4-rc2
yarn_mappings = 1.19.4-rc2+build.1
fabric_api_version = 0.75.3+1.19.4
amecs_api_version= 1.3.7+mc1.19.3
modmenu_version = 6.1.0-beta.3
cloth_config_version = 10.0.95

# If true, third-party mods will be loaded during runtime in the developer run configurations
use_third_party_mods = true
# 1.16
lazydfu_version_1_16 = 0.1.2
sodium_version_1_16 = mc1.16.5-0.2.0
lithium_version_1_16 = mc1.16.5-0.6.6
phosphor_version_1_16 = mc1.16.2-0.8.0
ferrite_core_version_1_16 = 2.1.1-fabric
smoothboot_version_1_16 = 1.16.5-1.6.0
no_fade_version_1_16 = 3228523
# 1.17
lazydfu_version_1_17 = 0.1.2
sodium_version_1_17 = mc1.17.1-0.3.4
joml_version_sodium_1_17 = 1.10.2
lithium_version_1_17 = mc1.17.1-0.7.5
starlight_version_1_17 = Starlight 1.0.0 1.17.x
ferrite_core_version_1_17 = 3.1.0
smoothboot_version_1_17 = 1.16.5-1.6.0
no_fade_version_1_17 = 3355800
# 1.18.2
lazydfu_version_1_18_2 = 0.1.2
sodium_version_1_18_2 = mc1.18.2-0.4.1
joml_version_sodium_1_18_2 = 1.10.2
lithium_version_1_18_2 = mc1.18.2-0.10.3
starlight_version_1_18_2 = 1.0.2+1.18.2
ferrite_core_version_1_18_2 = 4.2.1-fabric
smoothboot_version_1_18_2 = 3692365
no_fade_version_1_18_2 = 3550935
# 1.19
lazydfu_version_1_19 = 0.1.3
sodium_version_1_19 = mc1.19.2-0.4.4
joml_version_sodium_1_19 = 1.10.4
lithium_version_1_19 = mc1.19.2-0.10.4
starlight_version_1_19 = 1.1.1+1.19
ferrite_core_version_1_19 = 5.0.3-fabric
smoothboot_version_1_19 = 1.19-1.7.1
no_fade_version_1_19 = 3550935
# 1.19.3
lazydfu_version_1_19_3 = 0.1.3
sodium_version_1_19_3 = mc1.19.3-0.4.8
lithium_version_1_19_3 = mc1.19.3-0.10.4
starlight_version_1_19_3 = 1.1.1+1.19
ferrite_core_version_1_19_3 = 5.1.0-fabric
smoothboot_version_1_19_3 = 1.19-1.7.1
no_fade_version_1_19_3 = 3550935

starlight_version = 1.1.1+1.19
no_fade_version = 3550935
7 changes: 0 additions & 7 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,3 @@ pluginManagement {
}

rootProject.name = 'toomanybinds'

include 'toomanybinds-core'
include 'toomanybinds-1.16-compat'
include 'toomanybinds-1.17-compat'
include 'toomanybinds-1.18.2-compat'
include 'toomanybinds-1.19-compat'
include 'toomanybinds-1.19.3-compat'
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.github.reviversmc.toomanybinds.autocompletion.BindSuggestion;
import com.github.reviversmc.toomanybinds.autocompletion.LauncherCompletion;

public abstract class LauncherScreen extends Screen {
public class LauncherScreen extends Screen {
protected final int SUGGESTION_COLOR = 0x999999;
protected final int HIGHLIGHT_COLOR = 0xFFFF00;

Expand Down Expand Up @@ -61,7 +61,7 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
int lineAmt = Math.min(suggestions.size(), TooManyBinds.config.maxSuggestions);
int bgColor = (int) Math.round(TooManyBinds.config.bgOpacity * 255) * 0x1000000;
fill(matrices, getX()-1, getY()-1, getX()+w-1, getY()+lineHeight-2 + lineAmt * lineHeight, bgColor);
textField.setTextFieldFocused(true);
textField.setFocused(true);
textField.render(matrices, mouseX, mouseY, delta);

int y = getY();
Expand Down Expand Up @@ -120,7 +120,7 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
return true;
} else if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER) {
List<BindSuggestion> suggestions = completion.getSuggestions();
closeScreen();
client.setScreen(null);

if (suggestions.size() > selected) {
suggestions.get(selected).execute();
Expand All @@ -133,8 +133,6 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|| super.keyPressed(keyCode, scanCode, modifiers);
}

protected abstract void closeScreen();

public void textChangeListener(String s) {
completion.updateSuggestions(s);
selected = 0;
Expand All @@ -146,21 +144,16 @@ protected void init() {
baseX = (width - w) / 2;
baseY = (height - lineHeight) / 2;

setRepeatKeyboardEvents(true);

String text = "";
if (textField != null) text = textField.getText();
textField = new TextFieldWidget(textRenderer, getX(), getY()+1, w, lineHeight, NarratorManager.EMPTY);
textField.setDrawsBackground(false);
textField.setChangedListener(this::textChangeListener);
textField.setText(text);
addTextField(textField);
addSelectableChild(textField);
setInitialFocus(textField);
}

protected abstract void setRepeatKeyboardEvents(boolean repeatEvents);
protected abstract void addTextField(TextFieldWidget textField);

@Override
public void tick() {
textField.tick();
Expand All @@ -171,14 +164,8 @@ public void resize(MinecraftClient client, int width, int height) {
init(client, width, height);
}

@Override
public boolean isPauseScreen() {
return false;
}

@Override
public void removed() {
setRepeatKeyboardEvents(false);
TooManyBinds.config.launcherX = offsetX;
TooManyBinds.config.launcherY = offsetY;
AutoConfig.getConfigHolder(ModConfig.class).save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.github.reviversmc.toomanybinds.autocompletion.LauncherCompletion;
import com.github.reviversmc.toomanybinds.autocompletion.VanillaKeybindSuggestions;

public abstract class TooManyBinds implements ModInitializer {
public class TooManyBinds implements ModInitializer {
public static ModConfig config;
public static KeyBinding launcherKey;
public static KeyBinding favoriteKey;
Expand All @@ -36,15 +36,12 @@ public void onInitialize() {
"category.toomanybinds"));

ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (launcherKey.wasPressed()) openNewLauncherScreen(client);
if (launcherKey.wasPressed()) client.setScreen(new LauncherScreen());
});

ClientLifecycleEvents.CLIENT_STARTED.register(t -> LauncherCompletion.loadData());
ClientLifecycleEvents.CLIENT_STOPPING.register(t -> LauncherCompletion.saveData());

LauncherCompletion.suggestionProviders.add(newVanillaKeyBindSuggestions());
LauncherCompletion.suggestionProviders.add(new VanillaKeybindSuggestions());
}

protected abstract void openNewLauncherScreen(MinecraftClient client);
protected abstract VanillaKeybindSuggestions newVanillaKeyBindSuggestions();
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package com.github.reviversmc.toomanybinds.autocompletion;

import java.util.function.Consumer;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.GameOptions;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.ScreenshotRecorder;
import net.minecraft.text.Text;

import com.github.reviversmc.toomanybinds.integrations.AmecsIntegration;
import com.github.reviversmc.toomanybinds.mixinterface.KeyBindingMixinterface;

public abstract class BindSuggestion {
public class BindSuggestion {
public Text name;
public Text category;
public KeyBinding bind;
Expand All @@ -20,13 +18,11 @@ public abstract class BindSuggestion {

public BindSuggestion(KeyBinding bind) {
this.bind = bind;
name = newTranslatableText(bind.getTranslationKey());
category = newTranslatableText(bind.getCategory());
name = Text.translatable(bind.getTranslationKey());
category = Text.translatable(bind.getCategory());
searchable = (name.getString() + " " + category.getString()).toLowerCase();
}

protected abstract Text newTranslatableText(String key);

public boolean matches(String[] searchTerms) {
for (String term : searchTerms) {
if (!searchable.contains(term)) return false;
Expand All @@ -42,12 +38,12 @@ public void execute() {
LauncherCompletion.addToHistory(getId());

// workarounds for keybinds that are handled in dumb, incompatible ways
if (bind == fullscreenKey(options)) {
if (bind == options.fullscreenKey) {
mc.getWindow().toggleFullscreen();
saveFullscreenState(mc.options, mc.getWindow().isFullscreen());
options.getFullscreen().setValue(mc.getWindow().isFullscreen());
mc.options.write();
} else if (bind == screenshotKey(options)) {
takeScreenshot(mc, (text) -> {
} else if (bind == options.screenshotKey) {
ScreenshotRecorder.saveScreenshot(mc.runDirectory, mc.getFramebuffer(), text -> {
mc.execute(() -> {
mc.inGameHud.getChatHud().addMessage(text);
});
Expand All @@ -58,17 +54,13 @@ public void execute() {
bind.setPressed(false);

// Amecs compat
/*
if (FabricLoader.getInstance().isModLoaded("amecsapi")) {
AmecsIntegration.priorityPressIfApplicable(bind);
}
*/
}
}

protected abstract KeyBinding fullscreenKey(GameOptions options);
protected abstract void saveFullscreenState(GameOptions options, boolean fullscreen);
protected abstract KeyBinding screenshotKey(GameOptions options);
protected abstract void takeScreenshot(MinecraftClient mc, Consumer<Text> messageReceiver);

public String getId() {
return bind.getTranslationKey();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import com.github.reviversmc.toomanybinds.TooManyBinds;

public abstract class VanillaKeybindSuggestions implements SuggestionProvider {
public class VanillaKeybindSuggestions implements SuggestionProvider {
private static final Set<String> blacklist = new HashSet<String>(Arrays.asList(
// pointless
"key.use",
Expand All @@ -32,17 +32,12 @@ public abstract class VanillaKeybindSuggestions implements SuggestionProvider {
"key.saveToolbarActivator",
"key.loadToolbarActivator"
));

protected abstract KeyBinding[] allKeys(GameOptions options);

public void addEntries(List<BindSuggestion> binds) {
for (KeyBinding bind : allKeys(MinecraftClient.getInstance().options)) {
for (KeyBinding bind : MinecraftClient.getInstance().options.allKeys) {
if ((bind.isUnbound() || !TooManyBinds.config.hideBoundKeys)
&& !blacklist.contains(bind.getTranslationKey())) {
binds.add(newBindSuggestion(bind));
binds.add(new BindSuggestion(bind));
}
}
}

protected abstract BindSuggestion newBindSuggestion(KeyBinding bind);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.github.reviversmc.toomanybinds.integrations;

import de.siphalor.amecs.api.PriorityKeyBinding;
import net.minecraft.client.option.KeyBinding;

public class AmecsIntegration {
/*
public static void priorityPressIfApplicable(KeyBinding binding) {
if (binding instanceof PriorityKeyBinding) {
((PriorityKeyBinding) binding).onPressedPriority();
}
}
*/
}
File renamed without changes
Loading

0 comments on commit 426bfb0

Please sign in to comment.