├── test └── en_us.json ├── assets └── logo.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src └── main │ ├── resources │ ├── assets │ │ └── meteor-translation-addon │ │ │ └── icon.png │ ├── addon-translation.mixins.json │ └── fabric.mod.json │ └── java │ └── com │ └── nippaku_zanmu │ └── trans_addon │ ├── mixin │ ├── SettingGroupAccessor.java │ ├── SettingAccessor.java │ ├── ModuleAccessor.java │ ├── HudRenderer │ │ ├── FontHolder.java │ │ └── HudRendererMixin.java │ ├── DefaultSettingsWidgetFactoryMixin.java │ └── CustomTextRendererMixin.java │ ├── util │ ├── trans_engine │ │ ├── IKeyGenerate.java │ │ ├── EngineManager.java │ │ ├── AbstractTransEngine.java │ │ ├── TransEngineNew.java │ │ └── TransEngineOld.java │ ├── KeyBuilder.java │ ├── TransUtil.java │ └── JsonDump.java │ ├── MeteorTranslation.java │ ├── settings │ ├── ExtraSettings.java │ ├── StringSelectSetting.java │ └── StringSelectScreen.java │ ├── modules │ └── Translation.java │ └── font_fix │ └── FontFix.java ├── .editorconfig ├── settings.gradle ├── gradle.properties ├── .gitignore ├── .github └── workflows │ ├── pull_request.yml │ └── dev_build.yml ├── README.md ├── gradlew.bat ├── gradlew └── LICENSE /test/en_us.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nippaku-Zanmu/meteor-translation-addon/HEAD/assets/logo.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nippaku-Zanmu/meteor-translation-addon/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/assets/meteor-translation-addon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nippaku-Zanmu/meteor-translation-addon/HEAD/src/main/resources/assets/meteor-translation-addon/icon.png -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | charset = utf-8 3 | indent_style = space 4 | insert_final_newline = true 5 | trim_trailing_whitespace = true 6 | indent_size = 4 7 | 8 | [*.{json, yml}] 9 | indent_size = 2 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | name = 'Fabric' 5 | url = 'https://maven.fabricmc.net/' 6 | } 7 | mavenCentral() 8 | gradlePluginPortal() 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2G 2 | 3 | # Fabric Properties (https://fabricmc.net/develop) 4 | minecraft_version=1.21.11 5 | yarn_mappings=1.21.11+build.3 6 | loader_version=0.18.2 7 | 8 | # Mod Properties 9 | mod_version=0.7.2 10 | maven_group=com.nippaku_zanmu 11 | archives_base_name=translation-addon 12 | 13 | 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # gradle 2 | 3 | .gradle/ 4 | build/ 5 | out/ 6 | classes/ 7 | 8 | # eclipse 9 | 10 | *.launch 11 | 12 | # idea 13 | 14 | .idea/ 15 | *.iml 16 | *.ipr 17 | *.iws 18 | 19 | # vscode 20 | 21 | .settings/ 22 | .vscode/ 23 | bin/ 24 | .classpath 25 | .project 26 | 27 | # macos 28 | 29 | *.DS_Store 30 | 31 | # fabric 32 | 33 | run/ 34 | -------------------------------------------------------------------------------- /src/main/resources/addon-translation.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "com.nippaku_zanmu.trans_addon.mixin", 4 | "compatibilityLevel": "JAVA_21", 5 | "injectors": { 6 | "defaultRequire": 1 7 | }, 8 | "mixins": [ 9 | "CustomTextRendererMixin", 10 | "DefaultSettingsWidgetFactoryMixin", 11 | "ModuleAccessor", 12 | "SettingAccessor", 13 | "SettingGroupAccessor" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/mixin/SettingGroupAccessor.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.mixin; 2 | 3 | import meteordevelopment.meteorclient.settings.Setting; 4 | import meteordevelopment.meteorclient.settings.SettingGroup; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Accessor; 7 | 8 | import java.util.List; 9 | 10 | @Mixin(value = SettingGroup.class, remap = false) 11 | public interface SettingGroupAccessor { 12 | @Accessor("settings") 13 | public List> getSettings(); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/mixin/SettingAccessor.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.mixin; 2 | 3 | import meteordevelopment.meteorclient.settings.Setting; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.Mutable; 6 | import org.spongepowered.asm.mixin.gen.Accessor; 7 | 8 | @Mixin(value = Setting.class,remap = false) 9 | public interface SettingAccessor { 10 | @Accessor("title") 11 | @Mutable 12 | public void setTitle(String title); 13 | @Accessor( "description") 14 | @Mutable 15 | public void setDescription(String description); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/util/trans_engine/IKeyGenerate.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.util.trans_engine; 2 | 3 | import meteordevelopment.meteorclient.settings.Setting; 4 | import meteordevelopment.meteorclient.settings.SettingGroup; 5 | import meteordevelopment.meteorclient.systems.modules.Module; 6 | 7 | public interface IKeyGenerate { 8 | String getModuleNameKey(Module m); 9 | String getModuleDescriptionKey(Module m); 10 | String getSettingNameKey(Module module, SettingGroup group, Setting s); 11 | String getSettingDesKey(Module module, SettingGroup group, Setting s); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/mixin/ModuleAccessor.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.mixin; 2 | 3 | import meteordevelopment.meteorclient.systems.modules.Module; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.Mutable; 6 | import org.spongepowered.asm.mixin.Unique; 7 | import org.spongepowered.asm.mixin.gen.Accessor; 8 | 9 | @Mixin(value = Module.class,remap = false) 10 | public interface ModuleAccessor { 11 | 12 | 13 | @Mutable 14 | @Accessor("title") 15 | public void setTitle(String title); 16 | @Mutable 17 | @Accessor("description") 18 | public void setDescription(String description); 19 | } 20 | -------------------------------------------------------------------------------- /.github/workflows/pull_request.yml: -------------------------------------------------------------------------------- 1 | name: Build Pull Request Artifacts 2 | on: pull_request 3 | 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: Checkout Repository 9 | uses: actions/checkout@v4 10 | - name: Wrapper Validation 11 | uses: gradle/actions/wrapper-validation@v3 12 | - name: Set up Java 13 | uses: actions/setup-java@v4 14 | with: 15 | java-version: 21 16 | distribution: adopt 17 | - name: Build with Gradle 18 | run: ./gradlew build 19 | - name: Release 20 | uses: actions/upload-artifact@v4 21 | with: 22 | name: Artifacts 23 | path: build/libs/ 24 | -------------------------------------------------------------------------------- /.github/workflows/dev_build.yml: -------------------------------------------------------------------------------- 1 | name: Publish Development Build 2 | on: push 3 | 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: Checkout Repository 9 | uses: actions/checkout@v4 10 | - name: Wrapper Validation 11 | uses: gradle/actions/wrapper-validation@v3 12 | - name: Set up Java 13 | uses: actions/setup-java@v4 14 | with: 15 | java-version: 21 16 | distribution: adopt 17 | - name: Build with Gradle 18 | run: ./gradlew build 19 | - name: Release 20 | uses: marvinpinto/action-automatic-releases@latest 21 | with: 22 | repo_token: '${{ secrets.GITHUB_TOKEN }}' 23 | automatic_release_tag: latest 24 | prerelease: true 25 | title: Dev Build 26 | files: | 27 | ./build/libs/*.jar 28 | -------------------------------------------------------------------------------- /src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "meteor-translation-addon", 4 | "version": "${version}", 5 | "name": "Meteor Translation Addon", 6 | "description": "An addon offers unicode font rendering fix and translation for Meteor.", 7 | "authors": [ 8 | "Nippaku Zanmu" 9 | ], 10 | "contact": { 11 | "repo": "https://github.com/MeteorDevelopment/meteor-addon-template" 12 | }, 13 | "icon": "assets/meteor-translation-addon/icon.png", 14 | "environment": "client", 15 | "entrypoints": { 16 | "meteor": [ 17 | "com.nippaku_zanmu.trans_addon.MeteorTranslation" 18 | ] 19 | }, 20 | "mixins": [ 21 | "addon-translation.mixins.json" 22 | ], 23 | "custom": { 24 | "meteor-client:color": "231,25,25" 25 | }, 26 | "depends": { 27 | "java": ">=17", 28 | "minecraft": [">=1.21"], 29 | "meteor-client": "*" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/mixin/HudRenderer/FontHolder.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.mixin.HudRenderer; 2 | 3 | import com.nippaku_zanmu.trans_addon.font_fix.FontFix; 4 | import meteordevelopment.meteorclient.renderer.MeshBuilder; 5 | import meteordevelopment.meteorclient.renderer.MeteorRenderPipelines; 6 | 7 | public class FontHolder { 8 | public final FontFix font; 9 | public boolean visited; 10 | 11 | private MeshBuilder mesh; 12 | 13 | public FontHolder(FontFix font) { 14 | this.font = font; 15 | } 16 | 17 | public MeshBuilder getMesh() { 18 | if (mesh == null) mesh = new MeshBuilder(MeteorRenderPipelines.UI_TEXT); 19 | if (!mesh.isBuilding()) mesh.begin(); 20 | return mesh; 21 | } 22 | 23 | public void destroy() { 24 | font.texture.close(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/util/trans_engine/EngineManager.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.util.trans_engine; 2 | 3 | import java.util.LinkedHashMap; 4 | import java.util.List; 5 | import java.util.Set; 6 | 7 | public class EngineManager { 8 | private static final EngineManager INSTANCE = new EngineManager(); 9 | 10 | public static EngineManager getInstance() { 11 | return INSTANCE; 12 | } 13 | 14 | public Set getEngineNames() { 15 | return engines.keySet(); 16 | } 17 | 18 | public AbstractTransEngine getEngine(String name) { 19 | AbstractTransEngine engine = engines.get(name); 20 | return engine == null ? engines.get("OLD") : engine; 21 | } 22 | 23 | LinkedHashMap engines = new LinkedHashMap<>(); 24 | 25 | private EngineManager(){ 26 | engines.put("OLD", new TransEngineOld()); 27 | engines.put("NEW", new TransEngineNew()); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | meteor-translation-addon 3 | 4 |

Meteor Translation Addon

5 |

流星翻译插件

