Ported to fabric

This commit is contained in:
creeper123123321 2019-01-05 19:30:41 -02:00
parent 0e2b9e8e2f
commit 35b22e17f8
No known key found for this signature in database
GPG Key ID: 0AC57D54786721D1
32 changed files with 162 additions and 250 deletions

View File

@ -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 { plugins {
id 'java'
id 'net.minecrell.licenser' version '0.4.1' 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' id 'com.palantir.git-version' version '0.12.0-rc2'
} }
apply plugin: 'net.minecraftforge.gradle.tweaker-client' group 'com.github.creeper123123321.viafabric'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'java'
group 'com.github.creeper123123321.viarift'
version gitVersion() version gitVersion()
archivesBaseName = 'ViaRift' archivesBaseName = 'ViaFabric'
sourceCompatibility = 1.8 sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
@ -32,12 +15,10 @@ targetCompatibility = 1.8
repositories { repositories {
mavenLocal() mavenLocal()
mavenCentral() mavenCentral()
maven { url 'https://libraries.minecraft.net/' } jcenter()
maven { url 'https://repo.viaversion.com/' } maven { url 'https://repo.viaversion.com/' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://www.dimdev.org/maven/' } maven { url 'https://maven.fabricmc.net/' }
maven { url 'https://jitpack.io' }
maven { url 'http://repo.strezz.org/artifactory/list/Strezz-Central' }
} }
configurations { configurations {
@ -46,16 +27,22 @@ configurations {
} }
dependencies { dependencies {
shade ('us.myles:viaversion:2.0.0-SNAPSHOT') { shade('us.myles:viaversion:2.0.0-18w50a') {
transitive = false transitive = false
changing = true 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 { jar {
configurations.shade.each { dep -> configurations.shade.each { dep ->
from(project.zipTree(dep)){ from(project.zipTree(dep)) {
//exclude 'META-INF', 'META-INF/**' //exclude 'META-INF', 'META-INF/**'
exclude 'us/myles/ViaVersion/SpongePlugin.class' exclude 'us/myles/ViaVersion/SpongePlugin.class'
exclude 'us/viaversion/libs/javassist/**' 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 { 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
}

Binary file not shown.

View File

@ -1,5 +1,6 @@
#Sat Jan 05 17:54:35 BRST 2019
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists 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

23
gradlew vendored
View File

@ -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. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"
warn () { warn ( ) {
echo "$*" echo "$*"
} }
die () { die ( ) {
echo echo
echo "$*" echo "$*"
echo echo
@ -154,19 +154,16 @@ if $cygwin ; then
esac esac
fi fi
# Escape application args # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
save () { function splitJvmOpts() {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done JVM_OPTS=("$@")
echo " "
} }
APP_ARGS=$(save "$@") eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
# 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"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong # 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")" cd "$(dirname "$0")"
fi fi
exec "$JAVACMD" "$@" exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

10
settings.gradle Normal file
View File

@ -0,0 +1,10 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}

View File

@ -22,37 +22,28 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.creeper123123321.viarift; package com.github.creeper123123321.viafabric;
import com.github.creeper123123321.viarift.commands.VRCommandHandler; import com.github.creeper123123321.viafabric.commands.VRCommandHandler;
import com.github.creeper123123321.viarift.platform.VRInjector; import com.github.creeper123123321.viafabric.platform.VRInjector;
import com.github.creeper123123321.viarift.platform.VRLoader; import com.github.creeper123123321.viafabric.platform.VRLoader;
import com.github.creeper123123321.viarift.platform.VRPlatform; import com.github.creeper123123321.viafabric.platform.VRPlatform;
import com.github.creeper123123321.viarift.util.JLoggerToLog4j; import com.github.creeper123123321.viafabric.util.JLoggerToLog4j;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import io.netty.channel.DefaultEventLoop; import io.netty.channel.DefaultEventLoop;
import io.netty.channel.EventLoop; 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.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.ViaManager;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
public class ViaRift implements InitializationListener, MinecraftStartListener { public class ViaFabric implements ModInitializer {
public static final Logger LOGGER = LogManager.getLogger("ViaRift"); public static final java.util.logging.Logger JLOGGER = new JLoggerToLog4j(LogManager.getLogger("ViaFabric"));
public static final java.util.logging.Logger JLOGGER = new JLoggerToLog4j(LOGGER); public static final EventLoop EVENT_LOOP = new DefaultEventLoop(new ThreadFactoryBuilder()
public static final EventLoop EVENT_LOOP = new DefaultEventLoop(new NamedThreadFactory("ViaRift")); .setNameFormat("ViaFabric").build());
@Override
public void onInitialization() {
MixinBootstrap.init();
Mixins.addConfiguration("mixins.viarift.main.json");
}
@Override @Override
public void onMinecraftStart() { public void onInitialize() {
Via.init(ViaManager.builder() Via.init(ViaManager.builder()
.injector(new VRInjector()) .injector(new VRInjector())
.loader(new VRLoader()) .loader(new VRLoader())

View File

@ -22,9 +22,9 @@
* SOFTWARE. * 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; import us.myles.ViaVersion.commands.ViaCommandHandler;
public class VRCommandHandler extends ViaCommandHandler { public class VRCommandHandler extends ViaCommandHandler {

View File

@ -22,7 +22,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.creeper123123321.viarift.commands.subs; package com.github.creeper123123321.viafabric.commands.subs;
import io.netty.util.ResourceLeakDetector; import io.netty.util.ResourceLeakDetector;
import us.myles.ViaVersion.api.command.ViaCommandSender; import us.myles.ViaVersion.api.command.ViaCommandSender;

View File

@ -22,24 +22,24 @@
* SOFTWARE. * 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.widget.ButtonWidget;
import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.widget.TextFieldWidget;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.api.protocol.ProtocolVersion; import us.myles.ViaVersion.api.protocol.ProtocolVersion;
public class SaveProtocolButton extends GuiButton { public class SaveProtocolButton extends ButtonWidget {
private GuiTextField textField; 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); super(id, x, y, width, height, text);
textField = tf; textField = tf;
} }
@Override @Override
public void onClick(double p_mouseClicked_1_, double p_mouseClicked_3_) { public void onPressed(double p_mouseClicked_1_, double p_mouseClicked_3_) {
super.onClick(p_mouseClicked_1_, p_mouseClicked_3_); super.onPressed(p_mouseClicked_1_, p_mouseClicked_3_);
try { try {
ProtocolRegistry.SERVER_PROTOCOL = Integer.parseInt(textField.getText()); ProtocolRegistry.SERVER_PROTOCOL = Integer.parseInt(textField.getText());
} catch (NumberFormatException e) { } catch (NumberFormatException e) {

View File

@ -22,7 +22,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.creeper123123321.viarift.handler; package com.github.creeper123123321.viafabric.handler;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;

View File

@ -22,7 +22,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.creeper123123321.viarift.handler; package com.github.creeper123123321.viafabric.handler;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;

View File

@ -22,12 +22,12 @@
* SOFTWARE. * 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.viafabric.handler.VRDecodeHandler;
import com.github.creeper123123321.viarift.handler.VREncodeHandler; import com.github.creeper123123321.viafabric.handler.VREncodeHandler;
import com.github.creeper123123321.viarift.platform.VRUserConnection; import com.github.creeper123123321.viafabric.platform.VRUserConnection;
import com.github.creeper123123321.viarift.protocol.Interceptor; import com.github.creeper123123321.viafabric.protocol.Interceptor;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.ByteToMessageDecoder; 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.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolPipeline; import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
@Mixin(targets = "net.minecraft.network.NetworkManager$1") @Mixin(targets = "net.minecraft.network.ClientConnection$1")
public class MixinNetworkManagerClientChInit { public class ClientConnectionChInit {
@Inject(method = "initChannel(Lio/netty/channel/Channel;)V", at = @At(value = "TAIL")) @Inject(method = "initChannel(Lio/netty/channel/Channel;)V", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) { private void onInitChannel(Channel channel, CallbackInfo ci) {
if (channel instanceof SocketChannel) { if (channel instanceof SocketChannel) {
UserConnection user = new VRUserConnection((SocketChannel) channel); UserConnection user = new VRUserConnection((SocketChannel) channel);

View File

@ -22,13 +22,19 @@
* SOFTWARE. * 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.viafabric.gui.multiplayer.SaveProtocolButton;
import com.github.creeper123123321.viarift.util.VersionFormatFilter; import com.github.creeper123123321.viafabric.util.VersionFormatFilter;
import net.minecraft.client.gui.*; import net.minecraft.client.gui.Gui;
import net.minecraft.client.resources.I18n; 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.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.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 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.ProtocolRegistry;
import us.myles.ViaVersion.api.protocol.ProtocolVersion; import us.myles.ViaVersion.api.protocol.ProtocolVersion;
@Mixin(GuiMultiplayer.class) @Mixin(MultiplayerGui.class)
public abstract class MixinGuiMultiplayer extends GuiScreen { public abstract class MixinMultiplayerGui extends Gui {
private GuiTextField protocolVersion; @Shadow private ServerListWidget field_3043;
private TextFieldWidget protocolVersion;
@Inject(method = "initGui", at = @At("TAIL")) @Inject(method = "onInitialized", at = @At("TAIL"))
private void onInitGui(CallbackInfo ci) { private void onOnInitialized(CallbackInfo ci) {
protocolVersion = new GuiTextField(1235, fontRenderer, this.width / 2 + 55, 8, 45, 20); protocolVersion = new TextFieldWidget(1235, fontRenderer, this.width / 2 + 55, 8, 45, 20);
protocolVersion.setText(ProtocolVersion.isRegistered(ProtocolRegistry.SERVER_PROTOCOL) protocolVersion.setText(ProtocolVersion.isRegistered(ProtocolRegistry.SERVER_PROTOCOL)
? ProtocolVersion.getProtocol(ProtocolRegistry.SERVER_PROTOCOL).getName() ? ProtocolVersion.getProtocol(ProtocolRegistry.SERVER_PROTOCOL).getName()
: Integer.toString(ProtocolRegistry.SERVER_PROTOCOL)); : Integer.toString(ProtocolRegistry.SERVER_PROTOCOL));
protocolVersion.setValidator(new VersionFormatFilter()); protocolVersion.method_1890(new VersionFormatFilter());
this.children.add(protocolVersion); this.listeners.add(protocolVersion);
addButton(new SaveProtocolButton(6356, width / 2 + 100, 8, 50, 20, 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")) @Inject(method = "draw", at = @At("TAIL"))
private void onDrawScreen(int p_1, int p_2, float p_3, CallbackInfo ci) { private void onDraw(int p_1, int p_2, float p_3, CallbackInfo ci) {
drawCenteredString(fontRenderer, I18n.format("gui.protocol_version"), this.width / 2, 12, 0xFFFFFF); drawStringCentered(fontRenderer, I18n.translate("gui.protocol_version"), this.width / 2, 12, 0xFFFFFF);
protocolVersion.drawTextField(p_1, p_2, p_3); protocolVersion.render(p_1, p_2, p_3);
} }
@Inject(method = "tick", at = @At("TAIL")) @Inject(method = "update", at = @At("TAIL"))
private void onUpdateScreen(CallbackInfo ci) { private void onUpdate(CallbackInfo ci) {
protocolVersion.tick(); protocolVersion.tick();
} }
@Inject(method = "getFocused", at = @At("RETURN"), cancellable = true) @Inject(method = "getFocused", at = @At("HEAD"), cancellable = true, remap = false)
private void onGetFocused(CallbackInfoReturnable<IGuiEventListener> cir) { private void onGetFocused(CallbackInfoReturnable<GuiEventListener> cir) {
if (protocolVersion.isFocused()) { if (protocolVersion.isFocused()) {
cir.setReturnValue(protocolVersion); cir.setReturnValue(protocolVersion);
} }

View File

@ -22,7 +22,7 @@
* SOFTWARE. * 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.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle; import us.myles.ViaVersion.api.boss.BossStyle;

View File

@ -22,7 +22,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.creeper123123321.viarift.platform; package com.github.creeper123123321.viafabric.platform;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.command.ViaCommandSender; import us.myles.ViaVersion.api.command.ViaCommandSender;

View File

@ -22,11 +22,9 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.creeper123123321.viarift.platform; package com.github.creeper123123321.viafabric.platform;
import com.github.creeper123123321.viarift.interfaces.IPatchedCPacketHandshake; import net.minecraft.client.settings.ServerEntry;
import net.minecraft.network.EnumConnectionState;
import net.minecraft.network.handshake.client.CPacketHandshake;
import us.myles.ViaVersion.api.platform.ViaInjector; import us.myles.ViaVersion.api.platform.ViaInjector;
public class VRInjector implements ViaInjector { public class VRInjector implements ViaInjector {
@ -42,11 +40,7 @@ public class VRInjector implements ViaInjector {
@Override @Override
public int getServerProtocolVersion() { public int getServerProtocolVersion() {
return ((IPatchedCPacketHandshake) new CPacketHandshake( return new ServerEntry("", "", false).protocolVersion;
"XGH to get protocol",
0,
EnumConnectionState.HANDSHAKING)
).getProtocolVersion();
} }
@Override @Override

View File

@ -22,7 +22,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.creeper123123321.viarift.platform; package com.github.creeper123123321.viafabric.platform;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.platform.ViaPlatformLoader; import us.myles.ViaVersion.api.platform.ViaPlatformLoader;

View File

@ -22,12 +22,12 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.creeper123123321.viarift.platform; package com.github.creeper123123321.viafabric.platform;
import com.github.creeper123123321.viarift.ViaRift; import com.github.creeper123123321.viafabric.ViaFabric;
import com.github.creeper123123321.viarift.protocol.Interceptor; import com.github.creeper123123321.viafabric.protocol.Interceptor;
import com.github.creeper123123321.viarift.util.FutureTaskId; import com.github.creeper123123321.viafabric.util.FutureTaskId;
import com.github.creeper123123321.viarift.util.ManagedBlockerRunnable; import com.github.creeper123123321.viafabric.util.ManagedBlockerRunnable;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.ViaAPI; import us.myles.ViaVersion.api.ViaAPI;
@ -52,16 +52,16 @@ import java.util.concurrent.TimeUnit;
import java.util.logging.Logger; import java.util.logging.Logger;
public class VRPlatform implements ViaPlatform { public class VRPlatform implements ViaPlatform {
private VRViaConfig config = new VRViaConfig(new File("config/ViaRift")); private VRViaConfig config = new VRViaConfig(new File("config/ViaFabric"));
@Override @Override
public Logger getLogger() { public Logger getLogger() {
return ViaRift.JLOGGER; return ViaFabric.JLOGGER;
} }
@Override @Override
public String getPlatformName() { public String getPlatformName() {
return "ViaRift"; return "ViaFabric";
} }
@Override @Override
@ -71,7 +71,7 @@ public class VRPlatform implements ViaPlatform {
@Override @Override
public String getPluginVersion() { public String getPluginVersion() {
return VersionInfo.VERSION + "-ViaRift"; return VersionInfo.VERSION + "-ViaFabric";
} }
@Override @Override
@ -106,7 +106,7 @@ public class VRPlatform implements ViaPlatform {
@Override @Override
public TaskId runSync(Runnable runnable, Long ticks) { public TaskId runSync(Runnable runnable, Long ticks) {
return new FutureTaskId( return new FutureTaskId(
ViaRift.EVENT_LOOP ViaFabric.EVENT_LOOP
.schedule(runnable, ticks * 50, TimeUnit.SECONDS) .schedule(runnable, ticks * 50, TimeUnit.SECONDS)
.addListener(future -> { .addListener(future -> {
if (!future.isSuccess()) { if (!future.isSuccess()) {
@ -119,7 +119,7 @@ public class VRPlatform implements ViaPlatform {
@Override @Override
public TaskId runRepeatingSync(Runnable runnable, Long ticks) { public TaskId runRepeatingSync(Runnable runnable, Long ticks) {
return new FutureTaskId( return new FutureTaskId(
ViaRift.EVENT_LOOP ViaFabric.EVENT_LOOP
.scheduleAtFixedRate(runnable, 0, ticks * 50, TimeUnit.SECONDS) .scheduleAtFixedRate(runnable, 0, ticks * 50, TimeUnit.SECONDS)
.addListener(future -> { .addListener(future -> {
if (!future.isSuccess()) { if (!future.isSuccess()) {

View File

@ -22,7 +22,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.creeper123123321.viarift.platform; package com.github.creeper123123321.viafabric.platform;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel; import io.netty.channel.Channel;

View File

@ -22,7 +22,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.creeper123123321.viarift.platform; package com.github.creeper123123321.viafabric.platform;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;

View File

@ -22,7 +22,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.creeper123123321.viarift.platform; package com.github.creeper123123321.viafabric.platform;
import us.myles.ViaVersion.api.ViaVersionConfig; import us.myles.ViaVersion.api.ViaVersionConfig;
import us.myles.ViaVersion.util.Config; import us.myles.ViaVersion.util.Config;

View File

@ -22,9 +22,9 @@
* SOFTWARE. * 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.PacketWrapper;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
@ -48,10 +48,10 @@ public class Interceptor extends Protocol {
public void handle(PacketWrapper packetWrapper) throws Exception { public void handle(PacketWrapper packetWrapper) throws Exception {
String msg = packetWrapper.get(Type.STRING, 0); String msg = packetWrapper.get(Type.STRING, 0);
ProtocolInfo info = packetWrapper.user().get(ProtocolInfo.class); ProtocolInfo info = packetWrapper.user().get(ProtocolInfo.class);
if (msg.startsWith("/viarift")) { if (msg.startsWith("/viafabric")) {
Via.getManager().getCommandHandler().onCommand( Via.getManager().getCommandHandler().onCommand(
new VRCommandSender(info.getUuid(), info.getUsername()), 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(); packetWrapper.cancel();
} }

View File

@ -22,7 +22,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.creeper123123321.viarift.util; package com.github.creeper123123321.viafabric.util;
import us.myles.ViaVersion.api.platform.TaskId; import us.myles.ViaVersion.api.platform.TaskId;

View File

@ -22,7 +22,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.creeper123123321.viarift.util; package com.github.creeper123123321.viafabric.util;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.logging.Level; import java.util.logging.Level;

View File

@ -22,7 +22,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.creeper123123321.viarift.util; package com.github.creeper123123321.viafabric.util;
import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinPool;

View File

@ -22,7 +22,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.creeper123123321.viarift.util; package com.github.creeper123123321.viafabric.util;
import us.myles.ViaVersion.api.protocol.ProtocolVersion; import us.myles.ViaVersion.api.protocol.ProtocolVersion;

View File

@ -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();
}

View File

@ -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;
}
}

View File

@ -0,0 +1,12 @@
{
"id": "viafabric",
"name": "ViaFabric",
"side": "client",
"version": "?",
"initializers": [
"com.github.creeper123123321.viafabric.ViaFabric"
],
"mixins": {
"client": "mixins.viafabric.main.json"
}
}

View File

@ -0,0 +1,14 @@
{
"required": true,
"compatibilityLevel": "JAVA_8",
"package": "com.github.creeper123123321.viafabric.mixin",
"mixins": [
],
"client": [
"client.ClientConnectionChInit",
"client.MixinMultiplayerGui"
],
"injectors": {
"defaultRequire": 1
}
}

View File

@ -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"
]
}

View File

@ -1,10 +0,0 @@
{
"id": "viarift",
"name": "ViaRift",
"authors": [
"creeper123123321"
],
"listeners": [
"com.github.creeper123123321.viarift.ViaRift"
]
}