mirror of
https://github.com/ViaVersion/ViaForge.git
synced 2024-11-21 11:55:13 +01:00
Abstract platform code, build tasks and resources / fixed loading on all versions ™️
This commit is contained in:
parent
d015b8807e
commit
1fbc96b805
@ -1,3 +1,8 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "base"
|
id "java"
|
||||||
|
id "viaforge.base-conventions"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly "io.netty:netty-all:4.0.20.Final"
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,6 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "com.github.johnrengelman:shadow:7.1.2"
|
implementation "com.github.johnrengelman:shadow:7.1.2"
|
||||||
implementation "net.minecraftforge.gradle:ForgeGradle:5.1.+"
|
implementation "net.minecraftforge.gradle:ForgeGradle:5.+"
|
||||||
implementation "org.spongepowered:mixingradle:0.7-SNAPSHOT"
|
implementation "org.spongepowered:mixingradle:0.7-SNAPSHOT"
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "java-library"
|
id "java-library"
|
||||||
id "com.github.johnrengelman.shadow"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
archivesBaseName = project.maven_name
|
|
||||||
version = maven_version + "-" + project.mc_version
|
|
||||||
group = maven_group
|
|
||||||
|
|
||||||
compileJava.options.encoding = "UTF-8"
|
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
include
|
include
|
||||||
implementation.extendsFrom(include)
|
implementation.extendsFrom(include)
|
||||||
@ -31,14 +24,3 @@ dependencies {
|
|||||||
|
|
||||||
include "net.raphimc:ViaLoader:${project.vialoader_version}"
|
include "net.raphimc:ViaLoader:${project.vialoader_version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
|
||||||
inputs.property "version", project.version
|
|
||||||
|
|
||||||
|
|
||||||
for (final def file in ["mcmod.info", "META-INF/mods.toml"]) {
|
|
||||||
filesMatching(file) {
|
|
||||||
expand "version": project.version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,7 @@
|
|||||||
|
plugins {
|
||||||
|
id "viaforge.shadow-conventions"
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
exclude("META-INF/services/**")
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "net.minecraftforge.gradle"
|
id "net.minecraftforge.gradle"
|
||||||
id "org.spongepowered.mixin"
|
id "org.spongepowered.mixin"
|
||||||
|
id "viaforge.shadow-conventions"
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
@ -32,10 +33,12 @@ sourceSets.main.resources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
include "org.spongepowered:mixin:${mixin_version}"
|
include "org.spongepowered:mixin:0.8.3"
|
||||||
include "org.slf4j:slf4j-api:${project.slf4j_version}"
|
include "org.slf4j:slf4j-api:${project.slf4j_version}"
|
||||||
|
|
||||||
annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
|
annotationProcessor "org.spongepowered:mixin:0.8.3:processor"
|
||||||
|
|
||||||
|
include project(":")
|
||||||
}
|
}
|
||||||
|
|
||||||
mixin {
|
mixin {
|
||||||
@ -53,6 +56,8 @@ jar {
|
|||||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd"-"HH:mm:ssZ"),
|
"Implementation-Timestamp": new Date().format("yyyy-MM-dd"-"HH:mm:ssZ"),
|
||||||
"TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
|
"TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
|
||||||
"TweakOrder": "0",
|
"TweakOrder": "0",
|
||||||
|
"FMLCorePluginContainsFMLMod": "true",
|
||||||
|
"FMLCorePlugin": "de.florianmichael.viaforge.mixin.MixinLoader",
|
||||||
"MixinConfigs": "mixins.${maven_name}.json",
|
"MixinConfigs": "mixins.${maven_name}.json",
|
||||||
"ForceLoadAsMod": "true"
|
"ForceLoadAsMod": "true"
|
||||||
)
|
)
|
||||||
@ -65,7 +70,6 @@ shadowJar {
|
|||||||
duplicatesStrategy DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy DuplicatesStrategy.EXCLUDE
|
||||||
|
|
||||||
exclude("META-INF/maven/**")
|
exclude("META-INF/maven/**")
|
||||||
exclude("META-INF/services/**")
|
|
||||||
exclude("META-INF/versions/**")
|
exclude("META-INF/versions/**")
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
plugins {
|
||||||
|
id "viaforge.forge-conventions"
|
||||||
|
id "viaforge.conflicting-conventions"
|
||||||
|
}
|
||||||
|
|
||||||
|
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
21
buildSrc/src/main/groovy/viaforge.shadow-conventions.gradle
Normal file
21
buildSrc/src/main/groovy/viaforge.shadow-conventions.gradle
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
plugins {
|
||||||
|
id "com.github.johnrengelman.shadow"
|
||||||
|
id "viaforge.base-conventions"
|
||||||
|
}
|
||||||
|
|
||||||
|
archivesBaseName = project.maven_name
|
||||||
|
version = maven_version + "-" + project.mc_version
|
||||||
|
group = maven_group
|
||||||
|
|
||||||
|
compileJava.options.encoding = "UTF-8"
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
inputs.property "version", project.version
|
||||||
|
|
||||||
|
|
||||||
|
for (final def file in ["mcmod.info", "META-INF/mods.toml"]) {
|
||||||
|
filesMatching(file) {
|
||||||
|
expand "version": project.version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,5 +15,5 @@ viarewind_version=3.0.3-SNAPSHOT
|
|||||||
snake_yml_version=2.2
|
snake_yml_version=2.2
|
||||||
|
|
||||||
# Misc Libraries
|
# Misc Libraries
|
||||||
slf4j_version=2.0.9
|
slf4j_version=2.0.7
|
||||||
mixin_version=0.8.5
|
mixin_version=0.8.3
|
@ -15,20 +15,13 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
package de.florianmichael.viaforge.common;
|
||||||
|
|
||||||
import net.raphimc.vialoader.impl.viaversion.VLInjector;
|
import java.util.function.Supplier;
|
||||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
|
||||||
|
|
||||||
public class ViaForgeVLInjector extends VLInjector {
|
public interface PlatformFields {
|
||||||
|
|
||||||
@Override
|
int getGameVersion();
|
||||||
public String getDecoderName() {
|
|
||||||
return VLLegacyPipeline.VIA_DECODER_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
Supplier<Boolean> isSingleplayer();
|
||||||
public String getEncoderName() {
|
|
||||||
return VLLegacyPipeline.VIA_ENCODER_NAME;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||||
|
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package de.florianmichael.viaforge.common;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
||||||
|
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
|
||||||
|
import de.florianmichael.viaforge.common.protocolhack.ViaForgeVLInjector;
|
||||||
|
import de.florianmichael.viaforge.common.protocolhack.ViaForgeVLLegacyPipeline;
|
||||||
|
import de.florianmichael.viaforge.common.protocolhack.ViaForgeVLLoader;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import io.netty.channel.socket.SocketChannel;
|
||||||
|
import net.raphimc.vialoader.ViaLoader;
|
||||||
|
import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
|
||||||
|
import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
|
||||||
|
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
||||||
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
|
|
||||||
|
public class ViaForgeCommon {
|
||||||
|
private static ViaForgeCommon manager;
|
||||||
|
|
||||||
|
private final PlatformFields platform;
|
||||||
|
private VersionEnum targetVersion;
|
||||||
|
|
||||||
|
public ViaForgeCommon(PlatformFields platform) {
|
||||||
|
this.platform = platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(final PlatformFields platform) {
|
||||||
|
if (manager != null) {
|
||||||
|
return; // Already initialized, ignore it then :tm:
|
||||||
|
}
|
||||||
|
final VersionEnum version = VersionEnum.fromProtocolId(platform.getGameVersion());
|
||||||
|
if (version == VersionEnum.UNKNOWN) {
|
||||||
|
throw new IllegalArgumentException("Unknown version " + platform.getGameVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
manager = new ViaForgeCommon(platform);
|
||||||
|
manager.setTargetVersion(version);
|
||||||
|
|
||||||
|
ViaLoader.init(null, new ViaForgeVLLoader(), new ViaForgeVLInjector(), null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void inject(final Channel channel) {
|
||||||
|
if (channel instanceof SocketChannel && targetVersion != getNativeVersion()) {
|
||||||
|
final UserConnection user = new UserConnectionImpl(channel, true);
|
||||||
|
new ProtocolPipelineImpl(user);
|
||||||
|
|
||||||
|
channel.pipeline().addLast(new ViaForgeVLLegacyPipeline(user, targetVersion));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reorderCompression(final Channel channel) {
|
||||||
|
channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersionEnum getNativeVersion() {
|
||||||
|
return VersionEnum.fromProtocolId(platform.getGameVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersionEnum getTargetVersion() {
|
||||||
|
return targetVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTargetVersion(VersionEnum targetVersion) {
|
||||||
|
this.targetVersion = targetVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlatformFields getPlatform() {
|
||||||
|
return platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ViaForgeCommon getManager() {
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
package de.florianmichael.viaforge.common.protocolhack;
|
||||||
|
|
||||||
import net.raphimc.vialoader.impl.viaversion.VLInjector;
|
import net.raphimc.vialoader.impl.viaversion.VLInjector;
|
||||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
package de.florianmichael.viaforge.common.protocolhack;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
@ -15,14 +15,13 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
package de.florianmichael.viaforge.common.protocolhack;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
||||||
import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
|
import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.raphimc.vialoader.impl.viaversion.VLLoader;
|
import net.raphimc.vialoader.impl.viaversion.VLLoader;
|
||||||
|
|
||||||
public class ViaForgeVLLoader extends VLLoader {
|
public class ViaForgeVLLoader extends VLLoader {
|
||||||
@ -34,8 +33,8 @@ public class ViaForgeVLLoader extends VLLoader {
|
|||||||
Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() {
|
Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() {
|
||||||
@Override
|
@Override
|
||||||
public int getClosestServerProtocol(UserConnection connection) throws Exception {
|
public int getClosestServerProtocol(UserConnection connection) throws Exception {
|
||||||
if (connection.isClientSide() && !Minecraft.getInstance().hasSingleplayerServer()) {
|
if (connection.isClientSide() && !ViaForgeCommon.getManager().getPlatform().isSingleplayer().get()) {
|
||||||
return ViaForge.targetVersion.getVersion();
|
return ViaForgeCommon.getManager().getTargetVersion().getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getClosestServerProtocol(connection);
|
return super.getClosestServerProtocol(connection);
|
@ -1,6 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "florianmichael.viaforge.base-conventions"
|
id "viaforge.forge-conventions"
|
||||||
id "florianmichael.viaforge.forge-conventions"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
@ -8,5 +7,5 @@ minecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft "net.minecraftforge:forge:1.12.2-14.23.5.2860"
|
minecraft "net.minecraftforge:forge:1.12.2-14.23.5.2859"
|
||||||
}
|
}
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge;
|
|
||||||
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLInjector;
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLLoader;
|
|
||||||
import net.raphimc.vialoader.ViaLoader;
|
|
||||||
import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
|
|
||||||
import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
|
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
|
|
||||||
public class ViaForge {
|
|
||||||
public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_12_2;
|
|
||||||
|
|
||||||
public static VersionEnum targetVersion = VersionEnum.r1_12_2;
|
|
||||||
|
|
||||||
private static boolean loaded;
|
|
||||||
|
|
||||||
public static void initViaVersion() {
|
|
||||||
if (loaded) return;
|
|
||||||
|
|
||||||
ViaLoader.init(null, new ViaForgeVLLoader(), new ViaForgeVLInjector(), null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new);
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,20 +15,24 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
package de.florianmichael.viaforge;
|
||||||
|
|
||||||
import net.raphimc.vialoader.impl.viaversion.VLInjector;
|
import de.florianmichael.viaforge.common.PlatformFields;
|
||||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.realms.RealmsSharedConstants;
|
||||||
|
|
||||||
public class ViaForgeVLInjector extends VLInjector {
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class ViaForge112 implements PlatformFields {
|
||||||
|
public final static ViaForge112 PLATFORM = new ViaForge112();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDecoderName() {
|
public int getGameVersion() {
|
||||||
return VLLegacyPipeline.VIA_DECODER_NAME;
|
return RealmsSharedConstants.NETWORK_PROTOCOL_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getEncoderName() {
|
public Supplier<Boolean> isSingleplayer() {
|
||||||
return VLLegacyPipeline.VIA_ENCODER_NAME;
|
return () -> Minecraft.getMinecraft().isSingleplayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,7 +18,7 @@
|
|||||||
package de.florianmichael.viaforge.gui;
|
package de.florianmichael.viaforge.gui;
|
||||||
|
|
||||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
@ -85,7 +85,7 @@ public class GuiProtocolSelector extends GuiScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void elementClicked(int i, boolean b, int i1, int i2) {
|
protected void elementClicked(int i, boolean b, int i1, int i2) {
|
||||||
ViaForge.targetVersion = VersionEnum.SORTED_VERSIONS.get(i);
|
ViaForgeCommon.getManager().setTargetVersion(VersionEnum.SORTED_VERSIONS.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,9 +100,10 @@ public class GuiProtocolSelector extends GuiScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawSlot(int i, int i1, int i2, int i3, int i4, int i5, float v) {
|
protected void drawSlot(int i, int i1, int i2, int i3, int i4, int i5, float v) {
|
||||||
|
final VersionEnum targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||||
final VersionEnum version = VersionEnum.SORTED_VERSIONS.get(i);
|
final VersionEnum version = VersionEnum.SORTED_VERSIONS.get(i);
|
||||||
|
|
||||||
drawCenteredString(mc.fontRenderer,(ViaForge.targetVersion.getVersion() == version.getVersion() ? ChatFormatting.GREEN.toString() : ChatFormatting.DARK_RED.toString()) + version.getName(), width / 2, i2, -1);
|
drawCenteredString(mc.fontRenderer,(targetVersion == version ? ChatFormatting.GREEN.toString() : ChatFormatting.DARK_RED.toString()) + version.getName(), width / 2, i2, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin.impl;
|
package de.florianmichael.viaforge.mixin.impl;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge112;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.*;
|
import net.minecraft.client.gui.*;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@ -32,7 +33,7 @@ public class MixinGuiMainMenu extends GuiScreen {
|
|||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
buttonList.add(new GuiButton(1337, 5, 6, 98, 20, "ViaForge"));
|
buttonList.add(new GuiButton(1337, 5, 6, 98, 20, "ViaForge"));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
ViaForgeCommon.init(ViaForge112.PLATFORM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "actionPerformed", at = @At("RETURN"))
|
@Inject(method = "actionPerformed", at = @At("RETURN"))
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin.impl;
|
package de.florianmichael.viaforge.mixin.impl;
|
||||||
|
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@ -33,6 +33,6 @@ public class MixinNetworkManager {
|
|||||||
|
|
||||||
@Inject(method = "setCompressionThreshold", at = @At("RETURN"))
|
@Inject(method = "setCompressionThreshold", at = @At("RETURN"))
|
||||||
public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) {
|
public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) {
|
||||||
channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE);
|
ViaForgeCommon.getManager().reorderCompression(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin.impl;
|
package de.florianmichael.viaforge.mixin.impl;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
|
||||||
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLLegacyPipeline;
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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;
|
||||||
@ -34,11 +29,6 @@ public class MixinNetworkManager_5 {
|
|||||||
|
|
||||||
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
||||||
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
||||||
if (channel instanceof SocketChannel && ViaForge.targetVersion != ViaForge.NATIVE_VERSION) {
|
ViaForgeCommon.getManager().inject(channel);
|
||||||
final UserConnection user = new UserConnectionImpl(channel, true);
|
|
||||||
new ProtocolPipelineImpl(user);
|
|
||||||
|
|
||||||
channel.pipeline().addLast(new ViaForgeVLLegacyPipeline(user, ViaForge.targetVersion));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
|
|
||||||
public class ViaForgeVLLegacyPipeline extends VLLegacyPipeline {
|
|
||||||
|
|
||||||
public ViaForgeVLLegacyPipeline(UserConnection user, VersionEnum version) {
|
|
||||||
super(user, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String decompressName() {
|
|
||||||
return "decompress";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String compressName() {
|
|
||||||
return "compress";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String packetDecoderName() {
|
|
||||||
return "decoder";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String packetEncoderName() {
|
|
||||||
return "encoder";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String lengthSplitterName() {
|
|
||||||
return "splitter";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String lengthPrependerName() {
|
|
||||||
return "prepender";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
|
||||||
import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.raphimc.vialoader.impl.viaversion.VLLoader;
|
|
||||||
|
|
||||||
public class ViaForgeVLLoader extends VLLoader {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load() {
|
|
||||||
super.load();
|
|
||||||
|
|
||||||
Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() {
|
|
||||||
@Override
|
|
||||||
public int getClosestServerProtocol(UserConnection connection) throws Exception {
|
|
||||||
if (connection.isClientSide() && !Minecraft.getMinecraft().isSingleplayer()) {
|
|
||||||
return ViaForge.targetVersion.getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getClosestServerProtocol(connection);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,7 +3,7 @@
|
|||||||
"minVersion": "0.7.5",
|
"minVersion": "0.7.5",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"package": "de.florianmichael.viaforge.mixin.impl",
|
"package": "de.florianmichael.viaforge.mixin.impl",
|
||||||
"refmap": "mixins.viaforge.refmap.json",
|
"refmap": "mixins.viaforge-mc112.refmap.json",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinNetworkManager",
|
"MixinNetworkManager",
|
||||||
"MixinNetworkManager_5",
|
"MixinNetworkManager_5",
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "florianmichael.viaforge.base-conventions"
|
id "viaforge.forge-conventions"
|
||||||
id "florianmichael.viaforge.forge-conventions"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge;
|
|
||||||
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLInjector;
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLLoader;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.raphimc.vialoader.ViaLoader;
|
|
||||||
import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
|
|
||||||
import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
|
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
|
|
||||||
@Mod("viaforge")
|
|
||||||
public class ViaForge {
|
|
||||||
public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_14_4;
|
|
||||||
|
|
||||||
public static VersionEnum targetVersion = VersionEnum.r1_14_4;
|
|
||||||
|
|
||||||
private static boolean loaded;
|
|
||||||
|
|
||||||
public static void initViaVersion() {
|
|
||||||
if (loaded) return;
|
|
||||||
|
|
||||||
ViaLoader.init(null, new ViaForgeVLLoader(), new ViaForgeVLInjector(), null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new);
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||||
|
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package de.florianmichael.viaforge;
|
||||||
|
|
||||||
|
import de.florianmichael.viaforge.common.PlatformFields;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.util.SharedConstants;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
@Mod("viaforge")
|
||||||
|
public class ViaForge114 implements PlatformFields {
|
||||||
|
public final static ViaForge114 PLATFORM = new ViaForge114();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGameVersion() {
|
||||||
|
return SharedConstants.getCurrentVersion().getProtocolVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Supplier<Boolean> isSingleplayer() {
|
||||||
|
return () -> Minecraft.getInstance().hasSingleplayerServer();
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.gui;
|
package de.florianmichael.viaforge.gui;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
@ -87,14 +87,14 @@ public class GuiProtocolSelector extends Screen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double p_231044_1_, double p_231044_3_, int p_231044_5_) {
|
public boolean mouseClicked(double p_231044_1_, double p_231044_3_, int p_231044_5_) {
|
||||||
ViaForge.targetVersion = versionEnum;
|
ViaForgeCommon.getManager().setTargetVersion(versionEnum);
|
||||||
return super.mouseClicked(p_231044_1_, p_231044_3_, p_231044_5_);
|
return super.mouseClicked(p_231044_1_, p_231044_3_, p_231044_5_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(int p_230432_2_, int p_230432_3_, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) {
|
public void render(int p_230432_2_, int p_230432_3_, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) {
|
||||||
drawCenteredString(Minecraft.getInstance().font,
|
drawCenteredString(Minecraft.getInstance().font,
|
||||||
(ViaForge.targetVersion.getVersion() == versionEnum.getVersion() ? TextFormatting.GREEN.toString() : TextFormatting.DARK_RED.toString()) + versionEnum.getName(), width / 2, p_230432_3_, -1);
|
(ViaForgeCommon.getManager().getTargetVersion() == versionEnum ? TextFormatting.GREEN.toString() : TextFormatting.DARK_RED.toString()) + versionEnum.getName(), width / 2, p_230432_3_, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge114;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.screen.MainMenuScreen;
|
import net.minecraft.client.gui.screen.MainMenuScreen;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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;
|
||||||
@ -40,6 +40,6 @@ public class MixinMainMenuScreen extends Screen {
|
|||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
|
addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
ViaForgeCommon.init(ViaForge114.PLATFORM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge114;
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.screen.MultiplayerScreen;
|
import net.minecraft.client.gui.screen.MultiplayerScreen;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
@ -38,7 +38,5 @@ public class MixinMultiplayerScreen extends Screen {
|
|||||||
@Inject(method = "init", at = @At("RETURN"))
|
@Inject(method = "init", at = @At("RETURN"))
|
||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
|
addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
||||||
@ -33,6 +34,6 @@ public class MixinNetworkManager {
|
|||||||
|
|
||||||
@Inject(method = "setupCompression", at = @At("RETURN"))
|
@Inject(method = "setupCompression", at = @At("RETURN"))
|
||||||
public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) {
|
public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) {
|
||||||
channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE);
|
ViaForgeCommon.getManager().reorderCompression(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||||
|
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(targets = "net.minecraft.network.NetworkManager$1", remap = false)
|
||||||
|
public class MixinNetworkManager_1 {
|
||||||
|
|
||||||
|
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
||||||
|
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
||||||
|
ViaForgeCommon.getManager().inject(channel);
|
||||||
|
}
|
||||||
|
}
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge.mixin;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
|
||||||
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLLegacyPipeline;
|
|
||||||
import io.netty.channel.Channel;
|
|
||||||
import io.netty.channel.socket.SocketChannel;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(targets = "net.minecraft.network.NetworkManager$5", remap = false)
|
|
||||||
public class MixinNetworkManager_5 {
|
|
||||||
|
|
||||||
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
|
||||||
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
|
||||||
if (channel instanceof SocketChannel && ViaForge.targetVersion != ViaForge.NATIVE_VERSION) {
|
|
||||||
final UserConnection user = new UserConnectionImpl(channel, true);
|
|
||||||
new ProtocolPipelineImpl(user);
|
|
||||||
|
|
||||||
channel.pipeline().addLast(new ViaForgeVLLegacyPipeline(user, ViaForge.targetVersion));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.screen.ServerListScreen;
|
import net.minecraft.client.gui.screen.ServerListScreen;
|
||||||
@ -38,7 +37,5 @@ public class MixinServerListScreen extends Screen {
|
|||||||
@Inject(method = "init", at = @At("RETURN"))
|
@Inject(method = "init", at = @At("RETURN"))
|
||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
|
addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
|
|
||||||
public class ViaForgeVLLegacyPipeline extends VLLegacyPipeline {
|
|
||||||
|
|
||||||
public ViaForgeVLLegacyPipeline(UserConnection user, VersionEnum version) {
|
|
||||||
super(user, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String decompressName() {
|
|
||||||
return "decompress";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String compressName() {
|
|
||||||
return "compress";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String packetDecoderName() {
|
|
||||||
return "decoder";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String packetEncoderName() {
|
|
||||||
return "encoder";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String lengthSplitterName() {
|
|
||||||
return "splitter";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String lengthPrependerName() {
|
|
||||||
return "prepender";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
|
||||||
import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.raphimc.vialoader.impl.viaversion.VLLoader;
|
|
||||||
|
|
||||||
public class ViaForgeVLLoader extends VLLoader {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load() {
|
|
||||||
super.load();
|
|
||||||
|
|
||||||
Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() {
|
|
||||||
@Override
|
|
||||||
public int getClosestServerProtocol(UserConnection connection) throws Exception {
|
|
||||||
if (connection.isClientSide() && !Minecraft.getInstance().hasSingleplayerServer()) {
|
|
||||||
return ViaForge.targetVersion.getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getClosestServerProtocol(connection);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,7 +5,7 @@
|
|||||||
"package": "de.florianmichael.viaforge.mixin",
|
"package": "de.florianmichael.viaforge.mixin",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinNetworkManager",
|
"MixinNetworkManager",
|
||||||
"MixinNetworkManager_5",
|
"MixinNetworkManager_1",
|
||||||
"MixinMainMenuScreen",
|
"MixinMainMenuScreen",
|
||||||
"MixinMultiplayerScreen",
|
"MixinMultiplayerScreen",
|
||||||
"MixinServerListScreen"
|
"MixinServerListScreen"
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"pack": {
|
|
||||||
"description": "ViaForge",
|
|
||||||
"pack_format": 6
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "florianmichael.viaforge.base-conventions"
|
id "viaforge.forge-conventions"
|
||||||
id "florianmichael.viaforge.forge-conventions"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge;
|
|
||||||
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLInjector;
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLLoader;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.raphimc.vialoader.ViaLoader;
|
|
||||||
import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
|
|
||||||
import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
|
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
|
|
||||||
@Mod("viaforge")
|
|
||||||
public class ViaForge {
|
|
||||||
public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_15_2;
|
|
||||||
|
|
||||||
public static VersionEnum targetVersion = VersionEnum.r1_15_2;
|
|
||||||
|
|
||||||
private static boolean loaded;
|
|
||||||
|
|
||||||
public static void initViaVersion() {
|
|
||||||
if (loaded) return;
|
|
||||||
|
|
||||||
ViaLoader.init(null, new ViaForgeVLLoader(), new ViaForgeVLInjector(), null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new);
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||||
|
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package de.florianmichael.viaforge;
|
||||||
|
|
||||||
|
import de.florianmichael.viaforge.common.PlatformFields;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.util.SharedConstants;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
@Mod("viaforge")
|
||||||
|
public class ViaForge115 implements PlatformFields {
|
||||||
|
|
||||||
|
public final static ViaForge115 PLATFORM = new ViaForge115();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGameVersion() {
|
||||||
|
return SharedConstants.getCurrentVersion().getProtocolVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Supplier<Boolean> isSingleplayer() {
|
||||||
|
return () -> Minecraft.getInstance().hasSingleplayerServer();
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.gui;
|
package de.florianmichael.viaforge.gui;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge115;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
@ -87,14 +88,14 @@ public class GuiProtocolSelector extends Screen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double p_231044_1_, double p_231044_3_, int p_231044_5_) {
|
public boolean mouseClicked(double p_231044_1_, double p_231044_3_, int p_231044_5_) {
|
||||||
ViaForge.targetVersion = versionEnum;
|
ViaForgeCommon.getManager().setTargetVersion(versionEnum);
|
||||||
return super.mouseClicked(p_231044_1_, p_231044_3_, p_231044_5_);
|
return super.mouseClicked(p_231044_1_, p_231044_3_, p_231044_5_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(int p_230432_2_, int p_230432_3_, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) {
|
public void render(int p_230432_2_, int p_230432_3_, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) {
|
||||||
drawCenteredString(Minecraft.getInstance().font,
|
drawCenteredString(Minecraft.getInstance().font,
|
||||||
(ViaForge.targetVersion.getVersion() == versionEnum.getVersion() ? TextFormatting.GREEN.toString() : TextFormatting.DARK_RED.toString()) + versionEnum.getName(), width / 2, p_230432_3_, -1);
|
(ViaForgeCommon.getManager().getTargetVersion() == versionEnum ? TextFormatting.GREEN.toString() : TextFormatting.DARK_RED.toString()) + versionEnum.getName(), width / 2, p_230432_3_, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge115;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.screen.MainMenuScreen;
|
import net.minecraft.client.gui.screen.MainMenuScreen;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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;
|
||||||
@ -40,6 +40,6 @@ public class MixinMainMenuScreen extends Screen {
|
|||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
|
addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
ViaForgeCommon.init(ViaForge115.PLATFORM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge115;
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.screen.MultiplayerScreen;
|
import net.minecraft.client.gui.screen.MultiplayerScreen;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
@ -38,7 +38,5 @@ public class MixinMultiplayerScreen extends Screen {
|
|||||||
@Inject(method = "init", at = @At("RETURN"))
|
@Inject(method = "init", at = @At("RETURN"))
|
||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
|
addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
||||||
@ -33,6 +34,6 @@ public class MixinNetworkManager {
|
|||||||
|
|
||||||
@Inject(method = "setupCompression", at = @At("RETURN"))
|
@Inject(method = "setupCompression", at = @At("RETURN"))
|
||||||
public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) {
|
public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) {
|
||||||
channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE);
|
ViaForgeCommon.getManager().reorderCompression(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||||
|
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(targets = "net.minecraft.network.NetworkManager$1", remap = false)
|
||||||
|
public class MixinNetworkManager_1 {
|
||||||
|
|
||||||
|
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
||||||
|
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
||||||
|
ViaForgeCommon.getManager().inject(channel);
|
||||||
|
}
|
||||||
|
}
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge.mixin;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
|
||||||
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLLegacyPipeline;
|
|
||||||
import io.netty.channel.Channel;
|
|
||||||
import io.netty.channel.socket.SocketChannel;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(targets = "net.minecraft.network.NetworkManager$5", remap = false)
|
|
||||||
public class MixinNetworkManager_5 {
|
|
||||||
|
|
||||||
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
|
||||||
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
|
||||||
if (channel instanceof SocketChannel && ViaForge.targetVersion != ViaForge.NATIVE_VERSION) {
|
|
||||||
final UserConnection user = new UserConnectionImpl(channel, true);
|
|
||||||
new ProtocolPipelineImpl(user);
|
|
||||||
|
|
||||||
channel.pipeline().addLast(new ViaForgeVLLegacyPipeline(user, ViaForge.targetVersion));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.screen.ServerListScreen;
|
import net.minecraft.client.gui.screen.ServerListScreen;
|
||||||
@ -38,7 +37,5 @@ public class MixinServerListScreen extends Screen {
|
|||||||
@Inject(method = "init", at = @At("RETURN"))
|
@Inject(method = "init", at = @At("RETURN"))
|
||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
|
addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
modLoader="javafml"
|
|
||||||
loaderVersion="[1,)"
|
|
||||||
|
|
||||||
license="GPL-3.0 license"
|
|
||||||
issueTrackerURL="https://github.com/ViaVersion/ViaForge/issues"
|
|
||||||
showAsResourcePack=false
|
|
||||||
|
|
||||||
[[mods]]
|
|
||||||
modId="viaforge"
|
|
||||||
version="${version}"
|
|
||||||
displayName="ViaForge"
|
|
||||||
displayURL="https://github.com/FlorianMichael"
|
|
||||||
credits="FlorianMichael/EnZaXD and all ViaVersion/ViaForge contributors"
|
|
||||||
authors="FlorianMichael/EnZaXD"
|
|
||||||
description='''
|
|
||||||
Client-side Implementation of ViaVersion, ViaBackwards and ViaRewind for Legacy Minecraft Forge
|
|
||||||
'''
|
|
@ -5,7 +5,7 @@
|
|||||||
"package": "de.florianmichael.viaforge.mixin",
|
"package": "de.florianmichael.viaforge.mixin",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinNetworkManager",
|
"MixinNetworkManager",
|
||||||
"MixinNetworkManager_5",
|
"MixinNetworkManager_1",
|
||||||
"MixinMainMenuScreen",
|
"MixinMainMenuScreen",
|
||||||
"MixinMultiplayerScreen",
|
"MixinMultiplayerScreen",
|
||||||
"MixinServerListScreen"
|
"MixinServerListScreen"
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"pack": {
|
|
||||||
"description": "ViaForge",
|
|
||||||
"pack_format": 6
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "florianmichael.viaforge.base-conventions"
|
id "viaforge.forge-conventions"
|
||||||
id "florianmichael.viaforge.forge-conventions"
|
id "viaforge.conflicting-conventions"
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge;
|
|
||||||
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLInjector;
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLLoader;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.raphimc.vialoader.ViaLoader;
|
|
||||||
import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
|
|
||||||
import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
|
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
|
|
||||||
@Mod("viaforge")
|
|
||||||
public class ViaForge {
|
|
||||||
public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_16_4tor1_16_5;
|
|
||||||
|
|
||||||
public static VersionEnum targetVersion = VersionEnum.r1_16_4tor1_16_5;
|
|
||||||
|
|
||||||
private static boolean loaded;
|
|
||||||
|
|
||||||
public static void initViaVersion() {
|
|
||||||
if (loaded) return;
|
|
||||||
|
|
||||||
ViaLoader.init(null, new ViaForgeVLLoader(), new ViaForgeVLInjector(), null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new);
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||||
|
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package de.florianmichael.viaforge;
|
||||||
|
|
||||||
|
import de.florianmichael.viaforge.common.PlatformFields;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.util.SharedConstants;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
@Mod("viaforge")
|
||||||
|
public class ViaForge116 implements PlatformFields {
|
||||||
|
|
||||||
|
public final static ViaForge116 PLATFORM = new ViaForge116();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGameVersion() {
|
||||||
|
return SharedConstants.getProtocolVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Supplier<Boolean> isSingleplayer() {
|
||||||
|
return () -> Minecraft.getInstance().hasSingleplayerServer();
|
||||||
|
}
|
||||||
|
}
|
@ -18,7 +18,8 @@
|
|||||||
package de.florianmichael.viaforge.gui;
|
package de.florianmichael.viaforge.gui;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge116;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
@ -88,14 +89,14 @@ public class GuiProtocolSelector extends Screen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double p_231044_1_, double p_231044_3_, int p_231044_5_) {
|
public boolean mouseClicked(double p_231044_1_, double p_231044_3_, int p_231044_5_) {
|
||||||
ViaForge.targetVersion = versionEnum;
|
ViaForgeCommon.getManager().setTargetVersion(versionEnum);
|
||||||
return super.mouseClicked(p_231044_1_, p_231044_3_, p_231044_5_);
|
return super.mouseClicked(p_231044_1_, p_231044_3_, p_231044_5_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack p_230432_1_, int p_230432_2_, int p_230432_3_, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) {
|
public void render(MatrixStack p_230432_1_, int p_230432_2_, int p_230432_3_, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) {
|
||||||
drawCenteredString(p_230432_1_, Minecraft.getInstance().font,
|
drawCenteredString(p_230432_1_, Minecraft.getInstance().font,
|
||||||
(ViaForge.targetVersion.getVersion() == versionEnum.getVersion() ? TextFormatting.GREEN.toString() : TextFormatting.DARK_RED.toString()) + versionEnum.getName(), width / 2, p_230432_3_, -1);
|
(ViaForgeCommon.getManager().getTargetVersion() == versionEnum ? TextFormatting.GREEN.toString() : TextFormatting.DARK_RED.toString()) + versionEnum.getName(), width / 2, p_230432_3_, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge116;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.screen.MainMenuScreen;
|
import net.minecraft.client.gui.screen.MainMenuScreen;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
@ -40,6 +41,6 @@ public class MixinMainMenuScreen extends Screen {
|
|||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
addButton(new Button(5, 6, 98, 20, new StringTextComponent("ViaForge"), b -> GuiProtocolSelector.open(minecraft)));
|
addButton(new Button(5, 6, 98, 20, new StringTextComponent("ViaForge"), b -> GuiProtocolSelector.open(minecraft)));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
ViaForgeCommon.init(ViaForge116.PLATFORM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.screen.MultiplayerScreen;
|
import net.minecraft.client.gui.screen.MultiplayerScreen;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
@ -38,7 +37,5 @@ public class MixinMultiplayerScreen extends Screen {
|
|||||||
@Inject(method = "init", at = @At("RETURN"))
|
@Inject(method = "init", at = @At("RETURN"))
|
||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
addButton(new Button(5, 6, 98, 20, ITextComponent.nullToEmpty("ViaForge"), b -> minecraft.setScreen(new GuiProtocolSelector(this))));
|
addButton(new Button(5, 6, 98, 20, ITextComponent.nullToEmpty("ViaForge"), b -> minecraft.setScreen(new GuiProtocolSelector(this))));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
||||||
@ -33,6 +34,6 @@ public class MixinNetworkManager {
|
|||||||
|
|
||||||
@Inject(method = "setupCompression", at = @At("RETURN"))
|
@Inject(method = "setupCompression", at = @At("RETURN"))
|
||||||
public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) {
|
public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) {
|
||||||
channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE);
|
ViaForgeCommon.getManager().reorderCompression(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||||
|
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(targets = "net.minecraft.network.NetworkManager$1", remap = false)
|
||||||
|
public class MixinNetworkManager_1 {
|
||||||
|
|
||||||
|
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
||||||
|
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
||||||
|
ViaForgeCommon.getManager().inject(channel);
|
||||||
|
}
|
||||||
|
}
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge.mixin;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
|
||||||
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLLegacyPipeline;
|
|
||||||
import io.netty.channel.Channel;
|
|
||||||
import io.netty.channel.socket.SocketChannel;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(targets = "net.minecraft.network.NetworkManager$5", remap = false)
|
|
||||||
public class MixinNetworkManager_5 {
|
|
||||||
|
|
||||||
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
|
||||||
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
|
||||||
if (channel instanceof SocketChannel && ViaForge.targetVersion != ViaForge.NATIVE_VERSION) {
|
|
||||||
final UserConnection user = new UserConnectionImpl(channel, true);
|
|
||||||
new ProtocolPipelineImpl(user);
|
|
||||||
|
|
||||||
channel.pipeline().addLast(new ViaForgeVLLegacyPipeline(user, ViaForge.targetVersion));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge116;
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.screen.ServerListScreen;
|
import net.minecraft.client.gui.screen.ServerListScreen;
|
||||||
@ -38,7 +38,5 @@ public class MixinServerListScreen extends Screen {
|
|||||||
@Inject(method = "init", at = @At("RETURN"))
|
@Inject(method = "init", at = @At("RETURN"))
|
||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
addButton(new Button(5, 6, 98, 20, ITextComponent.nullToEmpty("ViaForge"), b -> minecraft.setScreen(new GuiProtocolSelector(this))));
|
addButton(new Button(5, 6, 98, 20, ITextComponent.nullToEmpty("ViaForge"), b -> minecraft.setScreen(new GuiProtocolSelector(this))));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
|
|
||||||
public class ViaForgeVLLegacyPipeline extends VLLegacyPipeline {
|
|
||||||
|
|
||||||
public ViaForgeVLLegacyPipeline(UserConnection user, VersionEnum version) {
|
|
||||||
super(user, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String decompressName() {
|
|
||||||
return "decompress";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String compressName() {
|
|
||||||
return "compress";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String packetDecoderName() {
|
|
||||||
return "decoder";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String packetEncoderName() {
|
|
||||||
return "encoder";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String lengthSplitterName() {
|
|
||||||
return "splitter";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String lengthPrependerName() {
|
|
||||||
return "prepender";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
|
||||||
import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.raphimc.vialoader.impl.viaversion.VLLoader;
|
|
||||||
|
|
||||||
public class ViaForgeVLLoader extends VLLoader {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load() {
|
|
||||||
super.load();
|
|
||||||
|
|
||||||
Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() {
|
|
||||||
@Override
|
|
||||||
public int getClosestServerProtocol(UserConnection connection) throws Exception {
|
|
||||||
if (connection.isClientSide() && !Minecraft.getInstance().hasSingleplayerServer()) {
|
|
||||||
return ViaForge.targetVersion.getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getClosestServerProtocol(connection);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
modLoader="javafml"
|
|
||||||
loaderVersion="[1,)"
|
|
||||||
|
|
||||||
license="GPL-3.0 license"
|
|
||||||
issueTrackerURL="https://github.com/ViaVersion/ViaForge/issues"
|
|
||||||
showAsResourcePack=false
|
|
||||||
|
|
||||||
[[mods]]
|
|
||||||
modId="viaforge"
|
|
||||||
version="${version}"
|
|
||||||
displayName="ViaForge"
|
|
||||||
displayURL="https://github.com/FlorianMichael"
|
|
||||||
credits="FlorianMichael/EnZaXD and all ViaVersion/ViaForge contributors"
|
|
||||||
authors="FlorianMichael/EnZaXD"
|
|
||||||
description='''
|
|
||||||
Client-side Implementation of ViaVersion, ViaBackwards and ViaRewind for Legacy Minecraft Forge
|
|
||||||
'''
|
|
@ -5,7 +5,7 @@
|
|||||||
"package": "de.florianmichael.viaforge.mixin",
|
"package": "de.florianmichael.viaforge.mixin",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinNetworkManager",
|
"MixinNetworkManager",
|
||||||
"MixinNetworkManager_5",
|
"MixinNetworkManager_1",
|
||||||
"MixinMainMenuScreen",
|
"MixinMainMenuScreen",
|
||||||
"MixinMultiplayerScreen",
|
"MixinMultiplayerScreen",
|
||||||
"MixinServerListScreen"
|
"MixinServerListScreen"
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"pack": {
|
|
||||||
"description": "ViaForge",
|
|
||||||
"pack_format": 6
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "florianmichael.viaforge.base-conventions"
|
id "viaforge.modern-conventions"
|
||||||
id "florianmichael.viaforge.forge-conventions"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: "official", version: "1.17.1"
|
mappings channel: "official", version: "1.17.1"
|
||||||
}
|
}
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge;
|
|
||||||
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLInjector;
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLLoader;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.raphimc.vialoader.ViaLoader;
|
|
||||||
import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
|
|
||||||
import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
|
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
|
|
||||||
@Mod("viaforge")
|
|
||||||
public class ViaForge {
|
|
||||||
public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_17_1;
|
|
||||||
|
|
||||||
public static VersionEnum targetVersion = VersionEnum.r1_17_1;
|
|
||||||
|
|
||||||
private static boolean loaded;
|
|
||||||
|
|
||||||
public static void initViaVersion() {
|
|
||||||
if (loaded) return;
|
|
||||||
|
|
||||||
ViaLoader.init(null, new ViaForgeVLLoader(), new ViaForgeVLInjector(), null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new);
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||||
|
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package de.florianmichael.viaforge;
|
||||||
|
|
||||||
|
import de.florianmichael.viaforge.common.PlatformFields;
|
||||||
|
import net.minecraft.SharedConstants;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
@Mod("viaforge")
|
||||||
|
public class ViaForge117 implements PlatformFields {
|
||||||
|
|
||||||
|
public final static ViaForge117 PLATFORM = new ViaForge117();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGameVersion() {
|
||||||
|
return SharedConstants.getProtocolVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Supplier<Boolean> isSingleplayer() {
|
||||||
|
return () -> Minecraft.getInstance().hasSingleplayerServer();
|
||||||
|
}
|
||||||
|
}
|
@ -18,7 +18,8 @@
|
|||||||
package de.florianmichael.viaforge.gui;
|
package de.florianmichael.viaforge.gui;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge117;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
@ -88,14 +89,14 @@ public class GuiProtocolSelector extends Screen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double p_231044_1_, double p_231044_3_, int p_231044_5_) {
|
public boolean mouseClicked(double p_231044_1_, double p_231044_3_, int p_231044_5_) {
|
||||||
ViaForge.targetVersion = versionEnum;
|
ViaForgeCommon.getManager().setTargetVersion(versionEnum);
|
||||||
return super.mouseClicked(p_231044_1_, p_231044_3_, p_231044_5_);
|
return super.mouseClicked(p_231044_1_, p_231044_3_, p_231044_5_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(PoseStack p_230432_1_, int p_230432_2_, int p_230432_3_, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) {
|
public void render(PoseStack p_230432_1_, int p_230432_2_, int p_230432_3_, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) {
|
||||||
drawCenteredString(p_230432_1_, Minecraft.getInstance().font,
|
drawCenteredString(p_230432_1_, Minecraft.getInstance().font,
|
||||||
(ViaForge.targetVersion.getVersion() == versionEnum.getVersion() ? ChatFormatting.GREEN.toString() : ChatFormatting.DARK_RED.toString()) + versionEnum.getName(), width / 2, p_230432_3_, -1);
|
(ViaForgeCommon.getManager().getTargetVersion() == versionEnum ? ChatFormatting.GREEN.toString() : ChatFormatting.DARK_RED.toString()) + versionEnum.getName(), width / 2, p_230432_3_, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import net.minecraft.network.Connection;
|
import net.minecraft.network.Connection;
|
||||||
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
||||||
@ -33,6 +34,6 @@ public class MixinConnection {
|
|||||||
|
|
||||||
@Inject(method = "setupCompression", at = @At("RETURN"))
|
@Inject(method = "setupCompression", at = @At("RETURN"))
|
||||||
public void reorderPipeline(int p_129485_, boolean p_182682_, CallbackInfo ci) {
|
public void reorderPipeline(int p_129485_, boolean p_182682_, CallbackInfo ci) {
|
||||||
channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE);
|
ViaForgeCommon.getManager().reorderCompression(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,28 +17,18 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
|
||||||
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLLegacyPipeline;
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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;
|
||||||
|
|
||||||
@Mixin(targets = "net.minecraft.network.Connection$1", remap = false)
|
@Mixin(targets = "net.minecraft.network.Connection$1", remap = false)
|
||||||
public class MixinNetworkManager_1 {
|
public class MixinConnection_1 {
|
||||||
|
|
||||||
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
||||||
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
||||||
if (channel instanceof SocketChannel && ViaForge.targetVersion != ViaForge.NATIVE_VERSION) {
|
ViaForgeCommon.getManager().inject(channel);
|
||||||
final UserConnection user = new UserConnectionImpl(channel, true);
|
|
||||||
new ProtocolPipelineImpl(user);
|
|
||||||
|
|
||||||
channel.pipeline().addLast(new ViaForgeVLLegacyPipeline(user, ViaForge.targetVersion));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge117;
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.screens.DirectJoinServerScreen;
|
import net.minecraft.client.gui.screens.DirectJoinServerScreen;
|
||||||
@ -39,7 +39,5 @@ public class MixinDirectJoinServerScreen extends Screen {
|
|||||||
@Inject(method = "init", at = @At("RETURN"))
|
@Inject(method = "init", at = @At("RETURN"))
|
||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
addRenderableWidget(new Button(5, 6, 98, 20, new TextComponent("ViaForge"), b -> minecraft.setScreen(new GuiProtocolSelector(this))));
|
addRenderableWidget(new Button(5, 6, 98, 20, new TextComponent("ViaForge"), b -> minecraft.setScreen(new GuiProtocolSelector(this))));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge117;
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
@ -39,7 +39,5 @@ public class MixinJoinMultiplayerScreen extends Screen {
|
|||||||
@Inject(method = "init", at = @At("RETURN"))
|
@Inject(method = "init", at = @At("RETURN"))
|
||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
addRenderableWidget(new Button(5, 6, 98, 20, new TextComponent("ViaForge"), b -> minecraft.setScreen(new GuiProtocolSelector(this))));
|
addRenderableWidget(new Button(5, 6, 98, 20, new TextComponent("ViaForge"), b -> minecraft.setScreen(new GuiProtocolSelector(this))));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge117;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
@ -40,6 +41,6 @@ public class MixinTitleScreen extends Screen {
|
|||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
addRenderableWidget(new Button(5, 6, 98, 20, new TextComponent("ViaForge"), b -> GuiProtocolSelector.open(minecraft)));
|
addRenderableWidget(new Button(5, 6, 98, 20, new TextComponent("ViaForge"), b -> GuiProtocolSelector.open(minecraft)));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
ViaForgeCommon.init(ViaForge117.PLATFORM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
|
||||||
|
|
||||||
import net.raphimc.vialoader.impl.viaversion.VLInjector;
|
|
||||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
|
||||||
|
|
||||||
public class ViaForgeVLInjector extends VLInjector {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDecoderName() {
|
|
||||||
return VLLegacyPipeline.VIA_DECODER_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEncoderName() {
|
|
||||||
return VLLegacyPipeline.VIA_ENCODER_NAME;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
|
|
||||||
public class ViaForgeVLLegacyPipeline extends VLLegacyPipeline {
|
|
||||||
|
|
||||||
public ViaForgeVLLegacyPipeline(UserConnection user, VersionEnum version) {
|
|
||||||
super(user, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String decompressName() {
|
|
||||||
return "decompress";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String compressName() {
|
|
||||||
return "compress";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String packetDecoderName() {
|
|
||||||
return "decoder";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String packetEncoderName() {
|
|
||||||
return "encoder";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String lengthSplitterName() {
|
|
||||||
return "splitter";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String lengthPrependerName() {
|
|
||||||
return "prepender";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
|
||||||
import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.raphimc.vialoader.impl.viaversion.VLLoader;
|
|
||||||
|
|
||||||
public class ViaForgeVLLoader extends VLLoader {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load() {
|
|
||||||
super.load();
|
|
||||||
|
|
||||||
Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() {
|
|
||||||
@Override
|
|
||||||
public int getClosestServerProtocol(UserConnection connection) throws Exception {
|
|
||||||
if (connection.isClientSide() && !Minecraft.getInstance().hasSingleplayerServer()) {
|
|
||||||
return ViaForge.targetVersion.getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getClosestServerProtocol(connection);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
modLoader="javafml"
|
|
||||||
loaderVersion="[1,)"
|
|
||||||
|
|
||||||
license="GPL-3.0 license"
|
|
||||||
issueTrackerURL="https://github.com/ViaVersion/ViaForge/issues"
|
|
||||||
showAsResourcePack=false
|
|
||||||
|
|
||||||
[[mods]]
|
|
||||||
modId="viaforge"
|
|
||||||
version="${version}"
|
|
||||||
displayName="ViaForge"
|
|
||||||
displayURL="https://github.com/FlorianMichael"
|
|
||||||
credits="FlorianMichael/EnZaXD and all ViaVersion/ViaForge contributors"
|
|
||||||
authors="FlorianMichael/EnZaXD"
|
|
||||||
description='''
|
|
||||||
Client-side Implementation of ViaVersion, ViaBackwards and ViaRewind for Legacy Minecraft Forge
|
|
||||||
'''
|
|
@ -5,7 +5,7 @@
|
|||||||
"package": "de.florianmichael.viaforge.mixin",
|
"package": "de.florianmichael.viaforge.mixin",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinConnection",
|
"MixinConnection",
|
||||||
"MixinNetworkManager_1",
|
"MixinConnection_1",
|
||||||
"MixinTitleScreen",
|
"MixinTitleScreen",
|
||||||
"MixinJoinMultiplayerScreen",
|
"MixinJoinMultiplayerScreen",
|
||||||
"MixinDirectJoinServerScreen"
|
"MixinDirectJoinServerScreen"
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"pack": {
|
|
||||||
"description": "ViaForge",
|
|
||||||
"pack_format": 6
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "florianmichael.viaforge.base-conventions"
|
id "viaforge.modern-conventions"
|
||||||
id "florianmichael.viaforge.forge-conventions"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: "official", version: "1.18.2"
|
mappings channel: "official", version: "1.18.2"
|
||||||
}
|
}
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge;
|
|
||||||
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLInjector;
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLLoader;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.raphimc.vialoader.ViaLoader;
|
|
||||||
import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
|
|
||||||
import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
|
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
|
|
||||||
@Mod("viaforge")
|
|
||||||
public class ViaForge {
|
|
||||||
public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_18_2;
|
|
||||||
|
|
||||||
public static VersionEnum targetVersion = VersionEnum.r1_18_2;
|
|
||||||
|
|
||||||
private static boolean loaded;
|
|
||||||
|
|
||||||
public static void initViaVersion() {
|
|
||||||
if (loaded) return;
|
|
||||||
|
|
||||||
ViaLoader.init(null, new ViaForgeVLLoader(), new ViaForgeVLInjector(), null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new);
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||||
|
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package de.florianmichael.viaforge;
|
||||||
|
|
||||||
|
import de.florianmichael.viaforge.common.PlatformFields;
|
||||||
|
import net.minecraft.SharedConstants;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
@Mod("viaforge")
|
||||||
|
public class ViaForge118 implements PlatformFields {
|
||||||
|
|
||||||
|
public final static ViaForge118 PLATFORM = new ViaForge118();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGameVersion() {
|
||||||
|
return SharedConstants.getProtocolVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Supplier<Boolean> isSingleplayer() {
|
||||||
|
return () -> Minecraft.getInstance().hasSingleplayerServer();
|
||||||
|
}
|
||||||
|
}
|
@ -18,7 +18,8 @@
|
|||||||
package de.florianmichael.viaforge.gui;
|
package de.florianmichael.viaforge.gui;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge118;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
@ -88,14 +89,14 @@ public class GuiProtocolSelector extends Screen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double p_231044_1_, double p_231044_3_, int p_231044_5_) {
|
public boolean mouseClicked(double p_231044_1_, double p_231044_3_, int p_231044_5_) {
|
||||||
ViaForge.targetVersion = versionEnum;
|
ViaForgeCommon.getManager().setTargetVersion(versionEnum);
|
||||||
return super.mouseClicked(p_231044_1_, p_231044_3_, p_231044_5_);
|
return super.mouseClicked(p_231044_1_, p_231044_3_, p_231044_5_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(PoseStack p_230432_1_, int p_230432_2_, int p_230432_3_, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) {
|
public void render(PoseStack p_230432_1_, int p_230432_2_, int p_230432_3_, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) {
|
||||||
drawCenteredString(p_230432_1_, Minecraft.getInstance().font,
|
drawCenteredString(p_230432_1_, Minecraft.getInstance().font,
|
||||||
(ViaForge.targetVersion.getVersion() == versionEnum.getVersion() ? ChatFormatting.GREEN.toString() : ChatFormatting.DARK_RED.toString()) + versionEnum.getName(), width / 2, p_230432_3_, -1);
|
(ViaForgeCommon.getManager().getTargetVersion() == versionEnum ? ChatFormatting.GREEN.toString() : ChatFormatting.DARK_RED.toString()) + versionEnum.getName(), width / 2, p_230432_3_, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import net.minecraft.network.Connection;
|
import net.minecraft.network.Connection;
|
||||||
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
||||||
@ -33,6 +34,6 @@ public class MixinConnection {
|
|||||||
|
|
||||||
@Inject(method = "setupCompression", at = @At("RETURN"))
|
@Inject(method = "setupCompression", at = @At("RETURN"))
|
||||||
public void reorderPipeline(int p_129485_, boolean p_182682_, CallbackInfo ci) {
|
public void reorderPipeline(int p_129485_, boolean p_182682_, CallbackInfo ci) {
|
||||||
channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE);
|
ViaForgeCommon.getManager().reorderCompression(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,28 +17,18 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
|
||||||
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLLegacyPipeline;
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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;
|
||||||
|
|
||||||
@Mixin(targets = "net.minecraft.network.Connection$1", remap = false)
|
@Mixin(targets = "net.minecraft.network.Connection$1", remap = false)
|
||||||
public class MixinNetworkManager_1 {
|
public class MixinConnection_1 {
|
||||||
|
|
||||||
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
||||||
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
||||||
if (channel instanceof SocketChannel && ViaForge.targetVersion != ViaForge.NATIVE_VERSION) {
|
ViaForgeCommon.getManager().inject(channel);
|
||||||
final UserConnection user = new UserConnectionImpl(channel, true);
|
|
||||||
new ProtocolPipelineImpl(user);
|
|
||||||
|
|
||||||
channel.pipeline().addLast(new ViaForgeVLLegacyPipeline(user, ViaForge.targetVersion));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge118;
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.screens.DirectJoinServerScreen;
|
import net.minecraft.client.gui.screens.DirectJoinServerScreen;
|
||||||
@ -39,7 +39,5 @@ public class MixinDirectJoinServerScreen extends Screen {
|
|||||||
@Inject(method = "init", at = @At("RETURN"))
|
@Inject(method = "init", at = @At("RETURN"))
|
||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
addRenderableWidget(new Button(5, 6, 98, 20, new TextComponent("ViaForge"), b -> minecraft.setScreen(new GuiProtocolSelector(this))));
|
addRenderableWidget(new Button(5, 6, 98, 20, new TextComponent("ViaForge"), b -> minecraft.setScreen(new GuiProtocolSelector(this))));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge118;
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
@ -39,7 +39,5 @@ public class MixinJoinMultiplayerScreen extends Screen {
|
|||||||
@Inject(method = "init", at = @At("RETURN"))
|
@Inject(method = "init", at = @At("RETURN"))
|
||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
addRenderableWidget(new Button(5, 6, 98, 20, new TextComponent("ViaForge"), b -> minecraft.setScreen(new GuiProtocolSelector(this))));
|
addRenderableWidget(new Button(5, 6, 98, 20, new TextComponent("ViaForge"), b -> minecraft.setScreen(new GuiProtocolSelector(this))));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
package de.florianmichael.viaforge.mixin;
|
package de.florianmichael.viaforge.mixin;
|
||||||
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
import de.florianmichael.viaforge.ViaForge118;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
@ -40,6 +41,6 @@ public class MixinTitleScreen extends Screen {
|
|||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
addRenderableWidget(new Button(5, 6, 98, 20, new TextComponent("ViaForge"), b -> GuiProtocolSelector.open(minecraft)));
|
addRenderableWidget(new Button(5, 6, 98, 20, new TextComponent("ViaForge"), b -> GuiProtocolSelector.open(minecraft)));
|
||||||
|
|
||||||
ViaForge.initViaVersion();
|
ViaForgeCommon.init(ViaForge118.PLATFORM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
|
||||||
|
|
||||||
import net.raphimc.vialoader.impl.viaversion.VLInjector;
|
|
||||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
|
||||||
|
|
||||||
public class ViaForgeVLInjector extends VLInjector {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDecoderName() {
|
|
||||||
return VLLegacyPipeline.VIA_DECODER_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEncoderName() {
|
|
||||||
return VLLegacyPipeline.VIA_ENCODER_NAME;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
|
|
||||||
public class ViaForgeVLLegacyPipeline extends VLLegacyPipeline {
|
|
||||||
|
|
||||||
public ViaForgeVLLegacyPipeline(UserConnection user, VersionEnum version) {
|
|
||||||
super(user, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String decompressName() {
|
|
||||||
return "decompress";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String compressName() {
|
|
||||||
return "compress";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String packetDecoderName() {
|
|
||||||
return "decoder";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String packetEncoderName() {
|
|
||||||
return "encoder";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String lengthSplitterName() {
|
|
||||||
return "splitter";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String lengthPrependerName() {
|
|
||||||
return "prepender";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge.protocolhack;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
|
||||||
import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
|
|
||||||
import de.florianmichael.viaforge.ViaForge;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.raphimc.vialoader.impl.viaversion.VLLoader;
|
|
||||||
|
|
||||||
public class ViaForgeVLLoader extends VLLoader {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load() {
|
|
||||||
super.load();
|
|
||||||
|
|
||||||
Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() {
|
|
||||||
@Override
|
|
||||||
public int getClosestServerProtocol(UserConnection connection) throws Exception {
|
|
||||||
if (connection.isClientSide() && !Minecraft.getInstance().hasSingleplayerServer()) {
|
|
||||||
return ViaForge.targetVersion.getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getClosestServerProtocol(connection);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
modLoader="javafml"
|
|
||||||
loaderVersion="[1,)"
|
|
||||||
|
|
||||||
license="GPL-3.0 license"
|
|
||||||
issueTrackerURL="https://github.com/ViaVersion/ViaForge/issues"
|
|
||||||
showAsResourcePack=false
|
|
||||||
|
|
||||||
[[mods]]
|
|
||||||
modId="viaforge"
|
|
||||||
version="${version}"
|
|
||||||
displayName="ViaForge"
|
|
||||||
displayURL="https://github.com/FlorianMichael"
|
|
||||||
credits="FlorianMichael/EnZaXD and all ViaVersion/ViaForge contributors"
|
|
||||||
authors="FlorianMichael/EnZaXD"
|
|
||||||
description='''
|
|
||||||
Client-side Implementation of ViaVersion, ViaBackwards and ViaRewind for Legacy Minecraft Forge
|
|
||||||
'''
|
|
@ -5,7 +5,7 @@
|
|||||||
"package": "de.florianmichael.viaforge.mixin",
|
"package": "de.florianmichael.viaforge.mixin",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinConnection",
|
"MixinConnection",
|
||||||
"MixinNetworkManager_1",
|
"MixinConnection_1",
|
||||||
"MixinTitleScreen",
|
"MixinTitleScreen",
|
||||||
"MixinJoinMultiplayerScreen",
|
"MixinJoinMultiplayerScreen",
|
||||||
"MixinDirectJoinServerScreen"
|
"MixinDirectJoinServerScreen"
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"pack": {
|
|
||||||
"description": "ViaForge",
|
|
||||||
"pack_format": 6
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "florianmichael.viaforge.base-conventions"
|
id "viaforge.modern-conventions"
|
||||||
id "florianmichael.viaforge.forge-conventions"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: "official", version: "1.19.4"
|
mappings channel: "official", version: "1.19.4"
|
||||||
}
|
}
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viaforge;
|
|
||||||
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLInjector;
|
|
||||||
import de.florianmichael.viaforge.protocolhack.ViaForgeVLLoader;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.raphimc.vialoader.ViaLoader;
|
|
||||||
import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
|
|
||||||
import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
|
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
|
|
||||||
@Mod("viaforge")
|
|
||||||
public class ViaForge {
|
|
||||||
public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_19_4;
|
|
||||||
|
|
||||||
public static VersionEnum targetVersion = VersionEnum.r1_19_4;
|
|
||||||
|
|
||||||
private static boolean loaded;
|
|
||||||
|
|
||||||
public static void initViaVersion() {
|
|
||||||
if (loaded) return;
|
|
||||||
|
|
||||||
ViaLoader.init(null, new ViaForgeVLLoader(), new ViaForgeVLInjector(), null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new);
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user