Skip to content

Commit

Permalink
update to 1.2.4
Browse files Browse the repository at this point in the history
增加本地化语言与提高优先级
  • Loading branch information
3093FengMing committed Jan 4, 2023
1 parent f4a09ff commit 632a3c9
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'


version = 'forge-1.2.3+1.18.2'
version = 'forge-1.2.4+1.18.2'
group = 'me.fengming.vaultpatcher' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'vaultpatcher'

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/me/fengming/vaultpatcher/Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package me.fengming.vaultpatcher;

public class Utils {
public static final String MOD_ID = "vaultpatcher";
public static final String MOD_NAME = "Vault Patcher";
}
7 changes: 4 additions & 3 deletions src/main/java/me/fengming/vaultpatcher/VaultPatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.logging.LogUtils;
import me.fengming.vaultpatcher.config.VaultPatcherConfig;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
Expand All @@ -10,14 +11,14 @@
import java.io.IOException;
import java.util.ArrayList;

@Mod("vaultpatcher")
@Mod(Utils.MOD_ID)
public class VaultPatcher {
public static final Logger LOGGER = LogUtils.getLogger();
public static ArrayList<String> exportList = new ArrayList<>();

@Mod.EventBusSubscriber(modid = "vaultpatcher", bus = Mod.EventBusSubscriber.Bus.MOD)
@Mod.EventBusSubscriber(modid = Utils.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public static final class Events {
@SubscribeEvent
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void loadConfig(FMLCommonSetupEvent event) {
event.enqueueWork(() -> {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package me.fengming.vaultpatcher.command;

import com.mojang.brigadier.CommandDispatcher;
import me.fengming.vaultpatcher.Utils;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraftforge.client.event.RegisterClientCommandsEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber(modid = "vaultpatcher", bus = Mod.EventBusSubscriber.Bus.FORGE)
@Mod.EventBusSubscriber(modid = Utils.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE)
public class CommandEventHandler {
@SubscribeEvent(priority = EventPriority.HIGH)
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void registerClientCommands(RegisterClientCommandsEvent event) {
CommandDispatcher<CommandSourceStack> dispatcher = event.getDispatcher();
dispatcher.register(
Commands.literal("vaultpatcher").then(
Commands.literal(Utils.MOD_ID).then(
Commands.literal("export")
.requires((commandSource) -> commandSource.hasPermission(2))
.executes(ExportCommand.instance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;

import java.io.BufferedWriter;
import java.io.FileWriter;
Expand All @@ -22,11 +23,11 @@ public class ExportCommand implements Command<CommandSourceStack> {

@Override
public int run(CommandContext<CommandSourceStack> context) {
context.getSource().sendSuccess(new TextComponent("Warning: This is *WIP*"), true);
context.getSource().sendSuccess(new TranslatableComponent("commands.vaultpatcher.export.warning.wip"), true);
Gson gson = new Gson();
String json = gson.toJson(exportList, new TypeToken<ArrayList<String>>() {
}.getType());
//Export Patch
//Export langs
try {
BufferedWriter bw = new BufferedWriter(
new FileWriter(
Expand All @@ -40,7 +41,7 @@ public int run(CommandContext<CommandSourceStack> context) {
} catch (IOException e) {
e.printStackTrace();
}
context.getSource().sendSuccess(new TextComponent("Export langpatcher.json"), true);
context.getSource().sendSuccess(new TranslatableComponent("commands.vaultpatcher.export.tips.success"), true);
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import static me.fengming.vaultpatcher.VaultPatcher.exportList;

@Mixin(Font.class)
@Mixin(value = Font.class, priority = Integer.MAX_VALUE)
public class FontMixin {
//GUI Transcription
@ModifyArg(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import static me.fengming.vaultpatcher.VaultPatcher.exportList;

@Mixin(TextComponent.class)
@Mixin(value = TextComponent.class, priority = Integer.MAX_VALUE)
public abstract class TextComponentMixin {
@Accessor("text")
abstract String getText();
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ modId = "vaultpatcher" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
# see the associated build.gradle script for how to populate this completely automatically during a build
version = "1.2.3+1.18.2" #mandatory
version = "1.2.4+1.18.2" #mandatory
# A display name for the mod
displayName = "Vanilla Hardcoded Bearker" #mandatory
displayName = "Vault Patcher" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
Expand Down Expand Up @@ -50,6 +50,6 @@ side = "BOTH"
modId = "minecraft"
mandatory = true
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange = "[1.18.2,1.19)"
versionRange = "[1.18.2,1.19.3)"
ordering = "NONE"
side = "BOTH"
4 changes: 4 additions & 0 deletions src/main/resources/assets/vaultpatcher/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"commands.vaultpatcher.export.tips.success": "Done! Export to langpatcher.json",
"commands.vaultpatcher.export.warning.wip": "Warning: This feature is still *WIP*!"
}
4 changes: 4 additions & 0 deletions src/main/resources/assets/vaultpatcher/lang/zh_cn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"commands.vaultpatcher.export.tips.success": "完成!导出到langpatcher.json",
"commands.vaultpatcher.export.warning.wip": "警告:此功能仍是WIP!"
}
4 changes: 3 additions & 1 deletion src/main/resources/mixins.vaultpatcher.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"mixinPriority": 2147483647,
"priority": 2147483647,
"compatibilityLevel": "JAVA_17",
"minVersion": "1",
"minVersion": "0.6",
"package": "me.fengming.vaultpatcher.mixin",
"refmap": "mixins.vaultpatcher.refmap.json",
"mixins": [
Expand Down

0 comments on commit 632a3c9

Please sign in to comment.