6 |
7 | 8 | 9 | 本模组翻译已完成 10 | 感谢 [顶针](https://github.com/dingzhen-vape) 提供的lang文件 11 | 12 | 如有翻译错误请提交 Issue/PR 并注明理由 13 | 14 | 把流星端的模块名称翻译为你游戏的语言 15 | 16 | ### How to use 17 | ## 如何使用 18 | Click the Translation button on the Translation module configuration screen 19 | 点击 Translation 模块中的 Translation按钮 20 | 21 | ### Why is it useless? 22 | ## 为啥没有用 23 | The module may not support your game language. Set the language to a supported language such as Chinese 24 | 25 | 模块可能不支持你的游戏语言 将语言设置为支持的语言 比如中文 26 | 27 | ## 为什么启用翻译过后功能名称一片空白/流星端字体无法正常渲染 28 | 29 | 0.2版本已修复流星字体渲染引擎的问题 如果模块名称无法正常显示 请将流星的自定义字体切换为任意支持中文的字体 30 | 31 | ## 鸣谢列表 32 | [MeteorDevelopment](https://github.com/MeteorDevelopment) 的流星端插件模板 33 | 34 | [顶针](https://github.com/dingzhen-vape) 为本插件提供完整的翻译文件 35 | 36 | [E0x72-24](https://github.com/E0x72-24) 为本项目绘制图标以及优化Readme文档 37 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/mixin/DefaultSettingsWidgetFactoryMixin.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.mixin; 2 | 3 | 4 | import com.nippaku_zanmu.trans_addon.settings.ExtraSettings; 5 | import meteordevelopment.meteorclient.gui.DefaultSettingsWidgetFactory; 6 | import meteordevelopment.meteorclient.gui.GuiTheme; 7 | import meteordevelopment.meteorclient.gui.utils.SettingsWidgetFactory; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | @Mixin(DefaultSettingsWidgetFactory.class) 14 | public abstract class DefaultSettingsWidgetFactoryMixin extends SettingsWidgetFactory { 15 | public DefaultSettingsWidgetFactoryMixin(GuiTheme theme) { 16 | super(theme); 17 | } 18 | 19 | @Inject(method = "", at = @At("TAIL"), remap = false) 20 | private void onInit(GuiTheme theme, CallbackInfo ci) { 21 | new ExtraSettings(factories, this.theme).addSettings(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/util/trans_engine/AbstractTransEngine.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.util.trans_engine; 2 | 3 | import com.nippaku_zanmu.trans_addon.util.TransUtil; 4 | import meteordevelopment.meteorclient.settings.Setting; 5 | import meteordevelopment.meteorclient.settings.SettingGroup; 6 | import meteordevelopment.meteorclient.systems.modules.Module; 7 | 8 | public abstract class AbstractTransEngine implements IKeyGenerate { 9 | 10 | public String transModuleName(Module module){ 11 | return TransUtil.trans(getModuleNameKey(module),module.name); 12 | } 13 | public String transModuleDescription(Module module){ 14 | return TransUtil.trans(getModuleDescriptionKey(module),module.description); 15 | } 16 | public String transSettingName(Module module, SettingGroup group, Setting s){ 17 | return TransUtil.trans(getSettingNameKey(module,group,s),s.name); 18 | } 19 | public String transSettingDes(Module module, SettingGroup group, Setting s){ 20 | return TransUtil.trans(getSettingDesKey(module,group,s),s.description); 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/util/KeyBuilder.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.util; 2 | 3 | import meteordevelopment.meteorclient.systems.modules.Module; 4 | 5 | public class KeyBuilder { 6 | StringBuilder sb = new StringBuilder(); 7 | 8 | public KeyBuilder(Module m) { 9 | append("meteor") 10 | .append(TransUtil.getAddonName(m)) 11 | .append(TransUtil.baseFormat(m.category.name)) 12 | .append(TransUtil.baseFormat(m.name)); 13 | } 14 | 15 | public KeyBuilder() { 16 | append("meteor"); 17 | } 18 | 19 | public KeyBuilder reset() { 20 | sb = new StringBuilder(); 21 | append("meteor"); 22 | return this; 23 | } 24 | 25 | public KeyBuilder module(Module m) { 26 | append(TransUtil.getAddonName(m)) 27 | .append(TransUtil.baseFormat(m.category.name)) 28 | .append(TransUtil.baseFormat(m.name)); 29 | return this; 30 | } 31 | 32 | public KeyBuilder append(String s) { 33 | sb.append(s).append("."); 34 | return this; 35 | } 36 | 37 | public KeyBuilder appendWithFormat(String s) { 38 | sb.append(TransUtil.baseFormat(s)).append("."); 39 | return this; 40 | } 41 | 42 | public String end(String s) { 43 | return sb.append(s).toString(); 44 | } 45 | public String endWithFormat(String s) { 46 | return sb.append(TransUtil.baseFormat(s)).toString(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/MeteorTranslation.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon; 2 | 3 | 4 | import com.mojang.logging.LogUtils; 5 | import com.nippaku_zanmu.trans_addon.modules.Translation; 6 | import meteordevelopment.meteorclient.addons.GithubRepo; 7 | import meteordevelopment.meteorclient.addons.MeteorAddon; 8 | import meteordevelopment.meteorclient.systems.hud.HudGroup; 9 | import meteordevelopment.meteorclient.systems.modules.Category; 10 | import meteordevelopment.meteorclient.systems.modules.Modules; 11 | import org.slf4j.Logger; 12 | 13 | import java.io.BufferedWriter; 14 | import java.io.FileNotFoundException; 15 | import java.io.FileOutputStream; 16 | import java.io.OutputStreamWriter; 17 | import java.nio.charset.StandardCharsets; 18 | 19 | public class MeteorTranslation extends MeteorAddon { 20 | public static final Logger LOG = LogUtils.getLogger(); 21 | public static final Category CATEGORY = new Category("MeteorTranslation"); 22 | @Override 23 | public void onInitialize() { 24 | LOG.info("Initializing MeteorTransaction"); 25 | 26 | // Modules 27 | Modules.get().add(new Translation()); 28 | 29 | } 30 | 31 | @Override 32 | public void onRegisterCategories() { 33 | Modules.registerCategory(CATEGORY); 34 | } 35 | 36 | @Override 37 | public String getPackage() { 38 | return "com.nippaku_zanmu.trans_addon"; 39 | } 40 | 41 | @Override 42 | public GithubRepo getRepo() { 43 | return new GithubRepo("Nippaku-Zanmu", "meteor-translation-addon"); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/util/TransUtil.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.util; 2 | 3 | import meteordevelopment.meteorclient.addons.AddonManager; 4 | import meteordevelopment.meteorclient.systems.modules.Module; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.text.Text; 7 | 8 | import java.util.Set; 9 | import java.util.stream.Collectors; 10 | 11 | public class TransUtil { 12 | private static final MinecraftClient mc = MinecraftClient.getInstance(); 13 | 14 | private static String trans(String s) { 15 | return Text.translatable(s).getString(); 16 | } 17 | public static String trans(String key,String alternative){ 18 | String trans = trans(key); 19 | //调用mc函数翻译 20 | if (trans.equals(key)) { 21 | return alternative; 22 | }//如果没有翻译 即翻译后的还是原本的key 则返回原名称 23 | return trans; 24 | } 25 | 26 | public static Set getAddonNames() { 27 | return AddonManager.ADDONS.stream().map(addon -> addon.name).map(TransUtil::baseFormat).collect(Collectors.toSet()); 28 | } 29 | 30 | public static String getAddonName(Module m) { 31 | return TransUtil.baseFormat(m.addon == null ? "unknow_addon" : m.addon.name); 32 | } 33 | 34 | public static String baseFormat(String s) { 35 | //把某些Addon作者的不规范模块命名还原 36 | s = s.toLowerCase(); 37 | s = s.replace(" ", "_"); 38 | s = s.replace("-", "_"); 39 | s = s.replace(".", "_"); 40 | s = s.replace("\"", "_"); 41 | return s; 42 | } 43 | public static String formatValue(String s){ 44 | s = s.replace("\"", "\\\""); 45 | return s; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/util/trans_engine/TransEngineNew.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.util.trans_engine; 2 | 3 | import com.nippaku_zanmu.trans_addon.util.KeyBuilder; 4 | import com.nippaku_zanmu.trans_addon.util.TransUtil; 5 | import meteordevelopment.meteorclient.settings.Setting; 6 | import meteordevelopment.meteorclient.settings.SettingGroup; 7 | import meteordevelopment.meteorclient.systems.modules.Module; 8 | 9 | public class TransEngineNew extends AbstractTransEngine { 10 | KeyBuilder builder = new KeyBuilder(); 11 | 12 | @Override 13 | public String getModuleNameKey(Module module) { 14 | builder.reset(); 15 | String key = builder.module(module).end("name"); 16 | return key; 17 | } 18 | 19 | @Override 20 | public String getModuleDescriptionKey(Module module) { 21 | builder.reset(); 22 | String key = builder.module(module).end("description"); 23 | return key; 24 | } 25 | 26 | @Override 27 | public String getSettingNameKey(Module module, SettingGroup group, Setting s) { 28 | String settingName = s.name; 29 | builder.reset(); 30 | String key = builder.module(module) 31 | .appendWithFormat("setting") 32 | .appendWithFormat(group.name) 33 | .appendWithFormat(settingName) 34 | .end("name"); 35 | return key; 36 | } 37 | 38 | @Override 39 | public String getSettingDesKey(Module module, SettingGroup group, Setting s) { 40 | String settingName = s.name; 41 | builder.reset(); 42 | String key = builder.module(module) 43 | .appendWithFormat("setting") 44 | .appendWithFormat(group.name) 45 | .appendWithFormat(settingName) 46 | .end("description"); 47 | return key; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/util/trans_engine/TransEngineOld.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.util.trans_engine; 2 | 3 | import com.nippaku_zanmu.trans_addon.util.KeyBuilder; 4 | import com.nippaku_zanmu.trans_addon.util.TransUtil; 5 | import meteordevelopment.meteorclient.settings.Setting; 6 | import meteordevelopment.meteorclient.settings.SettingGroup; 7 | import meteordevelopment.meteorclient.systems.modules.Category; 8 | import meteordevelopment.meteorclient.systems.modules.Module; 9 | 10 | public class TransEngineOld extends AbstractTransEngine { 11 | KeyBuilder builder = new KeyBuilder(); 12 | @Override 13 | public String getModuleNameKey(Module module) { 14 | String moduleName = module.name; 15 | builder.reset(); 16 | String key = builder.append(TransUtil.getAddonName(module)) 17 | .append(TransUtil.baseFormat(module.category.name)) 18 | .end(TransUtil.baseFormat(moduleName)); 19 | return key; 20 | } 21 | 22 | @Override 23 | public String getModuleDescriptionKey(Module module) { 24 | builder.reset(); 25 | String key = builder.module(module).end("description"); 26 | return key; 27 | } 28 | 29 | @Override 30 | public String getSettingNameKey(Module module, SettingGroup group, Setting s) { 31 | String settingName = s.name; 32 | builder.reset(); 33 | String key = builder.module(module) 34 | .append("setting") 35 | .append(group.name) 36 | .end(settingName) 37 | ; 38 | return key; 39 | } 40 | 41 | @Override 42 | public String getSettingDesKey(Module module, SettingGroup group, Setting s) { 43 | String settingName = s.name; 44 | builder.reset(); 45 | String key = builder.module(module) 46 | .append("setting") 47 | .append(group.name) 48 | .append(settingName) 49 | .end("description") 50 | ; 51 | return key; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /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 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/util/JsonDump.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.util; 2 | 3 | import com.nippaku_zanmu.trans_addon.mixin.ModuleAccessor; 4 | import com.nippaku_zanmu.trans_addon.mixin.SettingAccessor; 5 | import com.nippaku_zanmu.trans_addon.mixin.SettingGroupAccessor; 6 | import com.nippaku_zanmu.trans_addon.modules.Translation; 7 | import com.nippaku_zanmu.trans_addon.util.trans_engine.AbstractTransEngine; 8 | import meteordevelopment.meteorclient.settings.Setting; 9 | import meteordevelopment.meteorclient.settings.SettingGroup; 10 | import meteordevelopment.meteorclient.systems.modules.Module; 11 | import meteordevelopment.meteorclient.systems.modules.Modules; 12 | import meteordevelopment.meteorclient.utils.Utils; 13 | import meteordevelopment.meteorclient.utils.player.ChatUtils; 14 | import net.minecraft.client.MinecraftClient; 15 | 16 | import java.io.*; 17 | import java.nio.charset.StandardCharsets; 18 | import java.util.LinkedHashMap; 19 | import java.util.LinkedHashSet; 20 | import java.util.Map; 21 | 22 | public class JsonDump { 23 | public static JsonDump getINSTANCE() { 24 | return INSTANCE; 25 | } 26 | 27 | private static final JsonDump INSTANCE = new JsonDump(); 28 | 29 | // private LinkedHashSet keySet = new LinkedHashSet<>(); 30 | private LinkedHashMap entMap = new LinkedHashMap<>(); 31 | private BufferedWriter dumpBW; 32 | 33 | private Translation getTran() { 34 | return Modules.get().get(Translation.class); 35 | } 36 | 37 | 38 | public void write(AbstractTransEngine engine, AbstractTransEngine engine2) { 39 | 40 | dump2Set(engine, engine2); 41 | 42 | try { 43 | File path = new File(getTran().sSetDumpPath.get()); 44 | if (!path.exists() & !(path.createNewFile())) { 45 | ChatUtils.warning("DumpError Can't Create Dump File"); 46 | entMap.clear(); 47 | return; 48 | } 49 | dumpBW = new BufferedWriter(new OutputStreamWriter( 50 | new FileOutputStream(path, false), StandardCharsets.UTF_8)); 51 | 52 | for (Map.Entry entry : entMap.entrySet()) { 53 | dumpBW.write("\"" + entry.getKey() + "\"" + ":" + "\"" + TransUtil.formatValue(entry.getValue()) + "\"" + ","); 54 | dumpBW.newLine(); 55 | } 56 | 57 | dumpBW.flush(); 58 | dumpBW.close(); 59 | 60 | } catch (IOException e) { 61 | ChatUtils.error(e.getMessage()); 62 | entMap.clear(); 63 | return; 64 | } finally { 65 | try { 66 | if (dumpBW != null) 67 | dumpBW.close(); 68 | } catch (IOException ignore) { 69 | } 70 | } 71 | 72 | 73 | entMap.clear(); 74 | } 75 | 76 | private void dump2Set(AbstractTransEngine engine, AbstractTransEngine engine2) { 77 | boolean dumpText = getTran().bSetDumpText.get(); 78 | for (Module module : Modules.get().getAll()) { 79 | String addonName = TransUtil.getAddonName(module); 80 | if (!getTran().translationModules.get().contains(addonName)) continue; 81 | //插件过滤 82 | 83 | 84 | String nameKey = engine.getModuleNameKey(module); 85 | addEntry(nameKey, dumpText ? engine2.transModuleName(module) : module.name); 86 | 87 | String desKey = engine.getModuleDescriptionKey(module); 88 | addEntry(desKey, dumpText ? engine2.transModuleDescription(module) : module.description); 89 | 90 | for (SettingGroup group : module.settings.groups) { 91 | for (Setting setting : ((SettingGroupAccessor) group).getSettings()) { 92 | 93 | String settingNameKey = engine.getSettingNameKey(module, group, setting); 94 | addEntry(settingNameKey, dumpText ? engine2.transSettingName(module, group, setting) : setting.name); 95 | 96 | String settDescKey = engine.getSettingDesKey(module, group, setting); 97 | addEntry(settDescKey, dumpText ? engine2.transSettingDes(module, group, setting) : setting.description); 98 | 99 | 100 | } 101 | } 102 | 103 | } 104 | } 105 | 106 | private void addEntry(String key, String value) { 107 | entMap.putIfAbsent(key, value); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/settings/ExtraSettings.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.settings; 2 | 3 | 4 | import meteordevelopment.meteorclient.gui.DefaultSettingsWidgetFactory; 5 | import meteordevelopment.meteorclient.gui.GuiTheme; 6 | import meteordevelopment.meteorclient.gui.renderer.GuiRenderer; 7 | import meteordevelopment.meteorclient.gui.screens.settings.EntityTypeListSettingScreen; 8 | import meteordevelopment.meteorclient.gui.themes.meteor.widgets.WMeteorLabel; 9 | import meteordevelopment.meteorclient.gui.utils.SettingsWidgetFactory; 10 | import meteordevelopment.meteorclient.gui.widgets.containers.WContainer; 11 | import meteordevelopment.meteorclient.gui.widgets.containers.WHorizontalList; 12 | import meteordevelopment.meteorclient.gui.widgets.containers.WTable; 13 | import meteordevelopment.meteorclient.gui.widgets.pressable.WButton; 14 | import meteordevelopment.meteorclient.settings.EntityTypeListSetting; 15 | import meteordevelopment.meteorclient.settings.Setting; 16 | import meteordevelopment.meteorclient.settings.Settings; 17 | 18 | import java.util.Collection; 19 | import java.util.Map; 20 | 21 | import static meteordevelopment.meteorclient.MeteorClient.mc; 22 | 23 | public class ExtraSettings { 24 | private final Map, SettingsWidgetFactory.Factory> factories; 25 | 26 | private final GuiTheme theme; 27 | 28 | public ExtraSettings(Map, SettingsWidgetFactory.Factory> factories, GuiTheme theme) { 29 | this.factories = factories; 30 | this.theme = theme; 31 | } 32 | 33 | public void addSettings() { 34 | //factories.put(StringMapSetting.class, (table, setting) -> stringMapW(table, (StringMapSetting) setting)); 35 | 36 | factories.put(StringSelectSetting.class, (table, setting) -> stringSelectW(table, (StringSelectSetting) setting)); } 37 | 38 | private void stringSelectW(WTable table, StringSelectSetting setting) { 39 | selectW(table, setting, () -> mc.setScreen(new StringSelectScreen(theme, setting))); 40 | 41 | }private void selectW(WContainer c, Setting setting, Runnable action) { 42 | boolean addCount = WSelectedCountLabel.getSize(setting) != -1; 43 | 44 | WContainer c2 = c; 45 | if (addCount) { 46 | c2 = c.add(theme.horizontalList()).expandCellX().widget(); 47 | ((WHorizontalList) c2).spacing *= 2; 48 | } 49 | 50 | WButton button = c2.add(theme.button("Select")).expandCellX().widget(); 51 | button.action = action; 52 | 53 | if (addCount) c2.add(new WSelectedCountLabel(setting).color(theme.textSecondaryColor())); 54 | 55 | reset(c, setting, null); 56 | } 57 | 58 | private void reset(WContainer c, Setting setting, Runnable action) { 59 | WButton reset = c.add(theme.button(GuiRenderer.RESET)).widget(); 60 | reset.action = () -> { 61 | setting.reset(); 62 | if (action != null) action.run(); 63 | }; 64 | } 65 | 66 | // private void stringMapW(WTable table, StringMapSetting setting) { 67 | // WTable wtable = table.add(theme.table()).expandX().widget(); 68 | // StringMapSetting.fillTable(theme, wtable, setting); 69 | // } 70 | 71 | 72 | 73 | 74 | 75 | private static class WSelectedCountLabel extends WMeteorLabel { 76 | private final Setting setting; 77 | private int lastSize = -1; 78 | 79 | public WSelectedCountLabel(Setting setting) { 80 | super("", false); 81 | 82 | this.setting = setting; 83 | } 84 | 85 | @Override 86 | protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, double delta) { 87 | int size = getSize(setting); 88 | 89 | if (size != lastSize) { 90 | if (setting.get()instanceof Settings){ 91 | set("(" + size + " Group)"); 92 | }else 93 | set("(" + size + " selected)"); 94 | lastSize = size; 95 | } 96 | 97 | super.onRender(renderer, mouseX, mouseY, delta); 98 | } 99 | 100 | public static int getSize(Setting setting) { 101 | if (setting.get() instanceof Collection collection) return collection.size(); 102 | if (setting.get() instanceof Map map) return map.size(); 103 | if (setting.get() instanceof Settings) return ((Settings) setting.get()).groups.size(); 104 | return -1; 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/mixin/CustomTextRendererMixin.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.mixin; 2 | 3 | import com.nippaku_zanmu.trans_addon.font_fix.FontFix; 4 | import meteordevelopment.meteorclient.renderer.*; 5 | import meteordevelopment.meteorclient.renderer.text.CustomTextRenderer; 6 | import meteordevelopment.meteorclient.renderer.text.Font; 7 | import meteordevelopment.meteorclient.renderer.text.FontFace; 8 | import meteordevelopment.meteorclient.renderer.text.TextRenderer; 9 | import meteordevelopment.meteorclient.utils.Utils; 10 | import meteordevelopment.meteorclient.utils.render.color.Color; 11 | import net.minecraft.client.MinecraftClient; 12 | import org.lwjgl.BufferUtils; 13 | import org.spongepowered.asm.mixin.*; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Inject; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 17 | 18 | import java.nio.ByteBuffer; 19 | 20 | import static meteordevelopment.meteorclient.renderer.text.CustomTextRenderer.SHADOW_COLOR; 21 | 22 | @Mixin(value = CustomTextRenderer.class, remap = false) 23 | public abstract class CustomTextRendererMixin implements TextRenderer { 24 | 25 | @Shadow 26 | @Final 27 | private MeshBuilder mesh = new MeshBuilder(MeteorRenderPipelines.UI_TEXT); 28 | 29 | 30 | private FontFix[] fonts_fix; 31 | private FontFix font_fix; 32 | 33 | @Shadow 34 | private boolean building; 35 | @Shadow 36 | private boolean scaleOnly; 37 | @Shadow 38 | private double fontScale = 1; 39 | @Shadow 40 | private double scale = 1; 41 | 42 | 43 | @Inject(method = "",at = @At("RETURN")) 44 | public void onInit(FontFace fontFace, CallbackInfo ci) { 45 | 46 | byte[] bytes = Utils.readBytes(fontFace.toStream()); 47 | ByteBuffer buffer = BufferUtils.createByteBuffer(bytes.length).put(bytes).flip(); 48 | 49 | fonts_fix = new FontFix[5]; 50 | for (int i = 0; i < fonts_fix.length; i++) { 51 | fonts_fix[i] = new FontFix(buffer, (int) Math.round(27 * ((i * 0.5) + 1))); 52 | } 53 | } 54 | 55 | 56 | 57 | /** 58 | * @author Nippaku_Zanmu 59 | * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 60 | */ 61 | @Overwrite 62 | public void begin(double scale, boolean scaleOnly, boolean big) { 63 | if (building) throw new RuntimeException("CustomTextRenderer.begin() called twice"); 64 | 65 | if (!scaleOnly) mesh.begin(); 66 | 67 | if (big) { 68 | this.font_fix = fonts_fix[fonts_fix.length - 1]; 69 | } 70 | else { 71 | double scaleA = Math.floor(scale * 10) / 10; 72 | 73 | int scaleI; 74 | if (scaleA >= 3) scaleI = 5; 75 | else if (scaleA >= 2.5) scaleI = 4; 76 | else if (scaleA >= 2) scaleI = 3; 77 | else if (scaleA >= 1.5) scaleI = 2; 78 | else scaleI = 1; 79 | 80 | font_fix = fonts_fix[scaleI - 1]; 81 | } 82 | 83 | this.building = true; 84 | this.scaleOnly = scaleOnly; 85 | 86 | this.fontScale = font_fix.getHeight() / 27.0; 87 | this.scale = 1 + (scale - fontScale) / fontScale; 88 | } 89 | /** 90 | * @author Nippaku_Zanmu 91 | * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 92 | */ 93 | @Overwrite 94 | public double getWidth(String text, int length, boolean shadow) { 95 | if (text.isEmpty()) return 0; 96 | 97 | FontFix font = building ? this.font_fix : fonts_fix[0]; 98 | return (font.getWidth(text, length) + (shadow ? 1 : 0)) * scale / 1.5; 99 | } 100 | /** 101 | * @author Nippaku_Zanmu 102 | * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 103 | */ 104 | @Overwrite 105 | public double getHeight(boolean shadow) { 106 | FontFix font = building ? this.font_fix : fonts_fix[0]; 107 | return (font.getHeight() + 1 + (shadow ? 1 : 0)) * scale / 1.5; 108 | } 109 | /** 110 | * @author Nippaku_Zanmu 111 | * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 112 | */ 113 | @Overwrite 114 | public double render(String text, double x, double y, Color color, boolean shadow) { 115 | boolean wasBuilding = building; 116 | if (!wasBuilding) begin(); 117 | 118 | double width; 119 | if (shadow) { 120 | int preShadowA = SHADOW_COLOR.a; 121 | SHADOW_COLOR.a = (int) (color.a / 255.0 * preShadowA); 122 | 123 | width = font_fix.render(mesh, text, x + fontScale * scale / 1.5, y + fontScale * scale / 1.5, SHADOW_COLOR, scale / 1.5); 124 | font_fix.render(mesh, text, x, y, color, scale / 1.5); 125 | 126 | SHADOW_COLOR.a = preShadowA; 127 | } 128 | else { 129 | width = font_fix.render(mesh, text, x, y, color, scale / 1.5); 130 | } 131 | 132 | if (!wasBuilding) end(); 133 | return width; 134 | } 135 | 136 | /** 137 | * @author Nippaku_Zanmu 138 | * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 139 | */ 140 | @Overwrite 141 | public void end() { 142 | if (!building) throw new RuntimeException("CustomTextRenderer.end() called without calling begin()"); 143 | 144 | if (!scaleOnly) { 145 | mesh.end(); 146 | 147 | MeshRenderer.begin() 148 | .attachments(MinecraftClient.getInstance().getFramebuffer()) 149 | .pipeline(MeteorRenderPipelines.UI_TEXT) 150 | .mesh(mesh) 151 | .sampler("u_Texture", font_fix.texture.getGlTextureView(), font_fix.texture.getSampler()) 152 | .end(); 153 | } 154 | 155 | building = false; 156 | scale = 1; 157 | } 158 | 159 | public void destroy() {} 160 | } 161 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/modules/Translation.java: -------------------------------------------------------------------------------- 1 | package com.nippaku_zanmu.trans_addon.modules; 2 | 3 | 4 | import com.nippaku_zanmu.trans_addon.MeteorTranslation; 5 | import com.nippaku_zanmu.trans_addon.settings.StringSelectSetting; 6 | import com.nippaku_zanmu.trans_addon.util.JsonDump; 7 | import com.nippaku_zanmu.trans_addon.util.TransUtil; 8 | import com.nippaku_zanmu.trans_addon.mixin.ModuleAccessor; 9 | import com.nippaku_zanmu.trans_addon.mixin.SettingAccessor; 10 | import com.nippaku_zanmu.trans_addon.mixin.SettingGroupAccessor; 11 | import com.nippaku_zanmu.trans_addon.util.trans_engine.AbstractTransEngine; 12 | import com.nippaku_zanmu.trans_addon.util.trans_engine.EngineManager; 13 | import meteordevelopment.meteorclient.gui.GuiTheme; 14 | import meteordevelopment.meteorclient.gui.widgets.WWidget; 15 | import meteordevelopment.meteorclient.gui.widgets.containers.WHorizontalList; 16 | import meteordevelopment.meteorclient.gui.widgets.containers.WVerticalList; 17 | import meteordevelopment.meteorclient.gui.widgets.pressable.WButton; 18 | import meteordevelopment.meteorclient.settings.*; 19 | import meteordevelopment.meteorclient.systems.modules.Module; 20 | import meteordevelopment.meteorclient.systems.modules.Modules; 21 | import meteordevelopment.meteorclient.utils.Utils; 22 | import meteordevelopment.meteorclient.utils.player.ChatUtils; 23 | 24 | import java.util.Set; 25 | 26 | public class Translation extends Module { 27 | private final SettingGroup sgGeneral = this.settings.getDefaultGroup(); 28 | 29 | public final Setting bSetAutoTranslation = sgGeneral.add(new BoolSetting.Builder() 30 | .name("auto-translation") 31 | .description("") 32 | .defaultValue(false) 33 | .build()); 34 | 35 | public final Setting> translationModules = sgGeneral.add(new StringSelectSetting.Builder() 36 | .validValues(TransUtil.getAddonNames()) 37 | .defaultValue(TransUtil.getAddonNames()) 38 | .name("translation-modules") 39 | .build()); 40 | 41 | private final SettingGroup sgDev = this.settings.createGroup("Dev", false); 42 | 43 | public final Setting strSetTransEngine = sgDev.add(new StringSetting.Builder() 44 | .defaultValue("NEW") 45 | .name("translation-engine") 46 | .build()); 47 | 48 | 49 | public final Setting sSetDumpPath = sgDev.add(new StringSetting.Builder() 50 | .name("dump-path") 51 | .defaultValue("D:\\hack\\Misc\\meteor-translation-addon\\test\\en_us.json") 52 | .build()); 53 | 54 | public final Setting bSetDumpText = sgDev.add(new BoolSetting.Builder() 55 | .name("dump-text") 56 | .defaultValue(false) 57 | .build() 58 | ); 59 | public final Setting strSetDumpTextEngine = sgDev.add(new StringSetting.Builder() 60 | .defaultValue("OLD") 61 | .visible(bSetDumpText::get) 62 | .name("dump-text-engine") 63 | .build()); 64 | 65 | 66 | public Translation() { 67 | super(MeteorTranslation.CATEGORY, "meteor-trans", "An example module that highlights the center of the world."); 68 | } 69 | 70 | private boolean isTranslation = false; 71 | 72 | @Override 73 | public void onActivate() { 74 | if (bSetAutoTranslation.get() && !isTranslation) { 75 | isTranslation = true; 76 | tran(); 77 | } 78 | 79 | ChatUtils.warning("流星翻译插件是开源的项目且完全免费 作者不会以任何形式对此插件进行收费"); 80 | ChatUtils.warning("如果你购买了此插件 则说明你被骗了"); 81 | } 82 | 83 | 84 | @Override 85 | public WWidget getWidget(GuiTheme theme) { 86 | WVerticalList list = theme.verticalList(); 87 | 88 | WHorizontalList l1 = list.add(theme.horizontalList()).expandX().widget(); 89 | 90 | WButton start = l1.add(theme.button("Translate")).expandX().widget(); 91 | start.action = () -> { 92 | if (this.isActive()) { 93 | isTranslation = true; 94 | tran(); 95 | } else { 96 | ChatUtils.warning("你首先要开启此模块"); 97 | } 98 | }; 99 | 100 | if (!sgDev.sectionExpanded) 101 | return list; 102 | WHorizontalList l2 = list.add(theme.horizontalList()).expandX().widget(); 103 | WButton dump = l2.add(theme.button("Dump")).expandX().widget(); 104 | dump.action = () -> { 105 | JsonDump.getINSTANCE().write(EngineManager.getInstance().getEngine(strSetTransEngine.get()), EngineManager.getInstance().getEngine(strSetDumpTextEngine.get())); 106 | }; 107 | return list; 108 | } 109 | 110 | 111 | public void tran() { 112 | tran(EngineManager.getInstance().getEngine(strSetTransEngine.get())); 113 | } 114 | 115 | 116 | private void tran(AbstractTransEngine engine) { 117 | for (Module module : Modules.get().getAll()) { 118 | String addonName = TransUtil.getAddonName(module); 119 | if (!translationModules.get().contains(addonName)) continue; 120 | //插件过滤 121 | 122 | String tranName = engine.transModuleName(module); 123 | // 经过翻译的名称 124 | ((ModuleAccessor) module).setTitle(Utils.nameToTitle(tranName)); 125 | //把标题设为翻译之后的名称 126 | 127 | String tranDescry = engine.transModuleDescription(module); 128 | ((ModuleAccessor) module).setDescription(Utils.nameToTitle(tranDescry)); 129 | //翻译简介 130 | 131 | for (SettingGroup group : module.settings.groups) { 132 | for (Setting setting : ((SettingGroupAccessor) group).getSettings()) { 133 | 134 | String tranSettName = engine.transSettingName(module, group, setting); 135 | ((SettingAccessor) setting).setTitle(Utils.nameToTitle(tranSettName)); 136 | 137 | String tranSettDesc = engine.transSettingDes(module, group, setting); 138 | ((SettingAccessor) setting).setDescription(Utils.nameToTitle(tranSettDesc)); 139 | } 140 | } 141 | 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/settings/StringSelectSetting.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). 3 | * Copyright (c) Meteor Development. 4 | */ 5 | 6 | package com.nippaku_zanmu.trans_addon.settings; 7 | 8 | import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; 9 | import meteordevelopment.meteorclient.settings.IVisible; 10 | import meteordevelopment.meteorclient.settings.Setting; 11 | import net.minecraft.entity.EntityType; 12 | import net.minecraft.nbt.NbtCompound; 13 | import net.minecraft.nbt.NbtElement; 14 | import net.minecraft.nbt.NbtList; 15 | import net.minecraft.nbt.NbtString; 16 | 17 | import java.util.*; 18 | import java.util.function.Consumer; 19 | import java.util.function.Predicate; 20 | import java.util.stream.Collectors; 21 | 22 | public class StringSelectSetting extends Setting> { 23 | public final Predicate filter; 24 | private List suggestions; 25 | public Set validValues; 26 | private final static List groups = List.of("animal", "wateranimal", "monster", "ambient", "misc"); 27 | 28 | public StringSelectSetting(String name, String description, Set defaultValue, Consumer> onChanged, Consumer>> onModuleActivated, IVisible visible, Predicate filter, Set validValues) { 29 | super(name, description, defaultValue, onChanged, onModuleActivated, visible); 30 | this.validValues = validValues; 31 | this.filter = filter; 32 | } 33 | 34 | @Override 35 | public void resetImpl() { 36 | value = new ObjectOpenHashSet<>(defaultValue); 37 | } 38 | 39 | @Override 40 | protected Set parseImpl(String str) { 41 | return Arrays.stream(str.split(",")).collect(Collectors.toSet()); 42 | // String[] values = str.split(","); 43 | // Set> entities = new ObjectOpenHashSet<>(values.length); 44 | // 45 | // try { 46 | // for (String value : values) { 47 | // EntityType entity = parseId(Registries.ENTITY_TYPE, value); 48 | // if (entity != null) entities.add(entity); 49 | // else { 50 | // String lowerValue = value.trim().toLowerCase(); 51 | // if (!groups.contains(lowerValue)) continue; 52 | // 53 | // for (EntityType entityType : Registries.ENTITY_TYPE) { 54 | // if (filter != null && !filter.test(entityType)) continue; 55 | // 56 | // switch (lowerValue) { 57 | // case "animal" -> { 58 | // if (entityType.getSpawnGroup() == SpawnGroup.CREATURE) entities.add(entityType); 59 | // } 60 | // case "wateranimal" -> { 61 | // if (entityType.getSpawnGroup() == SpawnGroup.WATER_AMBIENT 62 | // || entityType.getSpawnGroup() == SpawnGroup.WATER_CREATURE 63 | // || entityType.getSpawnGroup() == SpawnGroup.UNDERGROUND_WATER_CREATURE 64 | // || entityType.getSpawnGroup() == SpawnGroup.AXOLOTLS) entities.add(entityType); 65 | // } 66 | // case "monster" -> { 67 | // if (entityType.getSpawnGroup() == SpawnGroup.MONSTER) entities.add(entityType); 68 | // } 69 | // case "ambient" -> { 70 | // if (entityType.getSpawnGroup() == SpawnGroup.AMBIENT) entities.add(entityType); 71 | // } 72 | // case "misc" -> { 73 | // if (entityType.getSpawnGroup() == SpawnGroup.MISC) entities.add(entityType); 74 | // } 75 | // } 76 | // } 77 | // } 78 | // } 79 | // } catch (Exception ignored) {} 80 | // 81 | // return entities; 82 | } 83 | 84 | @Override 85 | protected boolean isValueValid(Set value) { 86 | return true; 87 | } 88 | 89 | @Override 90 | public List getSuggestions() { 91 | if (suggestions==null){ 92 | suggestions = new ArrayList<>(groups); 93 | for (String str : validValues) { 94 | if (filter == null || filter.test(str)) 95 | suggestions.add(str); 96 | } 97 | } 98 | return suggestions; 99 | } 100 | 101 | @Override 102 | public NbtCompound save(NbtCompound tag) { 103 | NbtList valueTag = new NbtList(); 104 | for (String s : get()) { 105 | valueTag.add(NbtString.of(s)); 106 | } 107 | tag.put("value", valueTag); 108 | 109 | return tag; 110 | } 111 | 112 | @Override 113 | public Set load(NbtCompound tag) { 114 | get().clear(); 115 | 116 | NbtList valueTag = tag.getListOrEmpty("value"); 117 | for (NbtElement tagI : valueTag) { 118 | String s = tagI.asString().orElse(""); 119 | if ((filter == null || filter.test(s))&& validValues.contains(s))get().add(s); 120 | // EntityType type = Registries.ENTITY_TYPE.get(Identifier.of(tagI.asString())); 121 | // if (filter == null || filter.test(type)) get().add(type); 122 | } 123 | 124 | return get(); 125 | } 126 | 127 | public static class Builder extends SettingBuilder, StringSelectSetting> { 128 | private Predicate filter; 129 | private Set validValues = new LinkedHashSet<>(); 130 | 131 | public Builder() { 132 | super(new ObjectOpenHashSet<>(0)); 133 | } 134 | 135 | public Builder defaultValue(String... defaults) { 136 | return defaultValue(defaults != null ? new ObjectOpenHashSet<>(defaults) : new ObjectOpenHashSet<>(0)); 137 | } 138 | public Builder validValues(String... defaults) { 139 | validValues.addAll(List.of(defaults)); 140 | return this; 141 | //return defaultValue(defaults != null ? new ObjectOpenHashSet<>(defaults) : new ObjectOpenHashSet<>(0)); 142 | } 143 | public Builder validValues(Set validValues) { 144 | this.validValues.addAll(validValues); 145 | return this; 146 | //return defaultValue(defaults != null ? new ObjectOpenHashSet<>(defaults) : new ObjectOpenHashSet<>(0)); 147 | } 148 | 149 | public Builder filter(Predicate filter) { 150 | this.filter = filter; 151 | return this; 152 | } 153 | 154 | @Override 155 | public StringSelectSetting build() { 156 | return new StringSelectSetting(name, description, defaultValue, onChanged, onModuleActivated, visible, filter,validValues); 157 | } 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/font_fix/FontFix.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). 3 | * Copyright (c) Meteor Development. 4 | */ 5 | package com.nippaku_zanmu.trans_addon.font_fix; 6 | 7 | import com.mojang.blaze3d.textures.FilterMode; 8 | import com.mojang.blaze3d.textures.TextureFormat; 9 | import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; 10 | import meteordevelopment.meteorclient.renderer.MeshBuilder; 11 | import meteordevelopment.meteorclient.renderer.Texture; 12 | import meteordevelopment.meteorclient.utils.render.color.Color; 13 | import org.lwjgl.BufferUtils; 14 | import org.lwjgl.stb.*; 15 | import org.lwjgl.system.MemoryStack; 16 | 17 | import java.nio.ByteBuffer; 18 | import java.nio.IntBuffer; 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | 23 | public class FontFix { 24 | public Texture texture; 25 | private final int height; 26 | private final float scale; 27 | private final float ascent; 28 | private final Int2ObjectOpenHashMap charMap = new Int2ObjectOpenHashMap<>(); 29 | private final static int size = 2048; 30 | 31 | private final ByteBuffer buffer; 32 | private final STBTTFontinfo fontInfo; 33 | private final ByteBuffer bitmap; 34 | private final STBTTPackContext packContext; 35 | private final Int2ObjectOpenHashMap packedChars = new Int2ObjectOpenHashMap<>(); 36 | 37 | private long loadTimer = 0; 38 | private int loadCount = 0; 39 | private final int loadSpeedLimit = 7; 40 | //The number of string that can be loaded per 100ms 41 | 42 | public FontFix(ByteBuffer buffer, int height) { 43 | 44 | 45 | this.buffer = buffer; 46 | this.height = height; 47 | 48 | // Initialize font 49 | fontInfo = STBTTFontinfo.create(); 50 | STBTruetype.stbtt_InitFont(fontInfo, buffer); 51 | 52 | // Allocate buffers 53 | bitmap = BufferUtils.createByteBuffer(size * size); 54 | 55 | // create and initialise packing context 56 | packContext = STBTTPackContext.create(); 57 | STBTruetype.stbtt_PackBegin(packContext, bitmap, size, size, 0, 1); 58 | 59 | // Create texture object and get font scale 60 | texture = new Texture(size, size, TextureFormat.RED8, FilterMode.LINEAR, FilterMode.LINEAR); 61 | texture.upload(bitmap); 62 | scale = STBTruetype.stbtt_ScaleForPixelHeight(fontInfo, height); 63 | 64 | // Get font vertical ascent 65 | try (MemoryStack stack = MemoryStack.stackPush()) { 66 | IntBuffer ascent = stack.mallocInt(1); 67 | STBTruetype.stbtt_GetFontVMetrics(fontInfo, ascent, null, null); 68 | this.ascent = ascent.get(0); 69 | } 70 | 71 | // Preload basic ASCII characters 72 | preloadAsciiCharacters(); 73 | } 74 | 75 | private void preloadAsciiCharacters() { 76 | STBTTPackedchar.Buffer cdata = STBTTPackedchar.create(128); // Basic Latin 77 | 78 | // create the pack range 79 | STBTTPackRange.Buffer packRange = STBTTPackRange.create(1); 80 | packRange.put(STBTTPackRange.create().set(height, 32, null, 128, cdata, (byte) 2, (byte) 2)); 81 | packRange.flip(); 82 | 83 | // pack font ranges 84 | STBTruetype.stbtt_PackFontRanges(packContext, buffer, 0, packRange); 85 | 86 | // Load character data into charMap 87 | for (int i = 0; i < cdata.capacity(); i++) { 88 | STBTTPackedchar packedChar = cdata.get(i); 89 | putCharData(i + 32, packedChar); 90 | } 91 | 92 | // Create texture 93 | createTexture(); 94 | } 95 | 96 | private void loadCharacter(List codePoints) { 97 | if (System.currentTimeMillis() - loadTimer > 100) { 98 | loadTimer = System.currentTimeMillis(); 99 | loadCount = 0; 100 | } 101 | if (loadCount >= loadSpeedLimit) return; 102 | //Limit the load speed to avoid blocking the rendering thread 103 | for (Integer codePoint : codePoints) { 104 | loadCharacter(codePoint); 105 | } 106 | // Re-create texture 107 | createTexture(); 108 | loadCount++; 109 | } 110 | 111 | private void loadCharacter(int codePoint) { 112 | if (charMap.containsKey(codePoint)) return; 113 | 114 | STBTTPackedchar.Buffer cdata = STBTTPackedchar.create(1); 115 | 116 | // create the pack range 117 | STBTTPackRange.Buffer packRange = STBTTPackRange.create(1); 118 | packRange.put(STBTTPackRange.create().set(height, codePoint, null, 1, cdata, (byte) 2, (byte) 2)); 119 | packRange.flip(); 120 | 121 | // pack font ranges 122 | STBTruetype.stbtt_PackFontRanges(packContext, buffer, 0, packRange); 123 | 124 | STBTTPackedchar packedChar = cdata.get(0); 125 | putCharData(codePoint, packedChar); 126 | packedChars.put(codePoint, packedChar); 127 | } 128 | 129 | private void putCharData(int codePoint, STBTTPackedchar packedChar) { 130 | float ipw = 1f / size; // pixel width and height 131 | float iph = 1f / size; 132 | charMap.put(codePoint, new CharData( 133 | packedChar.xoff(), 134 | packedChar.yoff(), 135 | packedChar.xoff2(), 136 | packedChar.yoff2(), 137 | packedChar.x0() * ipw, 138 | packedChar.y0() * iph, 139 | packedChar.x1() * ipw, 140 | packedChar.y1() * iph, 141 | packedChar.xadvance() 142 | )); 143 | } 144 | 145 | private void createTexture() { 146 | texture = new Texture(size, size, TextureFormat.RED8, FilterMode.LINEAR, FilterMode.LINEAR); 147 | texture.upload(bitmap); 148 | //((ByteTextureAccessor)texture).upload(size, size, bitmap, ByteTexture.Format.A, ByteTexture.Filter.Linear, ByteTexture.Filter.Linear); 149 | } 150 | 151 | public double getWidth(String string, int length) { 152 | double width = 0; 153 | if (tryLoadString(string)) { 154 | return width; 155 | } 156 | for (int i = 0; i < length; i++) { 157 | int cp = string.charAt(i); 158 | CharData c = charMap.get(cp); 159 | if (c == null) { 160 | continue; 161 | } 162 | width += c.xAdvance; 163 | } 164 | return width; 165 | } 166 | 167 | public int getHeight() { 168 | return height; 169 | } 170 | 171 | private boolean tryLoadString(String s) { 172 | boolean isLoading = false; 173 | List charPoints = null; 174 | for (int i = 0; i < s.length(); i++) { 175 | int cp = s.charAt(i); 176 | CharData c = charMap.get(cp); 177 | if (c == null) { 178 | if (charPoints == null) charPoints = new ArrayList<>(); 179 | charPoints.add(cp); 180 | isLoading = true; 181 | } 182 | } 183 | if (charPoints != null) { 184 | loadCharacter(charPoints); 185 | } 186 | return isLoading; 187 | } 188 | 189 | 190 | public double render(MeshBuilder mesh, String string, double x, double y, Color color, double scale) { 191 | if (tryLoadString(string)) return x; 192 | 193 | y += ascent * this.scale * scale; 194 | 195 | int length = string.length(); 196 | mesh.ensureCapacity(length * 4, length * 6); 197 | for (int i = 0; i < length; i++) { 198 | int cp = string.charAt(i); 199 | CharData c = charMap.get(cp); 200 | if (c == null) { 201 | continue; 202 | } 203 | mesh.quad( 204 | mesh.vec2(x + c.x0 * scale, y + c.y0 * scale).vec2(c.u0, c.v0).color(color).next(), 205 | mesh.vec2(x + c.x0 * scale, y + c.y1 * scale).vec2(c.u0, c.v1).color(color).next(), 206 | mesh.vec2(x + c.x1 * scale, y + c.y1 * scale).vec2(c.u1, c.v1).color(color).next(), 207 | mesh.vec2(x + c.x1 * scale, y + c.y0 * scale).vec2(c.u1, c.v0).color(color).next() 208 | ); 209 | 210 | x += c.xAdvance * scale; 211 | } 212 | return x; 213 | } 214 | 215 | private record CharData(float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, 216 | float xAdvance) { 217 | } 218 | } 219 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 147 | # shellcheck disable=SC3045 148 | MAX_FD=$( ulimit -H -n ) || 149 | warn "Could not query maximum file descriptor limit" 150 | esac 151 | case $MAX_FD in #( 152 | '' | soft) :;; #( 153 | *) 154 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 155 | # shellcheck disable=SC3045 156 | ulimit -n "$MAX_FD" || 157 | warn "Could not set maximum file descriptor limit to $MAX_FD" 158 | esac 159 | fi 160 | 161 | # Collect all arguments for the java command, stacking in reverse order: 162 | # * args from the command line 163 | # * the main class name 164 | # * -classpath 165 | # * -D...appname settings 166 | # * --module-path (only if needed) 167 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 168 | 169 | # For Cygwin or MSYS, switch paths to Windows format before running java 170 | if "$cygwin" || "$msys" ; then 171 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 172 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 173 | 174 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 175 | 176 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 177 | for arg do 178 | if 179 | case $arg in #( 180 | -*) false ;; # don't mess with options #( 181 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 182 | [ -e "$t" ] ;; #( 183 | *) false ;; 184 | esac 185 | then 186 | arg=$( cygpath --path --ignore --mixed "$arg" ) 187 | fi 188 | # Roll the args list around exactly as many times as the number of 189 | # args, so each arg winds up back in the position where it started, but 190 | # possibly modified. 191 | # 192 | # NB: a `for` loop captures its iteration list before it begins, so 193 | # changing the positional parameters here affects neither the number of 194 | # iterations, nor the values presented in `arg`. 195 | shift # remove old arg 196 | set -- "$@" "$arg" # push replacement arg 197 | done 198 | fi 199 | 200 | # Collect all arguments for the java command; 201 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 202 | # shell script including quotes and variable substitutions, so put them in 203 | # double quotes to make sure that they get re-expanded; and 204 | # * put everything else in single quotes, so that it's not re-expanded. 205 | 206 | set -- \ 207 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 208 | -classpath "$CLASSPATH" \ 209 | org.gradle.wrapper.GradleWrapperMain \ 210 | "$@" 211 | 212 | # Stop when "xargs" is not available. 213 | if ! command -v xargs >/dev/null 2>&1 214 | then 215 | die "xargs is not available" 216 | fi 217 | 218 | # Use "xargs" to parse quoted args. 219 | # 220 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 221 | # 222 | # In Bash we could simply go: 223 | # 224 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 225 | # set -- "${ARGS[@]}" "$@" 226 | # 227 | # but POSIX shell has neither arrays nor command substitution, so instead we 228 | # post-process each arg (as a line of input to sed) to backslash-escape any 229 | # character that might be a shell metacharacter, then use eval to reverse 230 | # that process (while maintaining the separation between arguments), and wrap 231 | # the whole thing up as a single "set" statement. 232 | # 233 | # This will of course break if any of these variables contains a newline or 234 | # an unmatched quote. 235 | # 236 | 237 | eval "set -- $( 238 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 239 | xargs -n1 | 240 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 241 | tr '\n' ' ' 242 | )" '"$@"' 243 | 244 | exec "$JAVACMD" "$@" 245 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/settings/StringSelectScreen.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). 3 | * Copyright (c) Meteor Development. 4 | */ 5 | 6 | package com.nippaku_zanmu.trans_addon.settings; 7 | 8 | import meteordevelopment.meteorclient.gui.GuiTheme; 9 | import meteordevelopment.meteorclient.gui.WindowScreen; 10 | import meteordevelopment.meteorclient.gui.utils.Cell; 11 | import meteordevelopment.meteorclient.gui.widgets.WWidget; 12 | import meteordevelopment.meteorclient.gui.widgets.containers.WSection; 13 | import meteordevelopment.meteorclient.gui.widgets.containers.WTable; 14 | import meteordevelopment.meteorclient.gui.widgets.containers.WVerticalList; 15 | import meteordevelopment.meteorclient.gui.widgets.input.WTextBox; 16 | import meteordevelopment.meteorclient.gui.widgets.pressable.WCheckbox; 17 | import meteordevelopment.meteorclient.settings.EntityTypeListSetting; 18 | import meteordevelopment.meteorclient.utils.Utils; 19 | import meteordevelopment.meteorclient.utils.misc.Names; 20 | import net.minecraft.entity.EntityType; 21 | import net.minecraft.registry.Registries; 22 | import net.minecraft.util.Pair; 23 | 24 | import java.util.ArrayList; 25 | import java.util.Comparator; 26 | import java.util.List; 27 | import java.util.function.Consumer; 28 | 29 | public class StringSelectScreen extends WindowScreen { 30 | private final StringSelectSetting setting; 31 | 32 | private WVerticalList list; 33 | private final WTextBox filter; 34 | 35 | private String filterText = ""; 36 | // 37 | // private WSection animals; 38 | // private WTable animalsT; 39 | 40 | 41 | private WSection strings; 42 | private WTable stringsT; 43 | 44 | public StringSelectScreen(GuiTheme theme, StringSelectSetting setting) { 45 | super(theme, setting.title); 46 | this.setting = setting; 47 | 48 | // Filter 49 | filter = super.add(theme.textBox("")).minWidth(400).expandX().widget(); 50 | filter.setFocused(true); 51 | filter.action = () -> { 52 | filterText = filter.get().trim(); 53 | 54 | list.clear(); 55 | initWidgets(); 56 | }; 57 | 58 | list = super.add(theme.verticalList()).expandX().widget(); 59 | 60 | } 61 | 62 | @Override 63 | public Cell add(W widget) { 64 | return list.add(widget); 65 | } 66 | 67 | int strsSize; 68 | 69 | @Override 70 | public void initWidgets() { 71 | // strsSize = setting.get().size(); 72 | strsSize = 0; 73 | for (String s:setting.get()){ 74 | if (setting.filter == null || setting.filter.test(s)) strsSize++; 75 | } 76 | 77 | // hasAnimal = hasWaterAnimal = hasMonster = hasAmbient = hasMisc = 0; 78 | // 79 | // for (EntityType entityType : setting.get()) { 80 | // if (setting.filter == null || setting.filter.test(entityType)) { 81 | // switch (entityType.getSpawnGroup()) { 82 | // case CREATURE -> hasAnimal++; 83 | // case WATER_AMBIENT, WATER_CREATURE, UNDERGROUND_WATER_CREATURE, AXOLOTLS -> hasWaterAnimal++; 84 | // case MONSTER -> hasMonster++; 85 | // case AMBIENT -> hasAmbient++; 86 | // case MISC -> hasMisc++; 87 | // } 88 | // } 89 | // } 90 | // 91 | // boolean first = animals == null; 92 | List stringE = new ArrayList<>(); 93 | WCheckbox stringC = theme.checkbox(strsSize > 0); 94 | 95 | strings = theme.section("Strings", strings != null && strings.isExpanded(), stringC); 96 | stringC.action = () -> tableChecked(stringE, stringC.checked); 97 | 98 | Cell stringsCell = add(strings).expandX(); 99 | stringsT = strings.add(theme.table()).expandX().widget(); 100 | 101 | // // Animals 102 | // List> animalsE = new ArrayList<>(); 103 | // WCheckbox animalsC = theme.checkbox(hasAnimal > 0); 104 | // 105 | // animals = theme.section("Strings", animals != null && animals.isExpanded(), animalsC); 106 | // animalsC.action = () -> tableChecked(animalsE, animalsC.checked); 107 | // 108 | // Cell animalsCell = add(animals).expandX(); 109 | // animalsT = animals.add(theme.table()).expandX().widget(); 110 | 111 | Consumer stringForeach = str -> { 112 | stringE.add(str); 113 | addString(stringsT,stringC,str); 114 | }; 115 | 116 | strings.setExpanded(true); 117 | 118 | // Consumer> entityTypeForEach = entityType -> { 119 | // if (setting.filter == null || setting.filter.test(entityType)) { 120 | // switch (entityType.getSpawnGroup()) { 121 | // case CREATURE -> { 122 | // animalsE.add(entityType); 123 | // addEntityType(animalsT, animalsC, entityType); 124 | // } 125 | // case WATER_AMBIENT, WATER_CREATURE, UNDERGROUND_WATER_CREATURE, AXOLOTLS -> { 126 | // waterAnimalsE.add(entityType); 127 | // addEntityType(waterAnimalsT, waterAnimalsC, entityType); 128 | // } 129 | // case MONSTER -> { 130 | // monstersE.add(entityType); 131 | // addEntityType(monstersT, monstersC, entityType); 132 | // } 133 | // case AMBIENT -> { 134 | // ambientE.add(entityType); 135 | // addEntityType(ambientT, ambientC, entityType); 136 | // } 137 | // case MISC -> { 138 | // miscE.add(entityType); 139 | // addEntityType(miscT, miscC, entityType); 140 | // } 141 | // } 142 | // } 143 | // }; 144 | 145 | // Sort all entities 146 | if (filterText.isEmpty()) { 147 | setting.validValues.forEach(stringForeach); 148 | } else { 149 | List> entities = new ArrayList<>(); 150 | setting.validValues.forEach(str -> { 151 | int words = Utils.searchInWords(str, filterText); 152 | int diff = Utils.searchLevenshteinDefault(str, filterText, false); 153 | 154 | if (words > 0 || diff < str.length() / 2) entities.add(new Pair<>(str, -diff)); 155 | }); 156 | entities.sort(Comparator.comparingInt(value -> -value.getRight())); 157 | for (Pair pair : entities) stringForeach.accept(pair.getLeft()); 158 | } 159 | 160 | if (stringsT.cells.isEmpty()) list.cells.remove(stringsCell); 161 | // if (waterAnimalsT.cells.isEmpty()) list.cells.remove(waterAnimalsCell); 162 | // if (monstersT.cells.isEmpty()) list.cells.remove(monstersCell); 163 | // if (ambientT.cells.isEmpty()) list.cells.remove(ambientCell); 164 | // if (miscT.cells.isEmpty()) list.cells.remove(miscCell); 165 | 166 | 167 | // if (first) { 168 | // int totalCount = (hasWaterAnimal + waterAnimals.cells.size() + monsters.cells.size() + ambient.cells.size() + misc.cells.size()) / 2; 169 | // 170 | // if (totalCount <= 20) { 171 | // if (!animalsT.cells.isEmpty()) animals.setExpanded(true); 172 | // if (!waterAnimalsT.cells.isEmpty()) waterAnimals.setExpanded(true); 173 | // if (!monstersT.cells.isEmpty()) monsters.setExpanded(true); 174 | // if (!ambientT.cells.isEmpty()) ambient.setExpanded(true); 175 | // if (!miscT.cells.isEmpty()) misc.setExpanded(true); 176 | // } else { 177 | // if (!animalsT.cells.isEmpty()) animals.setExpanded(false); 178 | // if (!waterAnimalsT.cells.isEmpty()) waterAnimals.setExpanded(false); 179 | // if (!monstersT.cells.isEmpty()) monsters.setExpanded(false); 180 | // if (!ambientT.cells.isEmpty()) ambient.setExpanded(false); 181 | // if (!miscT.cells.isEmpty()) misc.setExpanded(false); 182 | // } 183 | // } 184 | } 185 | 186 | private void tableChecked(List strings, boolean checked) { 187 | boolean changed = false; 188 | 189 | for (String string : strings) { 190 | if (checked) { 191 | setting.get().add(string); 192 | changed = true; 193 | } else { 194 | if (setting.get().remove(string)) { 195 | changed = true; 196 | } 197 | } 198 | } 199 | 200 | if (changed) { 201 | list.clear(); 202 | initWidgets(); 203 | setting.onChanged(); 204 | } 205 | } 206 | 207 | // private void tableChecked(List> entityTypes, boolean checked) { 208 | // boolean changed = false; 209 | // 210 | // for (EntityType entityType : entityTypes) { 211 | // if (checked) { 212 | // setting.get().add(entityType); 213 | // changed = true; 214 | // } else { 215 | // if (setting.get().remove(entityType)) { 216 | // changed = true; 217 | // } 218 | // } 219 | // } 220 | // 221 | // if (changed) { 222 | // list.clear(); 223 | // initWidgets(); 224 | // setting.onChanged(); 225 | // } 226 | // } 227 | private void addString(WTable table, WCheckbox tableCheckbox, String str) { 228 | table.add(theme.label(str)); 229 | WCheckbox a = table.add(theme.checkbox(setting.get().contains(str))).expandCellX().right().widget(); 230 | a.action=()->{ 231 | if (a.checked) { 232 | setting.get().add(str); 233 | if (strsSize == 0) tableCheckbox.checked = true; 234 | strsSize++; 235 | }else { 236 | if (setting.get().remove(str)) { 237 | strsSize--; 238 | if (strsSize == 0) tableCheckbox.checked = false; 239 | } 240 | } 241 | }; 242 | table.row(); 243 | } 244 | 245 | // private void addEntityType(WTable table, WCheckbox tableCheckbox, EntityType entityType) { 246 | // table.add(theme.label(Names.get(entityType))); 247 | // 248 | // 249 | // WCheckbox a = table.add(theme.checkbox(setting.get().contains(entityType))).expandCellX().right().widget(); 250 | // a.action = () -> { 251 | // if (a.checked) { 252 | // setting.get().add(entityType); 253 | // switch (entityType.getSpawnGroup()) { 254 | // case CREATURE -> { 255 | // if (hasAnimal == 0) tableCheckbox.checked = true; 256 | // hasAnimal++; 257 | // } 258 | // case WATER_AMBIENT, WATER_CREATURE, UNDERGROUND_WATER_CREATURE, AXOLOTLS -> { 259 | // if (hasWaterAnimal == 0) tableCheckbox.checked = true; 260 | // hasWaterAnimal++; 261 | // } 262 | // case MONSTER -> { 263 | // if (hasMonster == 0) tableCheckbox.checked = true; 264 | // hasMonster++; 265 | // } 266 | // case AMBIENT -> { 267 | // if (hasAmbient == 0) tableCheckbox.checked = true; 268 | // hasAmbient++; 269 | // } 270 | // case MISC -> { 271 | // if (hasMisc == 0) tableCheckbox.checked = true; 272 | // hasMisc++; 273 | // } 274 | // } 275 | // } else { 276 | // if (setting.get().remove(entityType)) { 277 | // switch (entityType.getSpawnGroup()) { 278 | // case CREATURE -> { 279 | // hasAnimal--; 280 | // if (hasAnimal == 0) tableCheckbox.checked = false; 281 | // } 282 | // case WATER_AMBIENT, WATER_CREATURE, UNDERGROUND_WATER_CREATURE, AXOLOTLS -> { 283 | // hasWaterAnimal--; 284 | // if (hasWaterAnimal == 0) tableCheckbox.checked = false; 285 | // } 286 | // case MONSTER -> { 287 | // hasMonster--; 288 | // if (hasMonster == 0) tableCheckbox.checked = false; 289 | // } 290 | // case AMBIENT -> { 291 | // hasAmbient--; 292 | // if (hasAmbient == 0) tableCheckbox.checked = false; 293 | // } 294 | // case MISC -> { 295 | // hasMisc--; 296 | // if (hasMisc == 0) tableCheckbox.checked = false; 297 | // } 298 | // } 299 | // } 300 | // } 301 | // 302 | // setting.onChanged(); 303 | // }; 304 | // 305 | // table.row(); 306 | // } 307 | } 308 | -------------------------------------------------------------------------------- /src/main/java/com/nippaku_zanmu/trans_addon/mixin/HudRenderer/HudRendererMixin.java: -------------------------------------------------------------------------------- 1 | //package com.nippaku_zanmu.trans_addon.mixin.HudRenderer; 2 | // 3 | //import com.google.common.cache.CacheBuilder; 4 | //import com.google.common.cache.CacheLoader; 5 | //import com.google.common.cache.LoadingCache; 6 | //import com.nippaku_zanmu.trans_addon.font_fix.FontFix; 7 | //import it.unimi.dsi.fastutil.ints.Int2ObjectMap; 8 | //import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; 9 | //import meteordevelopment.meteorclient.events.meteor.CustomFontChangedEvent; 10 | //import meteordevelopment.meteorclient.renderer.*; 11 | //import meteordevelopment.meteorclient.renderer.text.CustomTextRenderer; 12 | //import meteordevelopment.meteorclient.renderer.text.VanillaTextRenderer; 13 | //import meteordevelopment.meteorclient.systems.hud.Hud; 14 | //import meteordevelopment.meteorclient.systems.hud.HudRenderer; 15 | //import meteordevelopment.meteorclient.utils.Utils; 16 | //import meteordevelopment.meteorclient.utils.render.RenderUtils; 17 | //import meteordevelopment.meteorclient.utils.render.color.Color; 18 | //import meteordevelopment.orbit.EventHandler; 19 | //import net.minecraft.client.gui.DrawContext; 20 | //import net.minecraft.item.ItemStack; 21 | //import net.minecraft.util.Identifier; 22 | //import org.lwjgl.BufferUtils; 23 | //import org.spongepowered.asm.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.CallbackInfo; 27 | // 28 | //import java.nio.ByteBuffer; 29 | //import java.time.Duration; 30 | //import java.util.ArrayList; 31 | //import java.util.Iterator; 32 | //import java.util.List; 33 | // 34 | //import static meteordevelopment.meteorclient.MeteorClient.mc; 35 | // 36 | //@Mixin(value = HudRenderer.class,remap = false) 37 | //public class HudRendererMixin { 38 | // @Shadow 39 | // @Final 40 | // private static double SCALE_TO_HEIGHT = 1.0 / 18.0; 41 | // @Shadow 42 | // @Final 43 | // private final Hud hud = Hud.get(); 44 | // @Shadow 45 | // @Final 46 | // private final List postTasks = new ArrayList<>(); 47 | // 48 | // @Unique 49 | // private final Int2ObjectMap fontsInUse_f = new Int2ObjectOpenHashMap<>(); 50 | // 51 | // @Unique 52 | // private final LoadingCache fontCache_f = CacheBuilder.newBuilder() 53 | // .maximumSize(4) 54 | // .expireAfterAccess(Duration.ofMinutes(10)) 55 | // .removalListener(notification -> { 56 | // if (notification.wasEvicted()) 57 | // ((FontHolder) notification.getValue()).destroy(); 58 | // }) 59 | // .build(CacheLoader.from(HudRendererMixin::loadFont_f)); 60 | // @Shadow 61 | // public double delta; 62 | // 63 | // @Shadow 64 | // public DrawContext drawContext; 65 | // 66 | // /** 67 | // * @author Nippaku_Zanmu 68 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 69 | // */ 70 | // @Overwrite 71 | // public void begin(DrawContext drawContext) { 72 | // Renderer2D.COLOR.begin(); 73 | // 74 | // this.drawContext = drawContext; 75 | // this.delta = Utils.frameTime; 76 | // 77 | // if (!hud.hasCustomFont()) { 78 | // VanillaTextRenderer.INSTANCE.scaleIndividually = true; 79 | // VanillaTextRenderer.INSTANCE.begin(); 80 | // } 81 | // } 82 | // 83 | // /** 84 | // * @author Nippaku_Zanmu 85 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 86 | // */ 87 | // @Overwrite 88 | // public void end() { 89 | // Renderer2D.COLOR.render(); 90 | // 91 | // if (hud.hasCustomFont()) { 92 | // // Render fonts that were visited this frame and move to cache which weren't visited 93 | // for (Iterator it = fontsInUse_f.values().iterator(); it.hasNext(); ) { 94 | // FontHolder fontHolder = it.next(); 95 | // 96 | // if (fontHolder.visited) { 97 | // MeshRenderer.begin() 98 | // .attachments(mc.getFramebuffer()) 99 | // .pipeline(MeteorRenderPipelines.UI_TEXT) 100 | // .mesh(fontHolder.getMesh()) 101 | // .setupCallback(pass -> pass.bindSampler("u_Texture", fontHolder.font.texture.getGlTexture())) 102 | // .end(); 103 | // } 104 | // else { 105 | // it.remove(); 106 | // fontCache_f.put(fontHolder.font.getHeight(), fontHolder); 107 | // } 108 | // 109 | // fontHolder.visited = false; 110 | // } 111 | // } 112 | // else { 113 | // VanillaTextRenderer.INSTANCE.end(); 114 | // VanillaTextRenderer.INSTANCE.scaleIndividually = false; 115 | // } 116 | // 117 | // for (Runnable task : postTasks) task.run(); 118 | // postTasks.clear(); 119 | // 120 | // this.drawContext = null; 121 | // } 122 | // 123 | // /** 124 | // * @author Nippaku_Zanmu 125 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 126 | // */ 127 | // @Overwrite 128 | // public void line(double x1, double y1, double x2, double y2, Color color) { 129 | // Renderer2D.COLOR.line(x1, y1, x2, y2, color); 130 | // } 131 | // 132 | // /** 133 | // * @author Nippaku_Zanmu 134 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 135 | // */ 136 | // @Overwrite 137 | // public void quad(double x, double y, double width, double height, Color color) { 138 | // Renderer2D.COLOR.quad(x, y, width, height, color); 139 | // } 140 | // 141 | // /** 142 | // * @author Nippaku_Zanmu 143 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 144 | // */ 145 | // @Overwrite 146 | // public void quad(double x, double y, double width, double height, Color cTopLeft, Color cTopRight, Color cBottomRight, Color cBottomLeft) { 147 | // Renderer2D.COLOR.quad(x, y, width, height, cTopLeft, cTopRight, cBottomRight, cBottomLeft); 148 | // } 149 | // 150 | // /** 151 | // * @author Nippaku_Zanmu 152 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 153 | // */ 154 | // @Overwrite 155 | // public void triangle(double x1, double y1, double x2, double y2, double x3, double y3, Color color) { 156 | // Renderer2D.COLOR.triangle(x1, y1, x2, y2, x3, y3, color); 157 | // } 158 | // 159 | // /** 160 | // * @author Nippaku_Zanmu 161 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 162 | // */ 163 | // @Overwrite 164 | // public void texture(Identifier id, double x, double y, double width, double height, Color color) { 165 | // Renderer2D.TEXTURE.begin(); 166 | // Renderer2D.TEXTURE.texQuad(x, y, width, height, color); 167 | // Renderer2D.TEXTURE.render(mc.getTextureManager().getTexture(id).getGlTexture()); 168 | // } 169 | // 170 | // /** 171 | // * @author Nippaku_Zanmu 172 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 173 | // */ 174 | // @Overwrite 175 | // public double text(String text, double x, double y, Color color, boolean shadow, double scale) { 176 | // if (scale == -1) scale = hud.getTextScale(); 177 | // 178 | // if (!hud.hasCustomFont()) { 179 | // VanillaTextRenderer.INSTANCE.scale = scale * 2; 180 | // return VanillaTextRenderer.INSTANCE.render(text, x, y, color, shadow); 181 | // } 182 | // 183 | // FontHolder fontHolder = getFontHolder_f(scale, true); 184 | // 185 | // FontFix font = fontHolder.font; 186 | // MeshBuilder mesh = fontHolder.getMesh(); 187 | // 188 | // double width; 189 | // 190 | // if (shadow) { 191 | // int preShadowA = CustomTextRenderer.SHADOW_COLOR.a; 192 | // CustomTextRenderer.SHADOW_COLOR.a = (int) (color.a / 255.0 * preShadowA); 193 | // 194 | // width = font.render(mesh, text, x + 1, y + 1, CustomTextRenderer.SHADOW_COLOR, scale); 195 | // font.render(mesh, text, x, y, color, scale); 196 | // 197 | // CustomTextRenderer.SHADOW_COLOR.a = preShadowA; 198 | // } 199 | // else { 200 | // width = font.render(mesh, text, x, y, color, scale); 201 | // } 202 | // 203 | // return width; 204 | // } 205 | // /** 206 | // * @author Nippaku_Zanmu 207 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 208 | // */ 209 | // @Overwrite 210 | // public double text(String text, double x, double y, Color color, boolean shadow) { 211 | // return text(text, x, y, color, shadow, -1); 212 | // } 213 | // /** 214 | // * @author Nippaku_Zanmu 215 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 216 | // */ 217 | // @Overwrite 218 | // public double textWidth(String text, boolean shadow, double scale) { 219 | // if (text.isEmpty()) return 0; 220 | // 221 | // if (hud.hasCustomFont()) { 222 | // double width = getFont_f(scale).getWidth(text, text.length()); 223 | // return (width + (shadow ? 1 : 0)) * (scale == -1 ? hud.getTextScale() : scale) + (shadow ? 1 : 0); 224 | // } 225 | // 226 | // VanillaTextRenderer.INSTANCE.scale = (scale == -1 ? hud.getTextScale() : scale) * 2; 227 | // return VanillaTextRenderer.INSTANCE.getWidth(text, shadow); 228 | // } 229 | // /** 230 | // * @author Nippaku_Zanmu 231 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 232 | // */ 233 | // @Overwrite 234 | // public double textWidth(String text, boolean shadow) { 235 | // return textWidth(text, shadow, -1); 236 | // } 237 | // /** 238 | // * @author Nippaku_Zanmu 239 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 240 | // */ 241 | // @Overwrite 242 | // public double textWidth(String text, double scale) { 243 | // return textWidth(text, false, scale); 244 | // } 245 | // /** 246 | // * @author Nippaku_Zanmu 247 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 248 | // */ 249 | // @Overwrite 250 | // public double textWidth(String text) { 251 | // return textWidth(text, false, -1); 252 | // } 253 | // 254 | // /** 255 | // * @author Nippaku_Zanmu 256 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 257 | // */ 258 | // @Overwrite 259 | // public double textHeight(boolean shadow, double scale) { 260 | // if (hud.hasCustomFont()) { 261 | // double height = getFont_f(scale).getHeight() + 1; 262 | // return (height + (shadow ? 1 : 0)) * (scale == -1 ? hud.getTextScale() : scale); 263 | // } 264 | // 265 | // VanillaTextRenderer.INSTANCE.scale = (scale == -1 ? hud.getTextScale() : scale) * 2; 266 | // return VanillaTextRenderer.INSTANCE.getHeight(shadow); 267 | // } 268 | // /** 269 | // * @author Nippaku_Zanmu 270 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 271 | // */ 272 | // @Overwrite 273 | // public double textHeight(boolean shadow) { 274 | // return textHeight(shadow, -1); 275 | // } 276 | // /** 277 | // * @author Nippaku_Zanmu 278 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 279 | // */ 280 | // @Overwrite 281 | // public double textHeight() { 282 | // return textHeight(false, -1); 283 | // } 284 | // 285 | // /** 286 | // * @author Nippaku_Zanmu 287 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 288 | // */ 289 | // @Overwrite 290 | // public void post(Runnable task) { 291 | // postTasks.add(task); 292 | // } 293 | // 294 | // /** 295 | // * @author Nippaku_Zanmu 296 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 297 | // */ 298 | // @Overwrite 299 | // public void item(ItemStack itemStack, int x, int y, float scale, boolean overlay, String countOverlay) { 300 | // RenderUtils.drawItem(drawContext, itemStack, x, y, scale, overlay, countOverlay); 301 | // } 302 | // 303 | // /** 304 | // * @author Nippaku_Zanmu 305 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 306 | // */ 307 | // @Overwrite 308 | // public void item(ItemStack itemStack, int x, int y, float scale, boolean overlay) { 309 | // RenderUtils.drawItem(drawContext, itemStack, x, y, scale, overlay); 310 | // } 311 | // 312 | // @Unique 313 | // private FontHolder getFontHolder_f(double scale, boolean render) { 314 | // // Calculate font height 315 | // if (scale == -1) scale = hud.getTextScale(); 316 | // int height = (int) Math.round(scale / SCALE_TO_HEIGHT); 317 | // 318 | // // Check fonts in use 319 | // FontHolder fontHolder = fontsInUse_f.get(height); 320 | // if (fontHolder != null) { 321 | // if (render) fontHolder.visited = true; 322 | // return fontHolder; 323 | // } 324 | // 325 | // // Create font if not in cache otherwise remove from cache and add to fonts in use 326 | // if (render) { 327 | // fontHolder = fontCache_f.getIfPresent(height); 328 | // if (fontHolder == null) fontHolder = loadFont_f(height); 329 | // else fontCache_f.invalidate(height); 330 | // 331 | // fontsInUse_f.put(height, fontHolder); 332 | // fontHolder.visited = true; 333 | // 334 | // return fontHolder; 335 | // } 336 | // 337 | // // Otherwise get from cache 338 | // return fontCache_f.getUnchecked(height); 339 | // } 340 | // 341 | // @Unique 342 | // private FontFix getFont_f(double scale) { 343 | // return getFontHolder_f(scale, false).font; 344 | // } 345 | // /** 346 | // * @author Nippaku_Zanmu 347 | // * @reason 我只能用这种方法修复他 之前尝试过Mixin Font类 但是字体会乱码 348 | // */ 349 | //// @Overwrite 350 | //// @EventHandler 351 | //// private void onCustomFontChanged(CustomFontChangedEvent event) { 352 | //// // Need to destroy both fonts in use and in cache because they were not evicted from the cache automatically 353 | //// for (FontHolder fontHolder : fontsInUse_f.values()) fontHolder.destroy(); 354 | //// for (FontHolder fontHolder : fontCache_f.asMap().values()) fontHolder.destroy(); 355 | //// 356 | //// // Clear collections 357 | //// fontsInUse_f.clear(); 358 | //// fontCache_f.invalidateAll(); 359 | //// } 360 | // @Inject(method = "onCustomFontChanged",at = @At("HEAD")) 361 | // private void onCustomFontChanged(CustomFontChangedEvent event, CallbackInfo ci){ 362 | // // Need to destroy both fonts in use and in cache because they were not evicted from the cache automatically 363 | // for (FontHolder fontHolder : fontsInUse_f.values()) fontHolder.destroy(); 364 | // for (FontHolder fontHolder : fontCache_f.asMap().values()) fontHolder.destroy(); 365 | // 366 | // // Clear collections 367 | // fontsInUse_f.clear(); 368 | // fontCache_f.invalidateAll(); 369 | // } 370 | // 371 | // @Unique 372 | // private static FontHolder loadFont_f(int height) { 373 | // byte[] data = Utils.readBytes(Fonts.RENDERER.fontFace.toStream()); 374 | // ByteBuffer buffer = BufferUtils.createByteBuffer(data.length).put(data).flip(); 375 | // 376 | // return new FontHolder(new FontFix(buffer, height)); 377 | // } 378 | // 379 | // 380 | //} 381 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------