diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..550b373 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +# gradle + +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ +*.iml +*.ipr +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# fabric + +run/ diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..7aec757 --- /dev/null +++ b/build.gradle @@ -0,0 +1,131 @@ +buildscript { + + repositories { + jcenter() + mavenLocal() + mavenCentral() + + maven { url 'https://files.minecraftforge.net/maven' } + maven { url 'https://plugins.gradle.org/m2' } + maven { url 'https://repo.spongepowered.org/maven' } + } + + dependencies { + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '2.3-SNAPSHOT' + classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.6-SNAPSHOT' + classpath group: 'com.github.jengelman.gradle.plugins', name: 'shadow', version: '4.0.4' + } +} + +apply plugin: "net.minecraftforge.gradle.forge" +apply plugin: "org.spongepowered.mixin" +apply plugin: "com.github.johnrengelman.shadow" +apply plugin: "java" + +repositories { + + mavenLocal() + mavenCentral() + jcenter() + + maven { + name = 'spongepowered-repo' + url = 'http://repo.spongepowered.org/maven/' + } +} + +version = "b1" +group = "com.github.creeper123123321" +archivesBaseName = "ViaForge" + +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 +compileJava.options.encoding = 'windows-1252' + +minecraft { + version = "1.12.2-14.23.5.2847" + runDir = 'run' + mappings = "stable_39" + makeObfSourceJar = true +} + +sourceSets { + main.java.srcDirs += 'src/main/java' + main.java.srcDirs += '../shared/main/java' + main.resources.srcDirs += '../shared/main/resources' +} + + +repositories { + mavenLocal() + mavenCentral() + jcenter() + + maven { url 'https://jitpack.io' } + maven { url 'https://repo.spongepowered.org/maven/' } +} + +dependencies { + compile("org.spongepowered:mixin:0.7.10-SNAPSHOT") { + exclude module: "launchwrapper" + } +} + +processResources { + inputs.property "version", project.version + inputs.property "mcversion", project.minecraft.version + + from(sourceSets.main.resources.srcDirs) { + include 'mcmod.info' + + expand 'version':project.version, 'mcversion':project.minecraft.version + } + + from(sourceSets.main.resources.srcDirs) { + exclude 'mcmod.info' + } + + rename '(.+_at.cfg)', 'META-INF/$1' +} + +mixin { + add sourceSets.main, "mixins.viaforge.refmap.json" +} + +jar { + manifest.attributes( + "MixinConfigs": "mixins.viaforge.json", + "tweakClass": "org.spongepowered.asm.launch.MixinTweaker", + "TweakOrder": 0, + "FMLCorePluginContainsFMLMod": "com.github.creeper123123321.viafabric.injection.MixinLoader" + ) +} + +apply plugin: "idea" + +idea { + module { + inheritOutputDirs = true + } +} + +shadowJar { + dependencies { + include(dependency('org.spongepowered:mixin')) + } + + exclude 'dummyThing' + exclude 'LICENSE.txt' + + classifier = "" +} + +reobf { shadowJar { mappingType = "SEARGE" } } +tasks.reobfShadowJar.mustRunAfter shadowJar + +configurations { + external + compile.extendsFrom external +} + +build.dependsOn shadowJar \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..30d399d Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..b8b110b --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Sep 14 12:28:28 PDT 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https://services.gradle.org/distributions/gradle-4.2.1-bin.zip diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..e69de29 diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/libs/SnakeYaml-1.27.jar b/libs/SnakeYaml-1.27.jar new file mode 100644 index 0000000..79bd430 Binary files /dev/null and b/libs/SnakeYaml-1.27.jar differ diff --git a/libs/ViaBackwards-3.3.0-21w06a.jar b/libs/ViaBackwards-3.3.0-21w06a.jar new file mode 100644 index 0000000..2f25002 Binary files /dev/null and b/libs/ViaBackwards-3.3.0-21w06a.jar differ diff --git a/libs/ViaRewind-1.5.3(4).jar b/libs/ViaRewind-1.5.3(4).jar new file mode 100644 index 0000000..4aba028 Binary files /dev/null and b/libs/ViaRewind-1.5.3(4).jar differ diff --git a/libs/ViaVersion-3.3.0-21w06a.jar b/libs/ViaVersion-3.3.0-21w06a.jar new file mode 100644 index 0000000..f3a6411 Binary files /dev/null and b/libs/ViaVersion-3.3.0-21w06a.jar differ diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..656f300 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,18 @@ +/* + * This settings file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * In a single project build this file can be empty or even removed. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user guide at https://docs.gradle.org/4.2.1/userguide/multi_project_builds.html + */ + +/* +// To declare projects as part of a multi-project build use the 'include' method +include 'shared' +include 'api' +include 'services:webservice' +*/ + +rootProject.name = 'ViaForge' diff --git a/src/main/java/com/github/creeper123123321/viafabric/ViaFabric.java b/src/main/java/com/github/creeper123123321/viafabric/ViaFabric.java new file mode 100644 index 0000000..3d61614 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/ViaFabric.java @@ -0,0 +1,85 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric; + +import com.github.creeper123123321.viafabric.platform.VRInjector; +import com.github.creeper123123321.viafabric.platform.VRLoader; +import com.github.creeper123123321.viafabric.platform.VRPlatform; +import com.github.creeper123123321.viafabric.util.JLoggerToLog4j; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import de.flori2007.viaforge.platform.ViaBackwardsPlatformImplementation; +import de.flori2007.viaforge.platform.ViaRewindPlatformImplementation; +import io.netty.channel.EventLoop; +import io.netty.channel.local.LocalEventLoopGroup; +import net.minecraftforge.fml.common.Mod; +import org.apache.logging.log4j.LogManager; +import us.myles.ViaVersion.ViaManager; +import us.myles.ViaVersion.api.Via; +import us.myles.ViaVersion.api.data.MappingDataLoader; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; +import java.util.logging.Logger; + +@Mod(modid = "viaforge", useMetadata = true) +public class ViaFabric { + + public static int clientSideVersion = 47; + + public static final Logger JLOGGER = new JLoggerToLog4j(LogManager.getLogger("ViaFabric")); + public static final ExecutorService ASYNC_EXECUTOR; + public static final EventLoop EVENT_LOOP; + public static CompletableFuture INIT_FUTURE = new CompletableFuture<>(); + + static { + ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("ViaFabric-%d").build(); + ASYNC_EXECUTOR = Executors.newFixedThreadPool(8, factory); + EVENT_LOOP = new LocalEventLoopGroup(1, factory).next(); // ugly code + EVENT_LOOP.submit(INIT_FUTURE::join); // https://github.com/ViaVersion/ViaFabric/issues/53 ugly workaround code but works tm + } + + public static String getVersion() { + return "1.0"; + } + + public void onInitialize() { + + Via.init(ViaManager.builder() + .injector(new VRInjector()) + .loader(new VRLoader()) + .platform(new VRPlatform()).build()); + + MappingDataLoader.enableMappingsCache(); + new ViaBackwardsPlatformImplementation(); + new ViaRewindPlatformImplementation(); + + Via.getManager().init(); + + INIT_FUTURE.complete(null); + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/handler/CommonTransformer.java b/src/main/java/com/github/creeper123123321/viafabric/handler/CommonTransformer.java new file mode 100644 index 0000000..4da17e8 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/handler/CommonTransformer.java @@ -0,0 +1,31 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric.handler; + +public class CommonTransformer { + public static final String HANDLER_DECODER_NAME = "via-decoder"; + public static final String HANDLER_ENCODER_NAME = "via-encoder"; +} \ No newline at end of file diff --git a/src/main/java/com/github/creeper123123321/viafabric/handler/clientside/VRDecodeHandler.java b/src/main/java/com/github/creeper123123321/viafabric/handler/clientside/VRDecodeHandler.java new file mode 100644 index 0000000..068134e --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/handler/clientside/VRDecodeHandler.java @@ -0,0 +1,70 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric.handler.clientside; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.MessageToMessageDecoder; +import us.myles.ViaVersion.api.data.UserConnection; +import us.myles.ViaVersion.exception.CancelCodecException; +import us.myles.ViaVersion.exception.CancelDecoderException; + +import java.util.List; + +public class VRDecodeHandler extends MessageToMessageDecoder { + private final UserConnection info; + + public VRDecodeHandler(UserConnection info) { + this.info = info; + } + + @Override + protected void decode(ChannelHandlerContext ctx, ByteBuf bytebuf, List out) throws Exception { + info.checkOutgoingPacket(); + if (!info.shouldTransformPacket()) { + out.add(bytebuf.retain()); + return; + } + + ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf); + try { + info.transformOutgoing(transformedBuf, CancelDecoderException::generate); + out.add(transformedBuf.retain()); + } finally { + transformedBuf.release(); + } + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + if (cause instanceof CancelCodecException) return; + super.exceptionCaught(ctx, cause); + } + + public UserConnection getInfo() { + return info; + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/handler/clientside/VREncodeHandler.java b/src/main/java/com/github/creeper123123321/viafabric/handler/clientside/VREncodeHandler.java new file mode 100644 index 0000000..aedf869 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/handler/clientside/VREncodeHandler.java @@ -0,0 +1,66 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric.handler.clientside; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.MessageToMessageEncoder; +import us.myles.ViaVersion.api.data.UserConnection; +import us.myles.ViaVersion.exception.CancelCodecException; +import us.myles.ViaVersion.exception.CancelEncoderException; + +import java.util.List; + +public class VREncodeHandler extends MessageToMessageEncoder { + private final UserConnection info; + + public VREncodeHandler(UserConnection info) { + this.info = info; + } + + @Override + protected void encode(ChannelHandlerContext ctx, ByteBuf bytebuf, List out) throws Exception { + if (!info.checkIncomingPacket()) throw CancelEncoderException.generate(null); + if (!info.shouldTransformPacket()) { + out.add(bytebuf.retain()); + return; + } + + ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf); + try { + info.transformIncoming(transformedBuf, CancelEncoderException::generate); + out.add(transformedBuf.retain()); + } finally { + transformedBuf.release(); + } + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + if (cause instanceof CancelCodecException) return; + super.exceptionCaught(ctx, cause); + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/injection/MixinLoader.java b/src/main/java/com/github/creeper123123321/viafabric/injection/MixinLoader.java new file mode 100644 index 0000000..7de2fe2 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/injection/MixinLoader.java @@ -0,0 +1,40 @@ +package com.github.creeper123123321.viafabric.injection; + +import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; +import org.spongepowered.asm.launch.MixinBootstrap; +import org.spongepowered.asm.mixin.MixinEnvironment; +import org.spongepowered.asm.mixin.Mixins; + +import java.util.Map; + +public class MixinLoader implements IFMLLoadingPlugin { + + public MixinLoader() { + MixinBootstrap.init(); + Mixins.addConfiguration("mixins.viaforge.json"); + MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT); + } + + @Override + public String[] getASMTransformerClass() { + return new String[0]; + } + + @Override + public String getModContainerClass() { + return null; + } + + @Override + public String getSetupClass() { + return null; + } + + @Override + public void injectData(Map data) { } + + @Override + public String getAccessTransformerClass() { + return null; + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinGuiDisconnected.java b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinGuiDisconnected.java new file mode 100644 index 0000000..478430e --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinGuiDisconnected.java @@ -0,0 +1,34 @@ +package com.github.creeper123123321.viafabric.injection.mixins; + +import com.github.creeper123123321.viafabric.ViaFabric; +import com.github.creeper123123321.viafabric.util.ProtocolUtils; +import de.flori2007.viaforge.gui.GuiProtocolSelector; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiDisconnected; +import net.minecraft.client.gui.GuiScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(GuiDisconnected.class) +public abstract class MixinGuiDisconnected extends GuiScreen { + + @Inject(method = "initGui", at = @At("RETURN")) + public void injectInitGui(CallbackInfo ci) { + buttonList.add(new GuiButton(1337, 5, 6, 98, 20, + ProtocolUtils.getProtocolName(ViaFabric.clientSideVersion))); + } + + @Inject(method = "actionPerformed", at = @At("RETURN")) + public void injectActionPerformed(GuiButton p_actionPerformed_1_, CallbackInfo ci) { + if (p_actionPerformed_1_.id == 1337) + mc.displayGuiScreen(new GuiProtocolSelector(this)); + } + + @Inject(method = "drawScreen", at = @At("RETURN")) + public void injectDrawScreen(int p_drawScreen_1_, int p_drawScreen_2_, float p_drawScreen_3_, CallbackInfo ci) { + mc.fontRenderer.drawStringWithShadow("<-- Current Version", + 104, 13, -1); + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinGuiMainMenu.java b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinGuiMainMenu.java new file mode 100644 index 0000000..4309f39 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinGuiMainMenu.java @@ -0,0 +1,34 @@ +package com.github.creeper123123321.viafabric.injection.mixins; + +import com.github.creeper123123321.viafabric.ViaFabric; +import com.github.creeper123123321.viafabric.util.ProtocolUtils; +import de.flori2007.viaforge.gui.GuiProtocolSelector; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiMainMenu; +import net.minecraft.client.gui.GuiScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(GuiMainMenu.class) +public abstract class MixinGuiMainMenu extends GuiScreen { + + @Inject(method = "initGui", at = @At("RETURN")) + public void injectInitGui(CallbackInfo ci) { + buttonList.add(new GuiButton(1337, 5, 6, 98, 20, + ProtocolUtils.getProtocolName(ViaFabric.clientSideVersion))); + } + + @Inject(method = "actionPerformed", at = @At("RETURN")) + public void injectActionPerformed(GuiButton p_actionPerformed_1_, CallbackInfo ci) { + if (p_actionPerformed_1_.id == 1337) + mc.displayGuiScreen(new GuiProtocolSelector(this)); + } + + @Inject(method = "drawScreen", at = @At("RETURN")) + public void injectDrawScreen(int p_drawScreen_1_, int p_drawScreen_2_, float p_drawScreen_3_, CallbackInfo ci) { + mc.fontRenderer.drawStringWithShadow("<-- Current Version", + 104, 13, -1); + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinGuiMultiplayer.java b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinGuiMultiplayer.java new file mode 100644 index 0000000..20761fd --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinGuiMultiplayer.java @@ -0,0 +1,34 @@ +package com.github.creeper123123321.viafabric.injection.mixins; + +import com.github.creeper123123321.viafabric.ViaFabric; +import com.github.creeper123123321.viafabric.util.ProtocolUtils; +import de.flori2007.viaforge.gui.GuiProtocolSelector; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiMultiplayer; +import net.minecraft.client.gui.GuiScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(GuiMultiplayer.class) +public abstract class MixinGuiMultiplayer extends GuiScreen { + + @Inject(method = "initGui", at = @At("RETURN")) + public void injectInitGui(CallbackInfo ci) { + buttonList.add(new GuiButton(1337, 5, 38, 98, 20, + ProtocolUtils.getProtocolName(ViaFabric.clientSideVersion))); + } + + @Inject(method = "actionPerformed", at = @At("RETURN")) + public void injectActionPerformed(GuiButton p_actionPerformed_1_, CallbackInfo ci) { + if (p_actionPerformed_1_.id == 1337) + mc.displayGuiScreen(new GuiProtocolSelector(this)); + } + + @Inject(method = "drawScreen", at = @At("RETURN")) + public void injectDrawScreen(int p_drawScreen_1_, int p_drawScreen_2_, float p_drawScreen_3_, CallbackInfo ci) { + mc.fontRenderer.drawStringWithShadow("<-- Current Version", + 104, 44, -1); + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinGuiScreenAddServer.java b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinGuiScreenAddServer.java new file mode 100644 index 0000000..904eeb5 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinGuiScreenAddServer.java @@ -0,0 +1,34 @@ +package com.github.creeper123123321.viafabric.injection.mixins; + +import com.github.creeper123123321.viafabric.ViaFabric; +import com.github.creeper123123321.viafabric.util.ProtocolUtils; +import de.flori2007.viaforge.gui.GuiProtocolSelector; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiScreenAddServer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(GuiScreenAddServer.class) +public abstract class MixinGuiScreenAddServer extends GuiScreen { + + @Inject(method = "initGui", at = @At("RETURN")) + public void injectInitGui(CallbackInfo ci) { + buttonList.add(new GuiButton(1337, 5, 6, 98, 20, + ProtocolUtils.getProtocolName(ViaFabric.clientSideVersion))); + } + + @Inject(method = "actionPerformed", at = @At("RETURN")) + public void injectActionPerformed(GuiButton p_actionPerformed_1_, CallbackInfo ci) { + if (p_actionPerformed_1_.id == 1337) + mc.displayGuiScreen(new GuiProtocolSelector(this)); + } + + @Inject(method = "drawScreen", at = @At("RETURN")) + public void injectDrawScreen(int p_drawScreen_1_, int p_drawScreen_2_, float p_drawScreen_3_, CallbackInfo ci) { + mc.fontRenderer.drawStringWithShadow("<-- Current Version", + 104, 13, -1); + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinGuiScreenServerList.java b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinGuiScreenServerList.java new file mode 100644 index 0000000..8b8809d --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinGuiScreenServerList.java @@ -0,0 +1,34 @@ +package com.github.creeper123123321.viafabric.injection.mixins; + +import com.github.creeper123123321.viafabric.ViaFabric; +import com.github.creeper123123321.viafabric.util.ProtocolUtils; +import de.flori2007.viaforge.gui.GuiProtocolSelector; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiScreenServerList; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(GuiScreenServerList.class) +public abstract class MixinGuiScreenServerList extends GuiScreen { + + @Inject(method = "initGui", at = @At("RETURN")) + public void injectInitGui(CallbackInfo ci) { + buttonList.add(new GuiButton(1337, 5, 6, 98, 20, + ProtocolUtils.getProtocolName(ViaFabric.clientSideVersion))); + } + + @Inject(method = "actionPerformed", at = @At("RETURN")) + public void injectActionPerformed(GuiButton p_actionPerformed_1_, CallbackInfo ci) { + if (p_actionPerformed_1_.id == 1337) + mc.displayGuiScreen(new GuiProtocolSelector(this)); + } + + @Inject(method = "drawScreen", at = @At("RETURN")) + public void injectDrawScreen(int p_drawScreen_1_, int p_drawScreen_2_, float p_drawScreen_3_, CallbackInfo ci) { + mc.fontRenderer.drawStringWithShadow("<-- Current Version", + 104, 13, -1); + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinMinecraft.java b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinMinecraft.java new file mode 100644 index 0000000..1d95085 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinMinecraft.java @@ -0,0 +1,22 @@ +package com.github.creeper123123321.viafabric.injection.mixins; + +import com.github.creeper123123321.viafabric.ViaFabric; +import net.minecraft.client.Minecraft; +import net.minecraft.client.main.GameConfiguration; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Minecraft.class) +public abstract class MixinMinecraft { + + @Inject(method = "", at = @At("RETURN")) + public void injectConstructor(GameConfiguration p_i45547_1_, CallbackInfo ci) { + try { + new ViaFabric().onInitialize(); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinNetworkManager.java b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinNetworkManager.java new file mode 100644 index 0000000..09bfa18 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinNetworkManager.java @@ -0,0 +1,36 @@ +package com.github.creeper123123321.viafabric.injection.mixins; + +import com.github.creeper123123321.viafabric.handler.CommonTransformer; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelPipeline; +import net.minecraft.network.NetworkManager; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(NetworkManager.class) +public abstract class MixinNetworkManager { + + @Redirect(method = "setCompressionThreshold", at = @At( + value = "INVOKE", + remap = false, + target = "Lio/netty/channel/ChannelPipeline;addBefore(Ljava/lang/String;Ljava/lang/String;Lio/netty/channel/ChannelHandler;)Lio/netty/channel/ChannelPipeline;" + )) + private ChannelPipeline decodeEncodePlacement(ChannelPipeline instance, String base, String newHandler, ChannelHandler handler) { + // Fixes the handler order + switch (base) { + case "decoder": { + if (instance.get(CommonTransformer.HANDLER_DECODER_NAME) != null) + base = CommonTransformer.HANDLER_DECODER_NAME; + break; + } + case "encoder": { + if (instance.get(CommonTransformer.HANDLER_ENCODER_NAME) != null) + base = CommonTransformer.HANDLER_ENCODER_NAME; + break; + } + } + return instance.addBefore(base, newHandler, handler); + } + +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinNetworkManagerChInit.java b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinNetworkManagerChInit.java new file mode 100644 index 0000000..dca54f2 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/injection/mixins/MixinNetworkManagerChInit.java @@ -0,0 +1,33 @@ +package com.github.creeper123123321.viafabric.injection.mixins; + +import com.github.creeper123123321.viafabric.handler.CommonTransformer; +import com.github.creeper123123321.viafabric.handler.clientside.VRDecodeHandler; +import com.github.creeper123123321.viafabric.handler.clientside.VREncodeHandler; +import com.github.creeper123123321.viafabric.platform.VRClientSideUserConnection; +import com.github.creeper123123321.viafabric.protocol.ViaFabricHostnameProtocol; +import io.netty.channel.Channel; +import io.netty.channel.socket.SocketChannel; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import us.myles.ViaVersion.api.data.UserConnection; +import us.myles.ViaVersion.api.protocol.ProtocolPipeline; + +@Mixin(targets = "net.minecraft.network.NetworkManager$5") +public abstract class MixinNetworkManagerChInit { + + @Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false) + private void onInitChannel(Channel channel, CallbackInfo ci) { + if (channel instanceof SocketChannel) { + + UserConnection user = new VRClientSideUserConnection(channel); + new ProtocolPipeline(user).add(ViaFabricHostnameProtocol.INSTANCE); + + channel.pipeline() + .addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new VREncodeHandler(user)) + .addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new VRDecodeHandler(user)); + System.out.println("aaaa"); + } + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/platform/VRBossBar.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRBossBar.java new file mode 100644 index 0000000..a5e0f98 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRBossBar.java @@ -0,0 +1,36 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric.platform; + +import us.myles.ViaVersion.api.boss.BossColor; +import us.myles.ViaVersion.api.boss.BossStyle; +import us.myles.ViaVersion.boss.CommonBoss; + +public class VRBossBar extends CommonBoss { + public VRBossBar(String title, float health, BossColor color, BossStyle style) { + super(title, health, color, style); + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/platform/VRClientSideUserConnection.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRClientSideUserConnection.java new file mode 100644 index 0000000..57eb782 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRClientSideUserConnection.java @@ -0,0 +1,67 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric.platform; + +import com.github.creeper123123321.viafabric.handler.CommonTransformer; +import io.netty.buffer.ByteBuf; +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; +import us.myles.ViaVersion.api.data.UserConnection; + +public class VRClientSideUserConnection extends UserConnection { + public VRClientSideUserConnection(Channel socketChannel) { + super(socketChannel); + } + // Based on https://github.com/Gerrygames/ClientViaVersion/blob/master/src/main/java/de/gerrygames/the5zig/clientviaversion/reflection/Injector.java + + @Override + public void sendRawPacket(final ByteBuf packet, boolean currentThread) { + Runnable act = () -> getChannel().pipeline().context(CommonTransformer.HANDLER_DECODER_NAME) + .fireChannelRead(packet); + if (currentThread) { + act.run(); + } else { + getChannel().eventLoop().execute(act); + } + } + + @Override + public ChannelFuture sendRawPacketFuture(ByteBuf packet) { + getChannel().pipeline().context(CommonTransformer.HANDLER_DECODER_NAME).fireChannelRead(packet); + return getChannel().newSucceededFuture(); + } + + @Override + public void sendRawPacketToServer(ByteBuf packet, boolean currentThread) { + if (currentThread) { + getChannel().pipeline().context(CommonTransformer.HANDLER_ENCODER_NAME).writeAndFlush(packet); + } else { + getChannel().eventLoop().submit(() -> { + getChannel().pipeline().context(CommonTransformer.HANDLER_ENCODER_NAME).writeAndFlush(packet); + }); + } + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/platform/VRConnectionManager.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRConnectionManager.java new file mode 100644 index 0000000..13c3ac6 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRConnectionManager.java @@ -0,0 +1,36 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric.platform; + +import us.myles.ViaVersion.api.data.UserConnection; +import us.myles.ViaVersion.api.platform.ViaConnectionManager; + +public class VRConnectionManager extends ViaConnectionManager { + @Override + public boolean isFrontEnd(UserConnection connection) { + return !(connection instanceof VRClientSideUserConnection); + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/platform/VRInjector.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRInjector.java new file mode 100644 index 0000000..1ba4560 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRInjector.java @@ -0,0 +1,85 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric.platform; + +import com.github.creeper123123321.viafabric.handler.CommonTransformer; +import us.myles.ViaVersion.api.platform.ViaInjector; +import us.myles.ViaVersion.util.GsonUtil; +import us.myles.viaversion.libs.gson.JsonObject; + +import java.lang.reflect.Method; +import java.util.Arrays; + +public class VRInjector implements ViaInjector { + @Override + public void inject() { + // *looks at Mixins* + } + + @Override + public void uninject() { + // not possible *plays sad violin* + } + + @Override + public int getServerProtocolVersion() throws NoSuchFieldException, IllegalAccessException { + return getClientProtocol(); + } + + private int getClientProtocol() throws NoSuchFieldException, IllegalAccessException { + return 47; + } + + @Override + public String getEncoderName() { + return CommonTransformer.HANDLER_ENCODER_NAME; + } + + @Override + public String getDecoderName() { + return CommonTransformer.HANDLER_DECODER_NAME; + } + + @Override + public JsonObject getDump() { + JsonObject obj = new JsonObject(); + try { + obj.add("serverNetworkIOChInit", GsonUtil.getGson().toJsonTree( + Arrays.stream(Class.forName("net.minecraft.class_3242$1").getDeclaredMethods()) + .map(Method::toString) + .toArray(String[]::new))); + } catch (ClassNotFoundException ignored) { + } + try { + obj.add("clientConnectionChInit", GsonUtil.getGson().toJsonTree( + Arrays.stream(Class.forName("net.minecraft.class_2535$1").getDeclaredMethods()) + .map(Method::toString) + .toArray(String[]::new))); + } catch (ClassNotFoundException ignored) { + } + return obj; + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/platform/VRLoader.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRLoader.java new file mode 100644 index 0000000..7e8c67c --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRLoader.java @@ -0,0 +1,46 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric.platform; + +import com.github.creeper123123321.viafabric.providers.VRVersionProvider; +import us.myles.ViaVersion.api.Via; +import us.myles.ViaVersion.api.platform.ViaPlatformLoader; +import us.myles.ViaVersion.bungee.providers.BungeeMovementTransmitter; +import us.myles.ViaVersion.protocols.base.VersionProvider; +import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider; + +public class VRLoader implements ViaPlatformLoader { + @Override + public void load() { + Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter()); + Via.getManager().getProviders().use(VersionProvider.class, new VRVersionProvider()); + } + + @Override + public void unload() { + // Nothing to do + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/platform/VRPlatform.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRPlatform.java new file mode 100644 index 0000000..bc8aaab --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRPlatform.java @@ -0,0 +1,237 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric.platform; + +import com.github.creeper123123321.viafabric.ViaFabric; +import com.github.creeper123123321.viafabric.util.FutureTaskId; +import com.github.creeper123123321.viafabric.util.JLoggerToLog4j; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; +import net.minecraft.client.Minecraft; +import net.minecraft.server.MinecraftServer; +import org.apache.logging.log4j.LogManager; +import us.myles.ViaVersion.api.ViaAPI; +import us.myles.ViaVersion.api.ViaVersionConfig; +import us.myles.ViaVersion.api.command.ViaCommandSender; +import us.myles.ViaVersion.api.configuration.ConfigurationProvider; +import us.myles.ViaVersion.api.platform.TaskId; +import us.myles.ViaVersion.api.platform.ViaConnectionManager; +import us.myles.ViaVersion.api.platform.ViaPlatform; +import us.myles.viaversion.libs.bungeecordchat.api.chat.TextComponent; +import us.myles.viaversion.libs.bungeecordchat.chat.ComponentSerializer; +import us.myles.viaversion.libs.gson.JsonObject; + +import java.io.File; +import java.nio.file.Path; +import java.util.UUID; +import java.util.concurrent.Callable; +import java.util.concurrent.CancellationException; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; +import java.util.logging.Logger; + +public class VRPlatform implements ViaPlatform { + private final Logger logger = new JLoggerToLog4j(LogManager.getLogger("ViaVersion")); + private final VRViaConfig config; + private final File dataFolder; + private final ViaConnectionManager connectionManager; + private final ViaAPI api; + + public VRPlatform() { + Path configDir = Minecraft.getMinecraft().gameDir.toPath().resolve("ViaFabric"); + config = new VRViaConfig(configDir.resolve("viaversion.yml").toFile()); + dataFolder = configDir.toFile(); + connectionManager = new VRConnectionManager(); + api = new VRViaAPI(); + } + + public static MinecraftServer getServer() { + // In 1.8.9 integrated server instance exists even if it's not running + if (!Minecraft.getMinecraft().isIntegratedServerRunning()) return null; + return Minecraft.getMinecraft().getIntegratedServer(); + } + + @Override + public Logger getLogger() { + return logger; + } + + @Override + public String getPlatformName() { + return "ViaFabric"; + } + + @Override + public String getPlatformVersion() { + return ViaFabric.getVersion(); + } + + @Override + public String getPluginVersion() { + return "3.3.0"; + } + + @Override + public TaskId runAsync(Runnable runnable) { + return new FutureTaskId(CompletableFuture + .runAsync(runnable, ViaFabric.ASYNC_EXECUTOR) + .exceptionally(throwable -> { + if (!(throwable instanceof CancellationException)) { + throwable.printStackTrace(); + } + return null; + }) + ); + } + + @Override + public TaskId runSync(Runnable runnable) { + if (getServer() != null) { + return runServerSync(runnable); + } else { + return runEventLoop(runnable); + } + } + + private TaskId runServerSync(Runnable runnable) { + // Kick task needs to be on main thread, it does already have error logger + return new FutureTaskId(CompletableFuture.runAsync(runnable, it -> getServer().callFromMainThread((Callable + ) () -> { + it.run(); + return null; + }))); + } + + private TaskId runEventLoop(Runnable runnable) { + return new FutureTaskId( + ViaFabric.EVENT_LOOP + .submit(runnable) + .addListener(errorLogger()) + ); + } + + @Override + public TaskId runSync(Runnable runnable, Long ticks) { + // ViaVersion seems to not need to run delayed tasks on main thread + return new FutureTaskId( + ViaFabric.EVENT_LOOP + .schedule(() -> runSync(runnable), ticks * 50, TimeUnit.MILLISECONDS) + .addListener(errorLogger()) + ); + } + + @Override + public TaskId runRepeatingSync(Runnable runnable, Long ticks) { + // ViaVersion seems to not need to run repeating tasks on main thread + return new FutureTaskId( + ViaFabric.EVENT_LOOP + .scheduleAtFixedRate(() -> runSync(runnable), 0, ticks * 50, TimeUnit.MILLISECONDS) + .addListener(errorLogger()) + ); + } + + private > GenericFutureListener errorLogger() { + return future -> { + if (!future.isCancelled() && future.cause() != null) { + future.cause().printStackTrace(); + } + }; + } + + @Override + public void cancelTask(TaskId taskId) { + if (taskId instanceof FutureTaskId) { + ((FutureTaskId) taskId).getObject().cancel(false); + } + } + + @Override + public ViaCommandSender[] getOnlinePlayers() { + return new ViaCommandSender[0]; + } + + @Override + public void sendMessage(UUID uuid, String s) { + } + + @Override + public boolean kickPlayer(UUID uuid, String s) { + return kickServer(uuid, s); + } + + private boolean kickServer(UUID uuid, String s) { + return false; // Can't know if it worked + } + + @Override + public boolean isPluginEnabled() { + return true; + } + + @Override + public ViaAPI getApi() { + return api; + } + + @Override + public ViaVersionConfig getConf() { + return config; + } + + @Override + public ConfigurationProvider getConfigurationProvider() { + return config; + } + + @Override + public File getDataFolder() { + return dataFolder; + } + + @Override + public void onReload() { + // Nothing to do + } + + @Override + public JsonObject getDump() { + return new JsonObject(); + } + + @Override + public boolean isOldClientsAllowed() { + return true; + } + + @Override + public ViaConnectionManager getConnectionManager() { + return connectionManager; + } + + private String legacyToJson(String legacy) { + return ComponentSerializer.toString(TextComponent.fromLegacyText(legacy)); + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/platform/VRViaAPI.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRViaAPI.java new file mode 100644 index 0000000..9387247 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRViaAPI.java @@ -0,0 +1,88 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric.platform; + +import io.netty.buffer.ByteBuf; +import us.myles.ViaVersion.api.Via; +import us.myles.ViaVersion.api.ViaAPI; +import us.myles.ViaVersion.api.boss.BossBar; +import us.myles.ViaVersion.api.boss.BossColor; +import us.myles.ViaVersion.api.boss.BossStyle; +import us.myles.ViaVersion.api.data.UserConnection; +import us.myles.ViaVersion.api.protocol.ProtocolRegistry; + +import java.util.SortedSet; +import java.util.TreeSet; +import java.util.UUID; + +public class VRViaAPI implements ViaAPI { + @Override + public int getPlayerVersion(UUID uuid) { + UserConnection con = Via.getManager().getConnection(uuid); + if (con != null) { + return con.getProtocolInfo().getProtocolVersion(); + } + try { + return Via.getManager().getInjector().getServerProtocolVersion(); + } catch (Exception e) { + throw new AssertionError(e); + } + } + + @Override + public boolean isInjected(UUID uuid) { + return Via.getManager().isClientConnected(uuid); + } + + @Override + public String getVersion() { + return Via.getPlatform().getPluginVersion(); + } + + @Override + public void sendRawPacket(UUID uuid, ByteBuf byteBuf) throws IllegalArgumentException { + UserConnection ci = Via.getManager().getConnection(uuid); + ci.sendRawPacket(byteBuf); + } + + @Override + public BossBar createBossBar(String s, BossColor bossColor, BossStyle bossStyle) { + return new VRBossBar(s, 1f, bossColor, bossStyle); + } + + @Override + public BossBar createBossBar(String s, float v, BossColor bossColor, BossStyle bossStyle) { + return new VRBossBar(s, v, bossColor, bossStyle); + } + + @Override + public SortedSet getSupportedVersions() { + SortedSet outputSet = new TreeSet<>(ProtocolRegistry.getSupportedVersions()); + outputSet.removeAll(Via.getPlatform().getConf().getBlockedProtocols()); + + return outputSet; + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/platform/VRViaConfig.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRViaConfig.java new file mode 100644 index 0000000..cdac054 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRViaConfig.java @@ -0,0 +1,98 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric.platform; + +import us.myles.ViaVersion.AbstractViaConfig; + +import java.io.File; +import java.net.URL; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +public class VRViaConfig extends AbstractViaConfig { + // Based on Sponge ViaVersion + private static List UNSUPPORTED = Arrays.asList("anti-xray-patch", "bungee-ping-interval", + "bungee-ping-save", "bungee-servers", "quick-move-action-fix", "nms-player-ticking", + "item-cache", "velocity-ping-interval", "velocity-ping-save", "velocity-servers", + "blockconnection-method", "change-1_9-hitbox", "change-1_14-hitbox"); + + public VRViaConfig(File configFile) { + super(configFile); + // Load config + reloadConfig(); + } + + @Override + public URL getDefaultConfigURL() { + return getClass().getClassLoader().getResource("assets/viaversion/config.yml"); + } + + @Override + protected void handleConfig(Map config) { + // Nothing Currently + } + + @Override + public List getUnsupportedOptions() { + return UNSUPPORTED; + } + + @Override + public boolean isAntiXRay() { + return false; + } + + @Override + public boolean isItemCache() { + return false; + } + + @Override + public boolean isNMSPlayerTicking() { + return false; + } + + @Override + public boolean is1_12QuickMoveActionFix() { + return false; + } + + @Override + public String getBlockConnectionMethod() { + return "packet"; + } + + @Override + public boolean is1_9HitboxFix() { + return false; + } + + @Override + public boolean is1_14HitboxFix() { + return false; + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/protocol/ViaFabricHostnameProtocol.java b/src/main/java/com/github/creeper123123321/viafabric/protocol/ViaFabricHostnameProtocol.java new file mode 100644 index 0000000..afb865c --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/protocol/ViaFabricHostnameProtocol.java @@ -0,0 +1,28 @@ +package com.github.creeper123123321.viafabric.protocol; + +import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.protocol.SimpleProtocol; +import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.remapper.ValueTransformer; +import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.packets.State; + +public class ViaFabricHostnameProtocol extends SimpleProtocol { + public static final ViaFabricHostnameProtocol INSTANCE = new ViaFabricHostnameProtocol(); + + @Override + protected void registerPackets() { + registerIncoming(State.HANDSHAKE, 0, 0, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // Protocol version + map(Type.STRING, new ValueTransformer(Type.STRING) { + @Override + public String transform(PacketWrapper packetWrapper, String s) { + return s; + } + }); + } + }); + } +} \ No newline at end of file diff --git a/src/main/java/com/github/creeper123123321/viafabric/providers/VRVersionProvider.java b/src/main/java/com/github/creeper123123321/viafabric/providers/VRVersionProvider.java new file mode 100644 index 0000000..49f355e --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/providers/VRVersionProvider.java @@ -0,0 +1,42 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric.providers; + +import com.github.creeper123123321.viafabric.ViaFabric; +import com.github.creeper123123321.viafabric.platform.VRClientSideUserConnection; +import us.myles.ViaVersion.api.data.UserConnection; +import us.myles.ViaVersion.protocols.base.VersionProvider; + +public class VRVersionProvider extends VersionProvider { + + @Override + public int getServerProtocol(UserConnection connection) throws Exception { + if (connection instanceof VRClientSideUserConnection) { + return ViaFabric.clientSideVersion; + } + return super.getServerProtocol(connection); + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/util/FutureTaskId.java b/src/main/java/com/github/creeper123123321/viafabric/util/FutureTaskId.java new file mode 100644 index 0000000..0fc044c --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/util/FutureTaskId.java @@ -0,0 +1,43 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric.util; + +import us.myles.ViaVersion.api.platform.TaskId; + +import java.util.concurrent.Future; + +public class FutureTaskId implements TaskId { + private final Future object; + + public FutureTaskId(Future object) { + this.object = object; + } + + @Override + public Future getObject() { + return object; + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/util/JLoggerToLog4j.java b/src/main/java/com/github/creeper123123321/viafabric/util/JLoggerToLog4j.java new file mode 100644 index 0000000..d0c1945 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/util/JLoggerToLog4j.java @@ -0,0 +1,93 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric.util; + +import java.text.MessageFormat; +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +public class JLoggerToLog4j extends Logger { + private final org.apache.logging.log4j.Logger base; + + public JLoggerToLog4j(org.apache.logging.log4j.Logger logger) { + super("logger", null); + this.base = logger; + } + + public void log(LogRecord record) { + this.log(record.getLevel(), record.getMessage()); + } + + public void log(Level level, String msg) { + if (level == Level.FINE) { + this.base.debug(msg); + } else if (level == Level.WARNING) { + this.base.warn(msg); + } else if (level == Level.SEVERE) { + this.base.error(msg); + } else if (level == Level.INFO) { + this.base.info(msg); + } else { + this.base.trace(msg); + } + + } + + public void log(Level level, String msg, Object param1) { + if (level == Level.FINE) { + this.base.debug(msg, param1); + } else if (level == Level.WARNING) { + this.base.warn(msg, param1); + } else if (level == Level.SEVERE) { + this.base.error(msg, param1); + } else if (level == Level.INFO) { + this.base.info(msg, param1); + } else { + this.base.trace(msg, param1); + } + + } + + public void log(Level level, String msg, Object[] params) { + log(level, MessageFormat.format(msg, params)); + } + + public void log(Level level, String msg, Throwable params) { + if (level == Level.FINE) { + this.base.debug(msg, params); + } else if (level == Level.WARNING) { + this.base.warn(msg, params); + } else if (level == Level.SEVERE) { + this.base.error(msg, params); + } else if (level == Level.INFO) { + this.base.info(msg, params); + } else { + this.base.trace(msg, params); + } + + } +} diff --git a/src/main/java/com/github/creeper123123321/viafabric/util/ProtocolUtils.java b/src/main/java/com/github/creeper123123321/viafabric/util/ProtocolUtils.java new file mode 100644 index 0000000..fec72f0 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viafabric/util/ProtocolUtils.java @@ -0,0 +1,37 @@ +/* + * MIT License + * + * Copyright (c) 2018- creeper123123321 + * Copyright (c) 2019- contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.creeper123123321.viafabric.util; + +import us.myles.ViaVersion.api.protocol.ProtocolVersion; + +public class ProtocolUtils { + + public static String getProtocolName(int id) { + if (!ProtocolVersion.isRegistered(id)) return Integer.toString(id); + return ProtocolVersion.getProtocol(id).getName(); + } + +} diff --git a/src/main/java/de/flori2007/viaforge/gui/GuiProtocolSelector.java b/src/main/java/de/flori2007/viaforge/gui/GuiProtocolSelector.java new file mode 100644 index 0000000..d5d6b89 --- /dev/null +++ b/src/main/java/de/flori2007/viaforge/gui/GuiProtocolSelector.java @@ -0,0 +1,99 @@ +package de.flori2007.viaforge.gui; + +import com.github.creeper123123321.viafabric.ViaFabric; +import com.github.creeper123123321.viafabric.util.ProtocolUtils; +import com.mojang.realmsclient.gui.ChatFormatting; +import de.flori2007.viaforge.utils.ProtocolSorter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiSlot; +import org.lwjgl.opengl.GL11; + +import java.io.IOException; + +public class GuiProtocolSelector extends GuiScreen { + + public SlotList list; + + private GuiScreen parent; + + public GuiProtocolSelector(GuiScreen parent) { + this.parent = parent; + } + + @Override + public void initGui() { + super.initGui(); + buttonList.add(new GuiButton(1, width / 2 - 100, height - 27, 200, + 20, "Back")); + + list = new SlotList(mc, width, height, 32, height - 32, 10); + } + + @Override + protected void actionPerformed(GuiButton p_actionPerformed_1_) throws IOException { + list.actionPerformed(p_actionPerformed_1_); + + if (p_actionPerformed_1_.id == 1) + mc.displayGuiScreen(parent); + } + + @Override + public void handleMouseInput() throws IOException { + list.handleMouseInput(); + super.handleMouseInput(); + } + + @Override + public void drawScreen(int p_drawScreen_1_, int p_drawScreen_2_, float p_drawScreen_3_) { + list.drawScreen(p_drawScreen_1_, p_drawScreen_2_, p_drawScreen_3_); + + GL11.glPushMatrix(); + GL11.glScalef(2.0F, 2.0F, 2.0F); + this.drawCenteredString(this.fontRenderer, ChatFormatting.GOLD.toString() + "ViaForge", + this.width / 4, 6, 16777215); + GL11.glPopMatrix(); + + drawString(this.fontRenderer, "by Flori2007", 1, 1, -1); + + super.drawScreen(p_drawScreen_1_, p_drawScreen_2_, p_drawScreen_3_); + } + + class SlotList extends GuiSlot { + + + public SlotList(Minecraft p_i1052_1_, int p_i1052_2_, int p_i1052_3_, int p_i1052_4_, int p_i1052_5_, int p_i1052_6_) { + super(p_i1052_1_, p_i1052_2_, p_i1052_3_, p_i1052_4_, p_i1052_5_, p_i1052_6_); + } + + @Override + protected int getSize() { + return ProtocolSorter.getProtocolVersions().size(); + } + + @Override + protected void elementClicked(int i, boolean b, int i1, int i2) { + ViaFabric.clientSideVersion = ProtocolSorter.getProtocolVersions().get(i).getVersion(); + } + + @Override + protected boolean isSelected(int i) { + return false; + } + + @Override + protected void drawBackground() { + drawDefaultBackground(); + } + + + @Override + protected void drawSlot(int i, int i1, int i2, int unknown, int i3, int i4, float i5) { + drawCenteredString(mc.fontRenderer,(ViaFabric.clientSideVersion == + ProtocolSorter.getProtocolVersions().get(i).getVersion() ? ChatFormatting.GREEN.toString() : + ChatFormatting.DARK_RED.toString()) + ProtocolUtils.getProtocolName(ProtocolSorter. + getProtocolVersions().get(i).getVersion()), width / 2, i2 + 2, -1); + } + } +} diff --git a/src/main/java/de/flori2007/viaforge/platform/ViaBackwardsPlatformImplementation.java b/src/main/java/de/flori2007/viaforge/platform/ViaBackwardsPlatformImplementation.java new file mode 100644 index 0000000..56faecf --- /dev/null +++ b/src/main/java/de/flori2007/viaforge/platform/ViaBackwardsPlatformImplementation.java @@ -0,0 +1,58 @@ +package de.flori2007.viaforge.platform; + +import net.minecraft.client.Minecraft; +import nl.matsv.viabackwards.ViaBackwards; +import nl.matsv.viabackwards.api.ViaBackwardsConfig; +import nl.matsv.viabackwards.api.ViaBackwardsPlatform; +import us.myles.ViaVersion.api.Via; + +import java.io.File; +import java.util.logging.Logger; + +public class ViaBackwardsPlatformImplementation implements ViaBackwardsPlatform { + + public ViaBackwardsPlatformImplementation() { + ViaBackwards.init(this, new ViaBackwardsConfig() { + @Override + public boolean addCustomEnchantsToLore() { + return true; + } + + @Override + public boolean addTeamColorTo1_13Prefix() { + return true; + } + + @Override + public boolean isFix1_13FacePlayer() { + return true; + } + + @Override + public boolean alwaysShowOriginalMobName() { + return true; + } + }); + init(Minecraft.getMinecraft().gameDir); + } + + @Override + public Logger getLogger() { + return Via.getPlatform().getLogger(); + } + + @Override + public void disable() { + + } + + @Override + public boolean isOutdated() { + return false; + } + + @Override + public File getDataFolder() { + return Minecraft.getMinecraft().gameDir; + } +} diff --git a/src/main/java/de/flori2007/viaforge/platform/ViaRewindPlatformImplementation.java b/src/main/java/de/flori2007/viaforge/platform/ViaRewindPlatformImplementation.java new file mode 100644 index 0000000..8074997 --- /dev/null +++ b/src/main/java/de/flori2007/viaforge/platform/ViaRewindPlatformImplementation.java @@ -0,0 +1,34 @@ +package de.flori2007.viaforge.platform; + +import de.gerrygames.viarewind.api.ViaRewindConfig; +import de.gerrygames.viarewind.api.ViaRewindPlatform; +import us.myles.ViaVersion.api.Via; + +import java.util.logging.Logger; + +public class ViaRewindPlatformImplementation implements ViaRewindPlatform { + + public ViaRewindPlatformImplementation() { + init(new ViaRewindConfig() { + @Override + public CooldownIndicator getCooldownIndicator() { + return CooldownIndicator.TITLE; + } + + @Override + public boolean isReplaceAdventureMode() { + return true; + } + + @Override + public boolean isReplaceParticles() { + return true; + } + }); + } + + @Override + public Logger getLogger() { + return Via.getPlatform().getLogger(); + } +} diff --git a/src/main/java/de/flori2007/viaforge/utils/ProtocolSorter.java b/src/main/java/de/flori2007/viaforge/utils/ProtocolSorter.java new file mode 100644 index 0000000..35ac5bc --- /dev/null +++ b/src/main/java/de/flori2007/viaforge/utils/ProtocolSorter.java @@ -0,0 +1,37 @@ +package de.flori2007.viaforge.utils; + +import us.myles.ViaVersion.api.protocol.ProtocolVersion; + +import java.lang.reflect.Field; +import java.util.Collections; +import java.util.LinkedList; + +public class ProtocolSorter { + + private static final LinkedList protocolVersions = new LinkedList<>(); + + private static int count = 0; + + static { + for (Field f : ProtocolVersion.class.getDeclaredFields()) { + if (f.getType().equals(ProtocolVersion.class)) { + count++; + try { + ProtocolVersion ver = (ProtocolVersion) f.get(null); + + if (count >= 8 && !ver.getName().equals("UNKNOWN")) + getProtocolVersions().add(ver); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + } + + Collections.reverse(getProtocolVersions()); + } + + public static LinkedList getProtocolVersions() { + return protocolVersions; + } + +} diff --git a/src/main/resources/assets/viafabric/config.yml b/src/main/resources/assets/viafabric/config.yml new file mode 100644 index 0000000..84481c4 --- /dev/null +++ b/src/main/resources/assets/viafabric/config.yml @@ -0,0 +1,12 @@ +# WARNING +# I cannot guarantee that this mod is allowed on every (or even any) server. This mod may cause problems with anti cheat plugins. USE AT OWN RISK +# This option enables client-side transforming (can also be enabled in-game) +enable-client-side: false +# This option sets the protocol version to be used when connection to the server (can also be changed in-game) +client-side-version: -1 +# Hides VIA button from multiplayer menu. +hide-button: false +# List of servers which ViaFabric will force disabling transforming on client-side. It can be overwritten by setting per-server version. +# This isn't always the address in multiplayer GUI. It will use the SRV record pointer when present. Check the game log for the address. +# Uses https://wiki.vg/Mojang_API#Blocked_Servers format (mc.example.com, *.example.com, 192.168.0.1, 192.168.*) +client-side-force-disable: ["hypixel.net", "*.hypixel.net", "hivemc.com", "*.hivemc.com", "hivemc.eu", "*.hivemc.eu"] \ No newline at end of file diff --git a/src/main/resources/assets/viafabric/lang/de_DE.lang b/src/main/resources/assets/viafabric/lang/de_DE.lang new file mode 100644 index 0000000..8b1bef1 --- /dev/null +++ b/src/main/resources/assets/viafabric/lang/de_DE.lang @@ -0,0 +1,12 @@ +gui.protocol_version_field.name=Protokoll Version +gui.enable_client_side_button=ViaVersion aktivieren +gui.enable_client_side.question=Bist du dir sicher, dass du den clientseitigen Modus aktivieren möchtest? +gui.enable_client_side.warning=Ich kann nicht garantieren, dass diese Mod auf jedem (oder überhaupt einem) Server erlaubt ist. Diese Mod könnte eventuell Probleme mit Anti-Cheat Plugins hervorrufen. VERWENDUNG AUF EIGENE GEFAHR. +gui.enable_client_side.enable=Aktivieren +gui.viafabric_config.title=ViaFabric-Konfigurationen +gui.client_side.enable=Clientseitig aktivieren +gui.client_side.disable=Clientseitig deaktivieren +gui.ping_version.translated=VIA: %s +gui.hide_via_button.enable=VIA Button ausblenden +gui.hide_via_button.disable=VIA Button anzeigen +gui.via_button=VIA diff --git a/src/main/resources/assets/viafabric/lang/en_US.lang b/src/main/resources/assets/viafabric/lang/en_US.lang new file mode 100644 index 0000000..e4b6ccd --- /dev/null +++ b/src/main/resources/assets/viafabric/lang/en_US.lang @@ -0,0 +1,12 @@ +gui.protocol_version_field.name=Protocol Version +gui.enable_client_side_button=Enable ViaVersion +gui.enable_client_side.question=Are you sure you want to enable client-side mode? +gui.enable_client_side.warning=I cannot guarantee that this mod is allowed on every (or even any) server. This mod may cause problems with anti-cheat plugins. USE AT OWN RISK. +gui.enable_client_side.enable=Enable +gui.viafabric_config.title=ViaFabric Configurations +gui.client_side.enable=Enable client-side +gui.client_side.disable=Disable client-side +gui.ping_version.translated"=VIA: %s +gui.hide_via_button.enable=Hide VIA button +gui.hide_via_button.disable=Show VIA button +gui.via_button="VIA \ No newline at end of file diff --git a/src/main/resources/assets/viafabric/lang/es_ES.lang b/src/main/resources/assets/viafabric/lang/es_ES.lang new file mode 100644 index 0000000..0ff96c6 --- /dev/null +++ b/src/main/resources/assets/viafabric/lang/es_ES.lang @@ -0,0 +1,12 @@ +gui.protocol_version_field.name=Versión del protocolo +gui.enable_client_side_button=Activar ViaVersion +gui.enable_client_side.question=¿Estás seguro de que quieres habilitar el modo de lado del cliente? +gui.enable_client_side.warning=No puedo garantizar que este mod esté permitido en todos (o incluso en cualquier) los servidores. Este mod puede causar problemas con los plugins anti-cheat. EL USO DE ESTE MOD ES BAJO SU PROPIO RIESGO. +gui.enable_client_side.enable=Activar +gui.viafabric_config.title=Configuraciones de ViaFabric +gui.client_side.enable=Activar el lado del cliente +gui.client_side.disable=Desactivar el lado del cliente +gui.ping_version.translated=VIA: %s +gui.hide_via_button.enable=Ocultar el botón VIA +gui.hide_via_button.disable=Mostrar el botón VIA +gui.via_button=VIA diff --git a/src/main/resources/assets/viafabric/lang/et_EE.lang b/src/main/resources/assets/viafabric/lang/et_EE.lang new file mode 100644 index 0000000..cb8ad98 --- /dev/null +++ b/src/main/resources/assets/viafabric/lang/et_EE.lang @@ -0,0 +1,12 @@ +gui.protocol_version_field.name=Protokolli versioon +gui.enable_client_side_button=Luba ViaVersion +gui.enable_client_side.question=Kas soovid kindlasti lubada kliendipoolse režiimi? +gui.enable_client_side.warning=Ma ei saa garanteerida selle modi lubamist igas (mistahes) serveris. See mod võib põhjustada sohivastaste pluginatega probleeme. KASUTA OMAL VASTUTUSEL. +gui.enable_client_side.enable=Luba +gui.viafabric_config.title=ViaFabricu seadistused +gui.client_side.enable=Luba kliendipoolne +gui.client_side.disable=Keela kliendipoolne +gui.ping_version.translated=VIA: %s +gui.hide_via_button.enable=Peida VIA nupp +gui.hide_via_button.disable=Kuva VIA nuppu +gui.via_button=VIA diff --git a/src/main/resources/assets/viafabric/lang/fr_FR.lang b/src/main/resources/assets/viafabric/lang/fr_FR.lang new file mode 100644 index 0000000..d482028 --- /dev/null +++ b/src/main/resources/assets/viafabric/lang/fr_FR.lang @@ -0,0 +1,12 @@ +gui.protocol_version_field.name=Version du protocole +gui.enable_client_side_button=Activer ViaVersion +gui.enable_client_side.question=Êtes vous sûr de vouloir activer le mode coté client ? +gui.enable_client_side.warning=Je ne peux pas vous garantir que ce mod est autorisé dans tous (ou même aucun) serveur. Ce mod peut causer des problèmes avec les plugin anti-cheat. À UTILISEZ À VOS RISQUES ET PERILS. +gui.enable_client_side.enable=Activer +gui.viafabric_config.title=Configuration de ViaFabric +gui.client_side.enable=Activer coté client +gui.client_side.disable=Désactiver coté client +gui.ping_version.translated=VIA: %s +gui.hide_via_button.enable=Cacher le bouton VIA +gui.hide_via_button.disable=Montrer le bouton VIA +gui.via_button=VIA diff --git a/src/main/resources/assets/viafabric/lang/it_IT.lang b/src/main/resources/assets/viafabric/lang/it_IT.lang new file mode 100644 index 0000000..814b332 --- /dev/null +++ b/src/main/resources/assets/viafabric/lang/it_IT.lang @@ -0,0 +1,12 @@ +gui.protocol_version_field.name=Versione del protocollo +gui.enable_client_side_button=Attivare ViaVersion +gui.enable_client_side.question=Siete sicuri di voler attivare la modalità lato cliente? +gui.enable_client_side.warning=Non posso garantire che questo mod sia consentito su ogni server (o anche solo su uno qualsiasi). Questo mod può causare problemi con i plugin anti-cheat. USO A PROPRIO RISCHIO E PERICOLO. +gui.enable_client_side.enable=Attivare +gui.viafabric_config.title=Configurazioni ViaFabric +gui.client_side.enable=Attivare lato cliente +gui.client_side.disable=Disattivare lato cliente +gui.ping_version.translated=VIA: %s +gui.hide_via_button.enable=Nascondi il pulsante VIA +gui.hide_via_button.disable=Mostra il pulsante VIA +gui.via_button=VIA diff --git a/src/main/resources/assets/viafabric/lang/ja_JP.lang b/src/main/resources/assets/viafabric/lang/ja_JP.lang new file mode 100644 index 0000000..602a0c3 --- /dev/null +++ b/src/main/resources/assets/viafabric/lang/ja_JP.lang @@ -0,0 +1,12 @@ +gui.protocol_version_field.name=プロトコルバージョン +gui.enable_client_side_button=ViaVersionを有効にする +gui.enable_client_side.question=本当にクライアントサイドモードを有効にしますか? +gui.enable_client_side.warning=私はこのMODがすべての(あるいはどのサーバーでも)許可されていることを保証することはできません。このMODはアンチチートプラグインの問題を引き起こす可能性があります。自己責任で使用してください。 +gui.enable_client_side.enable=有効化 +gui.viafabric_config.title=ViaFabricの構成 +gui.client_side.enable=クライアント側を有効にする +gui.client_side.disable=クライアント側を無効にする +gui.ping_version.translated=VIA: %s +gui.hide_via_button.enable=VIAボタンを隠す +gui.hide_via_button.disable=VIAボタンを表示 +gui.via_button=VIA diff --git a/src/main/resources/assets/viafabric/lang/nl_NL.lang b/src/main/resources/assets/viafabric/lang/nl_NL.lang new file mode 100644 index 0000000..ca9892c --- /dev/null +++ b/src/main/resources/assets/viafabric/lang/nl_NL.lang @@ -0,0 +1,12 @@ +gui.protocol_version_field.name=Protocolversie +gui.enable_client_side_button=Schakel ViaVersion in +gui.enable_client_side.question=Weet u zeker dat u de client-side modus wilt inschakelen? +gui.enable_client_side.warning=Ik kan niet garanderen dat deze mod op elke (of zelfs maar één) server is toegestaan. Deze mod kan problemen veroorzaken met anti-cheat plugins. GEBRUIK OP EIGEN RISICO. +gui.enable_client_side.enable=Schakel in +gui.viafabric_config.title=ViaFabric-configuraties +gui.client_side.enable=Klantenservice inschakelen +gui.client_side.disable=Cliëntenservice uitschakelen +gui.ping_version.translated=VIA: %s +gui.hide_via_button.enable=VIA-knop verbergen +gui.hide_via_button.disable=Toon VIA-knop +gui.via_button=VIA diff --git a/src/main/resources/assets/viafabric/lang/pl_PL.lang b/src/main/resources/assets/viafabric/lang/pl_PL.lang new file mode 100644 index 0000000..f2d1c72 --- /dev/null +++ b/src/main/resources/assets/viafabric/lang/pl_PL.lang @@ -0,0 +1,12 @@ +gui.protocol_version_field.name=Wersja protokołu +gui.enable_client_side_button=Włącz ViaVersion +gui.enable_client_side.question=Jesteś pewien, że chcesz włączyć tryb client-side? +gui.enable_client_side.warning=Nie możemy zagwarantować, że ten mod jest dozwolony na każdym (lub jakimkolwiek) serwerze. Ten mod może powodować problemy z anty-cheatami. UŻYWASZ NA WŁASNE RYZYKO!. +gui.enable_client_side.enable=Włączyć +gui.viafabric_config.title=Konfiguracje ViaFabric +gui.client_side.enable=Włączenie po stronie klienta +gui.client_side.disable=Wyłączenie po stronie klienta +gui.ping_version.translated=VIA: %s +gui.hide_via_button.enable=Ukrycie przycisku VIA +gui.hide_via_button.disable=Pokaż przycisk VIA +gui.via_button=VIA diff --git a/src/main/resources/assets/viafabric/lang/pt_BR.lang b/src/main/resources/assets/viafabric/lang/pt_BR.lang new file mode 100644 index 0000000..6709a73 --- /dev/null +++ b/src/main/resources/assets/viafabric/lang/pt_BR.lang @@ -0,0 +1,12 @@ +gui.protocol_version_field.name=Versão do protocolo +gui.enable_client_side_button=Habilitar ViaVersion +gui.enable_client_side.question=Você tem certeza de que deseja habilitar o modo cliente? +gui.enable_client_side.warning=Não posso garantir que este mod seja permitido em todos os (ou mesmo em quaisquer) servidores. Esse poderá causar problemas com plugins anti-trapaça. USE POR SUA PRÓPRIA CONTA E RISCO. +gui.enable_client_side.enable=Habilitar +gui.viafabric_config.title=Configurações de ViaFabric +gui.client_side.enable=Habilitar modo cliente +gui.client_side.disable=Desativar modo cliente +gui.ping_version.translated=VIA: %s +gui.hide_via_button.enable=Esconder botão VIA +gui.hide_via_button.disable=Mostrar botão VIA +gui.via_button=VIA diff --git a/src/main/resources/assets/viafabric/lang/ru_RU.lang b/src/main/resources/assets/viafabric/lang/ru_RU.lang new file mode 100644 index 0000000..78f1c1f --- /dev/null +++ b/src/main/resources/assets/viafabric/lang/ru_RU.lang @@ -0,0 +1,12 @@ +gui.protocol_version_field.name=Версия протокола +gui.enable_client_side_button=Включить ViaFabric +gui.enable_client_side.question=Вы уверены, что хотите включить мод на стороне клиента? +gui.enable_client_side.warning=Я не могу гарантировать, что этот мод разрешен на любом сервере. Он может вызвать проблемы с анти-чит плагинами. ИСПОЛЬЗОВАТЬ НА СВОЙ СТРАХ И РИСК. +gui.enable_client_side.enable=Включить +gui.viafabric_config.title=Настройка ViaFabric +gui.client_side.enable=Включить на стороне клиент +gui.client_side.disable=Выключить на стороне клиента +gui.ping_version.translated=VIA: %s +gui.hide_via_button.enable=Скрыть кнопку VIA +gui.hide_via_button.disable=Показать кнопку VIA +gui.via_button=VIA diff --git a/src/main/resources/assets/viafabric/lang/tr_TR.lang b/src/main/resources/assets/viafabric/lang/tr_TR.lang new file mode 100644 index 0000000..0a3e0b6 --- /dev/null +++ b/src/main/resources/assets/viafabric/lang/tr_TR.lang @@ -0,0 +1,12 @@ +gui.protocol_version_field.name=Protokol Versiyonu +gui.enable_client_side_button=ViaVersion'u aktive et +gui.enable_client_side.question=Alıcı-tarafı modunu aktive etmek istediğinize min misiniz? +gui.enable_client_side.warning=Bu modun her ( veya herhangi ) bir sunucuda izin verildiğine garanti veremem. Bu mod anti-cheat pluginleriyle sorunlara yol açabilir. KENDİ RİSKİNİZDE KULLANIN. +gui.enable_client_side.enable=Aktive et +gui.viafabric_config.title=ViaFabric Konfigürasyonu +gui.client_side.enable=Alıcı-tarafı aktive et +gui.client_side.disable=Alıcı-tarafı devre dışı bırak +gui.ping_version.translated=VIA: %s +gui.hide_via_button.enable=VIA tuşunu gizle +gui.hide_via_button.disable=VIA tuşunu göster +gui.via_button=VIA diff --git a/src/main/resources/assets/viafabric/lang/zh_CN.lang b/src/main/resources/assets/viafabric/lang/zh_CN.lang new file mode 100644 index 0000000..ca59471 --- /dev/null +++ b/src/main/resources/assets/viafabric/lang/zh_CN.lang @@ -0,0 +1,12 @@ +gui.protocol_version_field.name=协议版本 +gui.enable_client_side_button=启用 ViaVersion +gui.enable_client_side.question=您确定要启用客户端模式? +gui.enable_client_side.warning=我无法保证所有(甚至任何一个)服务器允许您使用这个 mod。这个 mod 可能被反作弊插件作出误判。使用后果自负。 +gui.enable_client_side.enable=启用 +gui.viafabric_config.title=ViaFabric配置 +gui.client_side.enable=启用客户端 +gui.client_side.disable=禁用客户端 +gui.ping_version.translated=VIA: %s +gui.hide_via_button.enable=隐藏VIA按钮 +gui.hide_via_button.disable=显示VIA按钮 +gui.via_button=VIA diff --git a/src/main/resources/assets/viafabric/textures/gui/widgets.png b/src/main/resources/assets/viafabric/textures/gui/widgets.png new file mode 100644 index 0000000..a01d48e Binary files /dev/null and b/src/main/resources/assets/viafabric/textures/gui/widgets.png differ diff --git a/src/main/resources/assets/viafabric/textures/logo.png b/src/main/resources/assets/viafabric/textures/logo.png new file mode 100644 index 0000000..edf22ee Binary files /dev/null and b/src/main/resources/assets/viafabric/textures/logo.png differ diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info new file mode 100644 index 0000000..3b2cd3d --- /dev/null +++ b/src/main/resources/mcmod.info @@ -0,0 +1,10 @@ +[{ + "modid": "viaforge", + "name": "Via Forge", + "description": "Clientside Implemention of ViaVersion for Forge", + "version": "1.0.0.0", + "mcversion": "1.8.9", + "url": "github.com/FlorianMichael", + "authorList": ["EnZaXD", "Flori2007"], + "credits": "Ty to ViaVersion for making the Protocol Translator 'ViaVersion'" +}] \ No newline at end of file diff --git a/src/main/resources/mixins.viaforge.json b/src/main/resources/mixins.viaforge.json new file mode 100644 index 0000000..7565dce --- /dev/null +++ b/src/main/resources/mixins.viaforge.json @@ -0,0 +1,16 @@ +{ + "required": true, + "package": "com.github.creeper123123321.viafabric.injection.mixins", + "refmap": "mixins.viaforge.refmap.json", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "MixinGuiDisconnected", + "MixinGuiMainMenu", + "MixinGuiMultiplayer", + "MixinGuiScreenAddServer", + "MixinGuiScreenServerList", + "MixinMinecraft", + "MixinNetworkManager", + "MixinNetworkManagerChInit" + ] +} \ No newline at end of file