mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-11-21 11:35:16 +01:00
Ported to fabric
This commit is contained in:
parent
0e2b9e8e2f
commit
35b22e17f8
64
build.gradle
64
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,11 +27,17 @@ 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 {
|
||||
@ -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
|
||||
}
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -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
|
||||
|
19
gradlew
vendored
19
gradlew
vendored
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
@ -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 "$@"
|
||||
|
10
settings.gradle
Normal file
10
settings.gradle
Normal file
@ -0,0 +1,10 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
@ -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())
|
@ -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 {
|
@ -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;
|
@ -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) {
|
@ -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;
|
@ -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;
|
@ -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);
|
@ -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<IGuiEventListener> cir) {
|
||||
@Inject(method = "getFocused", at = @At("HEAD"), cancellable = true, remap = false)
|
||||
private void onGetFocused(CallbackInfoReturnable<GuiEventListener> cir) {
|
||||
if (protocolVersion.isFocused()) {
|
||||
cir.setReturnValue(protocolVersion);
|
||||
}
|
@ -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;
|
@ -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;
|
@ -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
|
@ -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;
|
@ -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()) {
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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();
|
||||
}
|
@ -22,7 +22,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.creeper123123321.viarift.util;
|
||||
package com.github.creeper123123321.viafabric.util;
|
||||
|
||||
import us.myles.ViaVersion.api.platform.TaskId;
|
||||
|
@ -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;
|
@ -22,7 +22,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.creeper123123321.viarift.util;
|
||||
package com.github.creeper123123321.viafabric.util;
|
||||
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
|
@ -22,7 +22,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.creeper123123321.viarift.util;
|
||||
package com.github.creeper123123321.viafabric.util;
|
||||
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
|
@ -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();
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
12
src/main/resources/fabric.mod.json
Normal file
12
src/main/resources/fabric.mod.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"id": "viafabric",
|
||||
"name": "ViaFabric",
|
||||
"side": "client",
|
||||
"version": "?",
|
||||
"initializers": [
|
||||
"com.github.creeper123123321.viafabric.ViaFabric"
|
||||
],
|
||||
"mixins": {
|
||||
"client": "mixins.viafabric.main.json"
|
||||
}
|
||||
}
|
14
src/main/resources/mixins.viafabric.main.json
Normal file
14
src/main/resources/mixins.viafabric.main.json
Normal 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
|
||||
}
|
||||
}
|
@ -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"
|
||||
]
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"id": "viarift",
|
||||
"name": "ViaRift",
|
||||
"authors": [
|
||||
"creeper123123321"
|
||||
],
|
||||
"listeners": [
|
||||
"com.github.creeper123123321.viarift.ViaRift"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user