diff --git a/build.gradle b/build.gradle index 3f91a51..3047d6e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,30 +1,13 @@ -buildscript { - repositories { - mavenCentral() - maven { url 'https://www.jitpack.io' } - maven { url 'https://files.minecraftforge.net/maven' } - jcenter() - maven { url 'https://www.dimdev.org/maven/' } - maven { url 'https://repo.spongepowered.org/maven/' } - } - dependencies { - classpath 'com.github.Chocohead:ForgeGradle:moderniser-SNAPSHOT' - classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT' - } -} - plugins { + id 'java' id 'net.minecrell.licenser' version '0.4.1' + id 'fabric-loom' version '0.2.0-SNAPSHOT' id 'com.palantir.git-version' version '0.12.0-rc2' } -apply plugin: 'net.minecraftforge.gradle.tweaker-client' -apply plugin: 'org.spongepowered.mixin' -apply plugin: 'java' - -group 'com.github.creeper123123321.viarift' +group 'com.github.creeper123123321.viafabric' version gitVersion() -archivesBaseName = 'ViaRift' +archivesBaseName = 'ViaFabric' sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -32,12 +15,10 @@ targetCompatibility = 1.8 repositories { mavenLocal() mavenCentral() - maven { url 'https://libraries.minecraft.net/' } + jcenter() maven { url 'https://repo.viaversion.com/' } maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } - maven { url 'https://www.dimdev.org/maven/' } - maven { url 'https://jitpack.io' } - maven { url 'http://repo.strezz.org/artifactory/list/Strezz-Central' } + maven { url 'https://maven.fabricmc.net/' } } configurations { @@ -46,16 +27,22 @@ configurations { } dependencies { - shade ('us.myles:viaversion:2.0.0-SNAPSHOT') { + shade('us.myles:viaversion:2.0.0-18w50a') { transitive = false changing = true } - implementation 'com.github.Chocohead:Rift:jitpack-SNAPSHOT:dev' + + minecraft "com.mojang:minecraft:18w50a" + mappings "net.fabricmc:yarn:18w50a.64" + modCompile "net.fabricmc:fabric-loader:0.3.0.74" + + // Fabric API. This is technically optional, but you probably want it anyway. + modCompile "net.fabricmc:fabric:0.1.2.63" } jar { configurations.shade.each { dep -> - from(project.zipTree(dep)){ + from(project.zipTree(dep)) { //exclude 'META-INF', 'META-INF/**' exclude 'us/myles/ViaVersion/SpongePlugin.class' exclude 'us/viaversion/libs/javassist/**' @@ -64,20 +51,13 @@ jar { } } -reobf { - jar { - extraLines += "PK: us/myles com/github/creeper123123321/viarift/shaded/us/myles" - } -} - -mixin { - defaultObfuscationEnv notch - add sourceSets.main, 'mixins.viarift.refmap.json' -} - minecraft { - version = '1.13.2' - mappings = 'snapshot_20181130' - runDir = 'run' - tweakClass = 'org.dimdev.riftloader.launch.RiftLoaderClientTweaker' } + +// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task +// if it is present. +// If you remove this task, sources will not be generated. +task sourcesJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 01b8bf6..deedc7f 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bd24854..edb14bc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Sat Jan 05 17:54:35 BRST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip diff --git a/gradlew b/gradlew index cccdd3d..9aa616c 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash ############################################################################## ## @@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS="" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn () { +warn ( ) { echo "$*" } -die () { +die ( ) { echo echo "$*" echo @@ -154,19 +154,16 @@ if $cygwin ; then esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") } -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then +if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then cd "$(dirname "$0")" fi -exec "$JAVACMD" "$@" +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..5b60df3 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +pluginManagement { + repositories { + jcenter() + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + gradlePluginPortal() + } +} diff --git a/src/main/java/com/github/creeper123123321/viarift/ViaRift.java b/src/main/java/com/github/creeper123123321/viafabric/ViaFabric.java similarity index 62% rename from src/main/java/com/github/creeper123123321/viarift/ViaRift.java rename to src/main/java/com/github/creeper123123321/viafabric/ViaFabric.java index 9bef991..e1beea0 100644 --- a/src/main/java/com/github/creeper123123321/viarift/ViaRift.java +++ b/src/main/java/com/github/creeper123123321/viafabric/ViaFabric.java @@ -22,37 +22,28 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift; +package com.github.creeper123123321.viafabric; -import com.github.creeper123123321.viarift.commands.VRCommandHandler; -import com.github.creeper123123321.viarift.platform.VRInjector; -import com.github.creeper123123321.viarift.platform.VRLoader; -import com.github.creeper123123321.viarift.platform.VRPlatform; -import com.github.creeper123123321.viarift.util.JLoggerToLog4j; +import com.github.creeper123123321.viafabric.commands.VRCommandHandler; +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 io.netty.channel.DefaultEventLoop; import io.netty.channel.EventLoop; -import net.minecraft.util.NamedThreadFactory; +import net.fabricmc.api.ModInitializer; import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.dimdev.rift.listener.MinecraftStartListener; -import org.dimdev.riftloader.listener.InitializationListener; -import org.spongepowered.asm.launch.MixinBootstrap; -import org.spongepowered.asm.mixin.Mixins; import us.myles.ViaVersion.ViaManager; import us.myles.ViaVersion.api.Via; -public class ViaRift implements InitializationListener, MinecraftStartListener { - public static final Logger LOGGER = LogManager.getLogger("ViaRift"); - public static final java.util.logging.Logger JLOGGER = new JLoggerToLog4j(LOGGER); - public static final EventLoop EVENT_LOOP = new DefaultEventLoop(new NamedThreadFactory("ViaRift")); - @Override - public void onInitialization() { - MixinBootstrap.init(); - Mixins.addConfiguration("mixins.viarift.main.json"); - } +public class ViaFabric implements ModInitializer { + public static final java.util.logging.Logger JLOGGER = new JLoggerToLog4j(LogManager.getLogger("ViaFabric")); + public static final EventLoop EVENT_LOOP = new DefaultEventLoop(new ThreadFactoryBuilder() + .setNameFormat("ViaFabric").build()); @Override - public void onMinecraftStart() { + public void onInitialize() { Via.init(ViaManager.builder() .injector(new VRInjector()) .loader(new VRLoader()) diff --git a/src/main/java/com/github/creeper123123321/viarift/commands/VRCommandHandler.java b/src/main/java/com/github/creeper123123321/viafabric/commands/VRCommandHandler.java similarity index 91% rename from src/main/java/com/github/creeper123123321/viarift/commands/VRCommandHandler.java rename to src/main/java/com/github/creeper123123321/viafabric/commands/VRCommandHandler.java index 5ea0325..1344f1b 100644 --- a/src/main/java/com/github/creeper123123321/viarift/commands/VRCommandHandler.java +++ b/src/main/java/com/github/creeper123123321/viafabric/commands/VRCommandHandler.java @@ -22,9 +22,9 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.commands; +package com.github.creeper123123321.viafabric.commands; -import com.github.creeper123123321.viarift.commands.subs.LeakDetectSubCommand; +import com.github.creeper123123321.viafabric.commands.subs.LeakDetectSubCommand; import us.myles.ViaVersion.commands.ViaCommandHandler; public class VRCommandHandler extends ViaCommandHandler { diff --git a/src/main/java/com/github/creeper123123321/viarift/commands/subs/LeakDetectSubCommand.java b/src/main/java/com/github/creeper123123321/viafabric/commands/subs/LeakDetectSubCommand.java similarity index 97% rename from src/main/java/com/github/creeper123123321/viarift/commands/subs/LeakDetectSubCommand.java rename to src/main/java/com/github/creeper123123321/viafabric/commands/subs/LeakDetectSubCommand.java index d87b80c..2ef1bc8 100644 --- a/src/main/java/com/github/creeper123123321/viarift/commands/subs/LeakDetectSubCommand.java +++ b/src/main/java/com/github/creeper123123321/viafabric/commands/subs/LeakDetectSubCommand.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.commands.subs; +package com.github.creeper123123321.viafabric.commands.subs; import io.netty.util.ResourceLeakDetector; import us.myles.ViaVersion.api.command.ViaCommandSender; diff --git a/src/main/java/com/github/creeper123123321/viarift/gui/multiplayer/SaveProtocolButton.java b/src/main/java/com/github/creeper123123321/viafabric/gui/multiplayer/SaveProtocolButton.java similarity index 81% rename from src/main/java/com/github/creeper123123321/viarift/gui/multiplayer/SaveProtocolButton.java rename to src/main/java/com/github/creeper123123321/viafabric/gui/multiplayer/SaveProtocolButton.java index 5d98d26..506b97b 100644 --- a/src/main/java/com/github/creeper123123321/viarift/gui/multiplayer/SaveProtocolButton.java +++ b/src/main/java/com/github/creeper123123321/viafabric/gui/multiplayer/SaveProtocolButton.java @@ -22,24 +22,24 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.gui.multiplayer; +package com.github.creeper123123321.viafabric.gui.multiplayer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiTextField; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.gui.widget.TextFieldWidget; import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.protocol.ProtocolVersion; -public class SaveProtocolButton extends GuiButton { - private GuiTextField textField; +public class SaveProtocolButton extends ButtonWidget { + private TextFieldWidget textField; - public SaveProtocolButton(int id, int x, int y, int width, int height, String text, GuiTextField tf) { + public SaveProtocolButton(int id, int x, int y, int width, int height, String text, TextFieldWidget tf) { super(id, x, y, width, height, text); textField = tf; } @Override - public void onClick(double p_mouseClicked_1_, double p_mouseClicked_3_) { - super.onClick(p_mouseClicked_1_, p_mouseClicked_3_); + public void onPressed(double p_mouseClicked_1_, double p_mouseClicked_3_) { + super.onPressed(p_mouseClicked_1_, p_mouseClicked_3_); try { ProtocolRegistry.SERVER_PROTOCOL = Integer.parseInt(textField.getText()); } catch (NumberFormatException e) { diff --git a/src/main/java/com/github/creeper123123321/viarift/handler/VRDecodeHandler.java b/src/main/java/com/github/creeper123123321/viafabric/handler/VRDecodeHandler.java similarity index 98% rename from src/main/java/com/github/creeper123123321/viarift/handler/VRDecodeHandler.java rename to src/main/java/com/github/creeper123123321/viafabric/handler/VRDecodeHandler.java index 9bbc00c..a6fb467 100644 --- a/src/main/java/com/github/creeper123123321/viarift/handler/VRDecodeHandler.java +++ b/src/main/java/com/github/creeper123123321/viafabric/handler/VRDecodeHandler.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.handler; +package com.github.creeper123123321.viafabric.handler; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; diff --git a/src/main/java/com/github/creeper123123321/viarift/handler/VREncodeHandler.java b/src/main/java/com/github/creeper123123321/viafabric/handler/VREncodeHandler.java similarity index 98% rename from src/main/java/com/github/creeper123123321/viarift/handler/VREncodeHandler.java rename to src/main/java/com/github/creeper123123321/viafabric/handler/VREncodeHandler.java index 8cfca43..260d0e8 100644 --- a/src/main/java/com/github/creeper123123321/viarift/handler/VREncodeHandler.java +++ b/src/main/java/com/github/creeper123123321/viafabric/handler/VREncodeHandler.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.handler; +package com.github.creeper123123321.viafabric.handler; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; diff --git a/src/main/java/com/github/creeper123123321/viarift/mixin/MixinNetworkManagerClientChInit.java b/src/main/java/com/github/creeper123123321/viafabric/mixin/client/ClientConnectionChInit.java similarity index 83% rename from src/main/java/com/github/creeper123123321/viarift/mixin/MixinNetworkManagerClientChInit.java rename to src/main/java/com/github/creeper123123321/viafabric/mixin/client/ClientConnectionChInit.java index 0e113d8..42e9861 100644 --- a/src/main/java/com/github/creeper123123321/viarift/mixin/MixinNetworkManagerClientChInit.java +++ b/src/main/java/com/github/creeper123123321/viafabric/mixin/client/ClientConnectionChInit.java @@ -22,12 +22,12 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.mixin; +package com.github.creeper123123321.viafabric.mixin.client; -import com.github.creeper123123321.viarift.handler.VRDecodeHandler; -import com.github.creeper123123321.viarift.handler.VREncodeHandler; -import com.github.creeper123123321.viarift.platform.VRUserConnection; -import com.github.creeper123123321.viarift.protocol.Interceptor; +import com.github.creeper123123321.viafabric.handler.VRDecodeHandler; +import com.github.creeper123123321.viafabric.handler.VREncodeHandler; +import com.github.creeper123123321.viafabric.platform.VRUserConnection; +import com.github.creeper123123321.viafabric.protocol.Interceptor; import io.netty.channel.Channel; import io.netty.channel.socket.SocketChannel; import io.netty.handler.codec.ByteToMessageDecoder; @@ -39,9 +39,9 @@ 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$1") -public class MixinNetworkManagerClientChInit { - @Inject(method = "initChannel(Lio/netty/channel/Channel;)V", at = @At(value = "TAIL")) +@Mixin(targets = "net.minecraft.network.ClientConnection$1") +public class ClientConnectionChInit { + @Inject(method = "initChannel(Lio/netty/channel/Channel;)V", at = @At(value = "TAIL"), remap = false) private void onInitChannel(Channel channel, CallbackInfo ci) { if (channel instanceof SocketChannel) { UserConnection user = new VRUserConnection((SocketChannel) channel); diff --git a/src/main/java/com/github/creeper123123321/viarift/mixin/client/MixinGuiMultiplayer.java b/src/main/java/com/github/creeper123123321/viafabric/mixin/client/MixinMultiplayerGui.java similarity index 54% rename from src/main/java/com/github/creeper123123321/viarift/mixin/client/MixinGuiMultiplayer.java rename to src/main/java/com/github/creeper123123321/viafabric/mixin/client/MixinMultiplayerGui.java index 034bd8c..583b037 100644 --- a/src/main/java/com/github/creeper123123321/viarift/mixin/client/MixinGuiMultiplayer.java +++ b/src/main/java/com/github/creeper123123321/viafabric/mixin/client/MixinMultiplayerGui.java @@ -22,13 +22,19 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.mixin.client; +package com.github.creeper123123321.viafabric.mixin.client; -import com.github.creeper123123321.viarift.gui.multiplayer.SaveProtocolButton; -import com.github.creeper123123321.viarift.util.VersionFormatFilter; -import net.minecraft.client.gui.*; -import net.minecraft.client.resources.I18n; +import com.github.creeper123123321.viafabric.gui.multiplayer.SaveProtocolButton; +import com.github.creeper123123321.viafabric.util.VersionFormatFilter; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiEventListener; +import net.minecraft.client.gui.menu.MultiplayerGui; +import net.minecraft.client.gui.widget.ServerListWidget; +import net.minecraft.client.gui.widget.TextFieldWidget; +import net.minecraft.client.resource.language.I18n; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -36,35 +42,36 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.protocol.ProtocolVersion; -@Mixin(GuiMultiplayer.class) -public abstract class MixinGuiMultiplayer extends GuiScreen { - private GuiTextField protocolVersion; +@Mixin(MultiplayerGui.class) +public abstract class MixinMultiplayerGui extends Gui { + @Shadow private ServerListWidget field_3043; + private TextFieldWidget protocolVersion; - @Inject(method = "initGui", at = @At("TAIL")) - private void onInitGui(CallbackInfo ci) { - protocolVersion = new GuiTextField(1235, fontRenderer, this.width / 2 + 55, 8, 45, 20); + @Inject(method = "onInitialized", at = @At("TAIL")) + private void onOnInitialized(CallbackInfo ci) { + protocolVersion = new TextFieldWidget(1235, fontRenderer, this.width / 2 + 55, 8, 45, 20); protocolVersion.setText(ProtocolVersion.isRegistered(ProtocolRegistry.SERVER_PROTOCOL) ? ProtocolVersion.getProtocol(ProtocolRegistry.SERVER_PROTOCOL).getName() : Integer.toString(ProtocolRegistry.SERVER_PROTOCOL)); - protocolVersion.setValidator(new VersionFormatFilter()); - this.children.add(protocolVersion); + protocolVersion.method_1890(new VersionFormatFilter()); + this.listeners.add(protocolVersion); addButton(new SaveProtocolButton(6356, width / 2 + 100, 8, 50, 20, - I18n.format("gui.save_protocol_version"), protocolVersion)); + I18n.translate("gui.save_protocol_version"), protocolVersion)); } - @Inject(method = "render", at = @At("TAIL")) - private void onDrawScreen(int p_1, int p_2, float p_3, CallbackInfo ci) { - drawCenteredString(fontRenderer, I18n.format("gui.protocol_version"), this.width / 2, 12, 0xFFFFFF); - protocolVersion.drawTextField(p_1, p_2, p_3); + @Inject(method = "draw", at = @At("TAIL")) + private void onDraw(int p_1, int p_2, float p_3, CallbackInfo ci) { + drawStringCentered(fontRenderer, I18n.translate("gui.protocol_version"), this.width / 2, 12, 0xFFFFFF); + protocolVersion.render(p_1, p_2, p_3); } - @Inject(method = "tick", at = @At("TAIL")) - private void onUpdateScreen(CallbackInfo ci) { + @Inject(method = "update", at = @At("TAIL")) + private void onUpdate(CallbackInfo ci) { protocolVersion.tick(); } - @Inject(method = "getFocused", at = @At("RETURN"), cancellable = true) - private void onGetFocused(CallbackInfoReturnable cir) { + @Inject(method = "getFocused", at = @At("HEAD"), cancellable = true, remap = false) + private void onGetFocused(CallbackInfoReturnable cir) { if (protocolVersion.isFocused()) { cir.setReturnValue(protocolVersion); } diff --git a/src/main/java/com/github/creeper123123321/viarift/platform/VRBossBar.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRBossBar.java similarity index 96% rename from src/main/java/com/github/creeper123123321/viarift/platform/VRBossBar.java rename to src/main/java/com/github/creeper123123321/viafabric/platform/VRBossBar.java index 9918786..3d9fb65 100644 --- a/src/main/java/com/github/creeper123123321/viarift/platform/VRBossBar.java +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRBossBar.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.platform; +package com.github.creeper123123321.viafabric.platform; import us.myles.ViaVersion.api.boss.BossColor; import us.myles.ViaVersion.api.boss.BossStyle; diff --git a/src/main/java/com/github/creeper123123321/viarift/platform/VRCommandSender.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRCommandSender.java similarity index 97% rename from src/main/java/com/github/creeper123123321/viarift/platform/VRCommandSender.java rename to src/main/java/com/github/creeper123123321/viafabric/platform/VRCommandSender.java index 0050baa..3180c88 100644 --- a/src/main/java/com/github/creeper123123321/viarift/platform/VRCommandSender.java +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRCommandSender.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.platform; +package com.github.creeper123123321.viafabric.platform; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.command.ViaCommandSender; diff --git a/src/main/java/com/github/creeper123123321/viarift/platform/VRInjector.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRInjector.java similarity index 79% rename from src/main/java/com/github/creeper123123321/viarift/platform/VRInjector.java rename to src/main/java/com/github/creeper123123321/viafabric/platform/VRInjector.java index fba0c5f..7e33f7f 100644 --- a/src/main/java/com/github/creeper123123321/viarift/platform/VRInjector.java +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRInjector.java @@ -22,11 +22,9 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.platform; +package com.github.creeper123123321.viafabric.platform; -import com.github.creeper123123321.viarift.interfaces.IPatchedCPacketHandshake; -import net.minecraft.network.EnumConnectionState; -import net.minecraft.network.handshake.client.CPacketHandshake; +import net.minecraft.client.settings.ServerEntry; import us.myles.ViaVersion.api.platform.ViaInjector; public class VRInjector implements ViaInjector { @@ -42,11 +40,7 @@ public class VRInjector implements ViaInjector { @Override public int getServerProtocolVersion() { - return ((IPatchedCPacketHandshake) new CPacketHandshake( - "XGH to get protocol", - 0, - EnumConnectionState.HANDSHAKING) - ).getProtocolVersion(); + return new ServerEntry("", "", false).protocolVersion; } @Override diff --git a/src/main/java/com/github/creeper123123321/viarift/platform/VRLoader.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRLoader.java similarity index 96% rename from src/main/java/com/github/creeper123123321/viarift/platform/VRLoader.java rename to src/main/java/com/github/creeper123123321/viafabric/platform/VRLoader.java index f44e391..8c930cf 100644 --- a/src/main/java/com/github/creeper123123321/viarift/platform/VRLoader.java +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRLoader.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.platform; +package com.github.creeper123123321.viafabric.platform; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.platform.ViaPlatformLoader; diff --git a/src/main/java/com/github/creeper123123321/viarift/platform/VRPlatform.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRPlatform.java similarity index 92% rename from src/main/java/com/github/creeper123123321/viarift/platform/VRPlatform.java rename to src/main/java/com/github/creeper123123321/viafabric/platform/VRPlatform.java index 552adc9..3a8ff7f 100644 --- a/src/main/java/com/github/creeper123123321/viarift/platform/VRPlatform.java +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRPlatform.java @@ -22,12 +22,12 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.platform; +package com.github.creeper123123321.viafabric.platform; -import com.github.creeper123123321.viarift.ViaRift; -import com.github.creeper123123321.viarift.protocol.Interceptor; -import com.github.creeper123123321.viarift.util.FutureTaskId; -import com.github.creeper123123321.viarift.util.ManagedBlockerRunnable; +import com.github.creeper123123321.viafabric.ViaFabric; +import com.github.creeper123123321.viafabric.protocol.Interceptor; +import com.github.creeper123123321.viafabric.util.FutureTaskId; +import com.github.creeper123123321.viafabric.util.ManagedBlockerRunnable; import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.ViaAPI; @@ -52,16 +52,16 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Logger; public class VRPlatform implements ViaPlatform { - private VRViaConfig config = new VRViaConfig(new File("config/ViaRift")); + private VRViaConfig config = new VRViaConfig(new File("config/ViaFabric")); @Override public Logger getLogger() { - return ViaRift.JLOGGER; + return ViaFabric.JLOGGER; } @Override public String getPlatformName() { - return "ViaRift"; + return "ViaFabric"; } @Override @@ -71,7 +71,7 @@ public class VRPlatform implements ViaPlatform { @Override public String getPluginVersion() { - return VersionInfo.VERSION + "-ViaRift"; + return VersionInfo.VERSION + "-ViaFabric"; } @Override @@ -106,7 +106,7 @@ public class VRPlatform implements ViaPlatform { @Override public TaskId runSync(Runnable runnable, Long ticks) { return new FutureTaskId( - ViaRift.EVENT_LOOP + ViaFabric.EVENT_LOOP .schedule(runnable, ticks * 50, TimeUnit.SECONDS) .addListener(future -> { if (!future.isSuccess()) { @@ -119,7 +119,7 @@ public class VRPlatform implements ViaPlatform { @Override public TaskId runRepeatingSync(Runnable runnable, Long ticks) { return new FutureTaskId( - ViaRift.EVENT_LOOP + ViaFabric.EVENT_LOOP .scheduleAtFixedRate(runnable, 0, ticks * 50, TimeUnit.SECONDS) .addListener(future -> { if (!future.isSuccess()) { diff --git a/src/main/java/com/github/creeper123123321/viarift/platform/VRUserConnection.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRUserConnection.java similarity index 98% rename from src/main/java/com/github/creeper123123321/viarift/platform/VRUserConnection.java rename to src/main/java/com/github/creeper123123321/viafabric/platform/VRUserConnection.java index 41b9f09..ee27754 100644 --- a/src/main/java/com/github/creeper123123321/viarift/platform/VRUserConnection.java +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRUserConnection.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.platform; +package com.github.creeper123123321.viafabric.platform; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; diff --git a/src/main/java/com/github/creeper123123321/viarift/platform/VRViaAPI.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRViaAPI.java similarity index 98% rename from src/main/java/com/github/creeper123123321/viarift/platform/VRViaAPI.java rename to src/main/java/com/github/creeper123123321/viafabric/platform/VRViaAPI.java index 70fae2a..c87c68c 100644 --- a/src/main/java/com/github/creeper123123321/viarift/platform/VRViaAPI.java +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRViaAPI.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.platform; +package com.github.creeper123123321.viafabric.platform; import io.netty.buffer.ByteBuf; import us.myles.ViaVersion.api.Via; diff --git a/src/main/java/com/github/creeper123123321/viarift/platform/VRViaConfig.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRViaConfig.java similarity index 99% rename from src/main/java/com/github/creeper123123321/viarift/platform/VRViaConfig.java rename to src/main/java/com/github/creeper123123321/viafabric/platform/VRViaConfig.java index ba65bd3..88595de 100644 --- a/src/main/java/com/github/creeper123123321/viarift/platform/VRViaConfig.java +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRViaConfig.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.platform; +package com.github.creeper123123321.viafabric.platform; import us.myles.ViaVersion.api.ViaVersionConfig; import us.myles.ViaVersion.util.Config; diff --git a/src/main/java/com/github/creeper123123321/viarift/protocol/Interceptor.java b/src/main/java/com/github/creeper123123321/viafabric/protocol/Interceptor.java similarity index 90% rename from src/main/java/com/github/creeper123123321/viarift/protocol/Interceptor.java rename to src/main/java/com/github/creeper123123321/viafabric/protocol/Interceptor.java index 5c07db5..e26ad7d 100644 --- a/src/main/java/com/github/creeper123123321/viarift/protocol/Interceptor.java +++ b/src/main/java/com/github/creeper123123321/viafabric/protocol/Interceptor.java @@ -22,9 +22,9 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.protocol; +package com.github.creeper123123321.viafabric.protocol; -import com.github.creeper123123321.viarift.platform.VRCommandSender; +import com.github.creeper123123321.viafabric.platform.VRCommandSender; import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.data.UserConnection; @@ -48,10 +48,10 @@ public class Interceptor extends Protocol { public void handle(PacketWrapper packetWrapper) throws Exception { String msg = packetWrapper.get(Type.STRING, 0); ProtocolInfo info = packetWrapper.user().get(ProtocolInfo.class); - if (msg.startsWith("/viarift")) { + if (msg.startsWith("/viafabric")) { Via.getManager().getCommandHandler().onCommand( new VRCommandSender(info.getUuid(), info.getUsername()), - msg.length() == 8 ? new String[0] : msg.substring(9).split(" ", -1) + msg.length() == 10 ? new String[0] : msg.substring(9).split(" ", -1) ); packetWrapper.cancel(); } diff --git a/src/main/java/com/github/creeper123123321/viarift/util/FutureTaskId.java b/src/main/java/com/github/creeper123123321/viafabric/util/FutureTaskId.java similarity index 96% rename from src/main/java/com/github/creeper123123321/viarift/util/FutureTaskId.java rename to src/main/java/com/github/creeper123123321/viafabric/util/FutureTaskId.java index e457969..d6a5b94 100644 --- a/src/main/java/com/github/creeper123123321/viarift/util/FutureTaskId.java +++ b/src/main/java/com/github/creeper123123321/viafabric/util/FutureTaskId.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.util; +package com.github.creeper123123321.viafabric.util; import us.myles.ViaVersion.api.platform.TaskId; diff --git a/src/main/java/com/github/creeper123123321/viarift/util/JLoggerToLog4j.java b/src/main/java/com/github/creeper123123321/viafabric/util/JLoggerToLog4j.java similarity index 98% rename from src/main/java/com/github/creeper123123321/viarift/util/JLoggerToLog4j.java rename to src/main/java/com/github/creeper123123321/viafabric/util/JLoggerToLog4j.java index be93818..c8bce7a 100644 --- a/src/main/java/com/github/creeper123123321/viarift/util/JLoggerToLog4j.java +++ b/src/main/java/com/github/creeper123123321/viafabric/util/JLoggerToLog4j.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.util; +package com.github.creeper123123321.viafabric.util; import java.text.MessageFormat; import java.util.logging.Level; diff --git a/src/main/java/com/github/creeper123123321/viarift/util/ManagedBlockerRunnable.java b/src/main/java/com/github/creeper123123321/viafabric/util/ManagedBlockerRunnable.java similarity index 96% rename from src/main/java/com/github/creeper123123321/viarift/util/ManagedBlockerRunnable.java rename to src/main/java/com/github/creeper123123321/viafabric/util/ManagedBlockerRunnable.java index 399314f..f24406d 100644 --- a/src/main/java/com/github/creeper123123321/viarift/util/ManagedBlockerRunnable.java +++ b/src/main/java/com/github/creeper123123321/viafabric/util/ManagedBlockerRunnable.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.util; +package com.github.creeper123123321.viafabric.util; import java.util.concurrent.ForkJoinPool; diff --git a/src/main/java/com/github/creeper123123321/viarift/util/VersionFormatFilter.java b/src/main/java/com/github/creeper123123321/viafabric/util/VersionFormatFilter.java similarity index 97% rename from src/main/java/com/github/creeper123123321/viarift/util/VersionFormatFilter.java rename to src/main/java/com/github/creeper123123321/viafabric/util/VersionFormatFilter.java index c467af7..7214c46 100644 --- a/src/main/java/com/github/creeper123123321/viarift/util/VersionFormatFilter.java +++ b/src/main/java/com/github/creeper123123321/viafabric/util/VersionFormatFilter.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package com.github.creeper123123321.viarift.util; +package com.github.creeper123123321.viafabric.util; import us.myles.ViaVersion.api.protocol.ProtocolVersion; diff --git a/src/main/java/com/github/creeper123123321/viarift/interfaces/IPatchedCPacketHandshake.java b/src/main/java/com/github/creeper123123321/viarift/interfaces/IPatchedCPacketHandshake.java deleted file mode 100644 index 5942dc2..0000000 --- a/src/main/java/com/github/creeper123123321/viarift/interfaces/IPatchedCPacketHandshake.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2018 creeper123123321 and 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.viarift.interfaces; - -public interface IPatchedCPacketHandshake { - int getProtocolVersion(); -} diff --git a/src/main/java/com/github/creeper123123321/viarift/mixin/client/MixinCPacketHandshake.java b/src/main/java/com/github/creeper123123321/viarift/mixin/client/MixinCPacketHandshake.java deleted file mode 100644 index 93673b2..0000000 --- a/src/main/java/com/github/creeper123123321/viarift/mixin/client/MixinCPacketHandshake.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2018 creeper123123321 and 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.viarift.mixin.client; - -import com.github.creeper123123321.viarift.interfaces.IPatchedCPacketHandshake; -import net.minecraft.network.handshake.client.CPacketHandshake; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(CPacketHandshake.class) -public class MixinCPacketHandshake implements IPatchedCPacketHandshake { - @Shadow private int protocolVersion; - - @Override - public int getProtocolVersion() { - return protocolVersion; - } -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..9342670 --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,12 @@ +{ + "id": "viafabric", + "name": "ViaFabric", + "side": "client", + "version": "?", + "initializers": [ + "com.github.creeper123123321.viafabric.ViaFabric" + ], + "mixins": { + "client": "mixins.viafabric.main.json" + } +} diff --git a/src/main/resources/mixins.viafabric.main.json b/src/main/resources/mixins.viafabric.main.json new file mode 100644 index 0000000..ce62e37 --- /dev/null +++ b/src/main/resources/mixins.viafabric.main.json @@ -0,0 +1,14 @@ +{ + "required": true, + "compatibilityLevel": "JAVA_8", + "package": "com.github.creeper123123321.viafabric.mixin", + "mixins": [ + ], + "client": [ + "client.ClientConnectionChInit", + "client.MixinMultiplayerGui" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/src/main/resources/mixins.viarift.main.json b/src/main/resources/mixins.viarift.main.json deleted file mode 100644 index 0c15217..0000000 --- a/src/main/resources/mixins.viarift.main.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "required": true, - "minVersion": "0.7.7", - "compatibilityLevel": "JAVA_8", - "target": "@env(DEFAULT)", - "package": "com.github.creeper123123321.viarift.mixin", - "refmap": "mixins.viarift.refmap.json", - "mixins": [ - "MixinNetworkManagerClientChInit" - ], - "client": [ - "client.MixinGuiMultiplayer", - "client.MixinCPacketHandshake" - ] -} diff --git a/src/main/resources/riftmod.json b/src/main/resources/riftmod.json deleted file mode 100644 index 560636b..0000000 --- a/src/main/resources/riftmod.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "id": "viarift", - "name": "ViaRift", - "authors": [ - "creeper123123321" - ], - "listeners": [ - "com.github.creeper123123321.viarift.ViaRift" - ] -}