Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Minecraft 1.19.x #18

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.10-SNAPSHOT'
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -10,9 +10,6 @@ archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

minecraft {
}

repositories {
maven { url "https://maven.terraformersmc.com/releases" }
maven { url "https://maven.shedaniel.me/" }
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
minecraft_version=1.18
yarn_mappings=1.18+build.1
loader_version=0.12.8
minecraft_version=1.19
yarn_mappings=1.19+build.4
loader_version=0.14.8

# Mod Properties
mod_version = 1.1.16
mod_version = 1.1.17
maven_group = com.umollu
archives_base_name = ash

# Dependencies
fabric_version=0.44.0+1.18
clothconfig_version=6.0.42
modmenu_version=3.0.0
fabric_version=0.55.2+1.19
clothconfig_version=7.0.74
modmenu_version=4.0.4
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Empty file modified gradlew
100644 → 100755
Empty file.
181 changes: 90 additions & 91 deletions src/main/java/com/umollu/ash/AshCommands.java
Original file line number Diff line number Diff line change
@@ -1,111 +1,110 @@
package com.umollu.ash;

import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.umollu.ash.config.AshConfig;

import me.shedaniel.autoconfig.AutoConfig;
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;

public class AshCommands {

public static AshConfig config;
public static AshConfig config;

public static void registerCommands() {
public static void registerCommands() {

CommandDispatcher<FabricClientCommandSource> commandDispatcher = ClientCommandManager.DISPATCHER;

if(config == null) {
config = AutoConfig.getConfigHolder(AshConfig.class).getConfig();
}
commandDispatcher.register(ClientCommandManager.literal("toggleash")
.executes(context -> {
config.showHud = !config.showHud;
AshMod.configManager.save();
return 1;
}));
if (config == null) {
config = AutoConfig.getConfigHolder(AshConfig.class).getConfig();
}

commandDispatcher.register(ClientCommandManager.literal("togglefps")
.executes(context -> {
config.showFps = !config.showFps;
AshMod.configManager.save();
return 1;
}));
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
dispatcher.register(ClientCommandManager.literal("toggleash").executes(context -> {
config.showHud = !config.showHud;
AshMod.configManager.save();
return 1;
}));
});

commandDispatcher.register(ClientCommandManager.literal("togglecoords")
.executes(context -> {
config.showCoords = !config.showCoords;
AshMod.configManager.save();
return 1;
}));
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
dispatcher.register(ClientCommandManager.literal("togglefps").executes(context -> {
config.showFps = !config.showFps;
AshMod.configManager.save();
return 1;
}));
});

commandDispatcher.register(ClientCommandManager.literal("toggledirection")
.executes(context -> {
config.showDirection = !config.showDirection;
AshMod.configManager.save();
return 1;
}));
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
dispatcher.register(ClientCommandManager.literal("togglecoords").executes(context -> {
config.showCoords = !config.showCoords;
AshMod.configManager.save();
return 1;
}));
});

commandDispatcher.register(ClientCommandManager.literal("ashcolor")
.then(ClientCommandManager.argument("r", IntegerArgumentType.integer())
.then(ClientCommandManager.argument("g", IntegerArgumentType.integer())
.then(ClientCommandManager.argument("b", IntegerArgumentType.integer())
.executes(context -> {
int r = IntegerArgumentType.getInteger(context,"r");
int g = IntegerArgumentType.getInteger(context,"g");
int b = IntegerArgumentType.getInteger(context,"b");
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
dispatcher.register(ClientCommandManager.literal("toggledirection").executes(context -> {
config.showDirection = !config.showDirection;
AshMod.configManager.save();
return 1;
}));
});

config.hudColor = b + (g << 8) + (r << 16);
AshMod.configManager.save();
return 1;
})))));
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
dispatcher.register(ClientCommandManager.literal("ashcolor")
.then(ClientCommandManager.argument("r", IntegerArgumentType.integer())
.then(ClientCommandManager.argument("g", IntegerArgumentType.integer())
.then(ClientCommandManager.argument("b", IntegerArgumentType.integer())
.executes(context -> {
int r = IntegerArgumentType.getInteger(context, "r");
int g = IntegerArgumentType.getInteger(context, "g");
int b = IntegerArgumentType.getInteger(context, "b");

config.hudColor = b + (g << 8) + (r << 16);
AshMod.configManager.save();
return 1;
})))));
});

commandDispatcher.register(ClientCommandManager.literal("resetash")
.executes(context -> {
config = new AshConfig();
AshMod.configManager.save();
return 1;
}));
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
dispatcher.register(ClientCommandManager.literal("resetash").executes(context -> {
config = new AshConfig();
AshMod.configManager.save();
return 1;
}));
});

commandDispatcher.register(ClientCommandManager.literal("alignash")
.then(ClientCommandManager.literal("left")
.executes(context -> {
config.align = 0;
AshMod.configManager.save();
return 1;
}))
.then(ClientCommandManager.literal("center")
.executes(context -> {
config.align = 1;
AshMod.configManager.save();
return 1;
}))
.then(ClientCommandManager.literal("right")
.executes(context -> {
config.align = 2;
AshMod.configManager.save();
return 1;
})));
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
dispatcher.register(ClientCommandManager.literal("alignash")
.then(ClientCommandManager.literal("left").executes(context -> {
config.align = 0;
AshMod.configManager.save();
return 1;
})).then(ClientCommandManager.literal("center").executes(context -> {
config.align = 1;
AshMod.configManager.save();
return 1;
})).then(ClientCommandManager.literal("right").executes(context -> {
config.align = 2;
AshMod.configManager.save();
return 1;
})));
});

commandDispatcher.register(ClientCommandManager.literal("valignash")
.then(ClientCommandManager.literal("top")
.executes(context -> {
config.verticalAlign = 0;
AshMod.configManager.save();
return 1;
}))
.then(ClientCommandManager.literal("middle")
.executes(context -> {
config.verticalAlign = 1;
AshMod.configManager.save();
return 1;
}))
.then(ClientCommandManager.literal("bottom")
.executes(context -> {
config.verticalAlign = 2;
AshMod.configManager.save();
return 1;
})));
}
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
dispatcher.register(ClientCommandManager.literal("valignash")
.then(ClientCommandManager.literal("top").executes(context -> {
config.verticalAlign = 0;
AshMod.configManager.save();
return 1;
})).then(ClientCommandManager.literal("middle").executes(context -> {
config.verticalAlign = 1;
AshMod.configManager.save();
return 1;
})).then(ClientCommandManager.literal("bottom").executes(context -> {
config.verticalAlign = 2;
AshMod.configManager.save();
return 1;
})));
});
}
}
15 changes: 10 additions & 5 deletions src/main/java/com/umollu/ash/AshMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.TranslatableText;
import net.minecraft.text.Text;

import java.util.Collections;
import java.util.List;

public class AshMod implements ClientModInitializer {

Expand Down Expand Up @@ -44,7 +46,7 @@ public void onInitializeClient() {
ints[1] = "Center";
ints[2] = "Right";

return Collections.singletonList(ENTRY_BUILDER.startSelector(new TranslatableText(i13n), ints, alignToString((Integer) Utils.getUnsafely(field, config, (Object)null))).setDefaultValue(() -> {
return Collections.singletonList(ENTRY_BUILDER.startSelector(Text.translatable(i13n), ints, alignToString((Integer) Utils.getUnsafely(field, config, (Object)null))).setDefaultValue(() -> {
return alignToString(Utils.getUnsafely(field, defaults));
}).setSaveConsumer((newValue) -> {
int intValue = 0;
Expand All @@ -68,7 +70,7 @@ else if(newValue.equals("Right"))
ints[1] = "Middle";
ints[2] = "Bottom";

return Collections.singletonList(ENTRY_BUILDER.startSelector(new TranslatableText(i13n), ints, verticalAlignToString((Integer) Utils.getUnsafely(field, config, (Object)null))).setDefaultValue(() -> {
return Collections.singletonList(ENTRY_BUILDER.startSelector(Text.translatable(i13n), ints, verticalAlignToString((Integer) Utils.getUnsafely(field, config, (Object)null))).setDefaultValue(() -> {
return verticalAlignToString(Utils.getUnsafely(field, defaults));
}).setSaveConsumer((newValue) -> {
int intValue = 0;
Expand All @@ -82,8 +84,11 @@ else if(newValue.equals("Bottom"))
}, (field) -> {
return field.getName().equals("verticalAlign");
});

AshCommands.registerCommands();

ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> {
AshCommands.registerCommands();
});

}

private String alignToString(int align) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"umollu_ash.mixins.json"
],
"depends": {
"fabricloader": ">=0.11.3",
"fabricloader": ">=0.14.8",
"fabric": "*",
"minecraft": "1.18.x",
"minecraft": "1.19.x",
"java": ">=17"
}
}