-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Support for Minecraft 1.14 and 1.15
- Loading branch information
1 parent
fe045d0
commit d015b88
Showing
34 changed files
with
1,109 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
plugins { | ||
id "florianmichael.viaforge.base-conventions" | ||
id "florianmichael.viaforge.forge-conventions" | ||
} | ||
|
||
minecraft { | ||
mappings channel: "official", version: "1.14.4" | ||
} | ||
|
||
dependencies { | ||
minecraft "net.minecraftforge:forge:1.14.4-28.2.26" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
maven_name=viaforge-mc114 | ||
mc_version=1.14.4 |
42 changes: 42 additions & 0 deletions
42
viaforge-mc114/src/main/java/de/florianmichael/viaforge/ViaForge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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; | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
viaforge-mc114/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* 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.gui; | ||
|
||
import de.florianmichael.viaforge.ViaForge; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.widget.button.Button; | ||
import net.minecraft.client.gui.widget.list.AbstractList; | ||
import net.minecraft.client.gui.widget.list.ExtendedList; | ||
import net.minecraft.util.text.StringTextComponent; | ||
import net.minecraft.util.text.TextFormatting; | ||
import net.raphimc.vialoader.util.VersionEnum; | ||
import org.lwjgl.opengl.GL11; | ||
|
||
public class GuiProtocolSelector extends Screen { | ||
|
||
private final Screen parent; | ||
|
||
public static void open(final Minecraft minecraft) { // Bypass for some weird bytecode instructions errors in Forge | ||
minecraft.setScreen(new GuiProtocolSelector(minecraft.screen)); | ||
} | ||
|
||
private SlotList slotList; | ||
|
||
public GuiProtocolSelector(Screen parent) { | ||
super(new StringTextComponent("ViaForge Protocol Selector")); | ||
this.parent = parent; | ||
} | ||
|
||
@Override | ||
protected void init() { | ||
super.init(); | ||
|
||
slotList = new SlotList(minecraft, width, height, 32, height - 32, 10); | ||
addButton(new Button(width / 2 - 100, height - 27, 200, 20, "Back", b -> minecraft.setScreen(parent))); | ||
} | ||
|
||
@Override | ||
public void render(int p_230430_2_, int p_230430_3_, float p_230430_4_) { | ||
renderBackground(); | ||
this.slotList.render(p_230430_2_, p_230430_3_, p_230430_4_); | ||
|
||
super.render(p_230430_2_, p_230430_3_, p_230430_4_); | ||
|
||
GL11.glPushMatrix(); | ||
GL11.glScalef(2.0F, 2.0F, 2.0F); | ||
drawCenteredString(this.font, TextFormatting.GOLD + "ViaForge", this.width / 4, 6, 16777215); | ||
GL11.glPopMatrix(); | ||
|
||
drawString(this.font, "by https://github.com/ViaVersion/ViaForge", 1, 1, -1); | ||
drawString(this.font, "Discord: florianmichael", 1, 11, -1); | ||
} | ||
|
||
static class SlotList extends ExtendedList<SlotList.SlotEntry> { | ||
|
||
public SlotList(Minecraft p_i51146_1_, int p_i51146_2_, int p_i51146_3_, int p_i51146_4_, int p_i51146_5_, int p_i51146_6_) { | ||
super(p_i51146_1_, p_i51146_2_, p_i51146_3_, p_i51146_4_, p_i51146_5_, p_i51146_6_); | ||
|
||
for (VersionEnum version : VersionEnum.SORTED_VERSIONS) { | ||
addEntry(new SlotEntry(version)); | ||
} | ||
} | ||
|
||
public class SlotEntry extends AbstractList.AbstractListEntry<SlotEntry> { | ||
|
||
private final VersionEnum versionEnum; | ||
|
||
public SlotEntry(VersionEnum versionEnum) { | ||
this.versionEnum = versionEnum; | ||
} | ||
|
||
@Override | ||
public boolean mouseClicked(double p_231044_1_, double p_231044_3_, int p_231044_5_) { | ||
ViaForge.targetVersion = versionEnum; | ||
return super.mouseClicked(p_231044_1_, p_231044_3_, p_231044_5_); | ||
} | ||
|
||
@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_) { | ||
drawCenteredString(Minecraft.getInstance().font, | ||
(ViaForge.targetVersion.getVersion() == versionEnum.getVersion() ? TextFormatting.GREEN.toString() : TextFormatting.DARK_RED.toString()) + versionEnum.getName(), width / 2, p_230432_3_, -1); | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinMainMenuScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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.ViaForge; | ||
import de.florianmichael.viaforge.gui.GuiProtocolSelector; | ||
import net.minecraft.client.gui.screen.MainMenuScreen; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.widget.button.Button; | ||
import net.minecraft.util.text.ITextComponent; | ||
import net.minecraft.util.text.StringTextComponent; | ||
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(MainMenuScreen.class) | ||
public class MixinMainMenuScreen extends Screen { | ||
|
||
public MixinMainMenuScreen(ITextComponent p_i51108_1_) { | ||
super(p_i51108_1_); | ||
} | ||
|
||
@Inject(method = "init", at = @At("HEAD")) | ||
public void hookViaForgeButton(CallbackInfo ci) { | ||
addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft))); | ||
|
||
ViaForge.initViaVersion(); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinMultiplayerScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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.ViaForge; | ||
import de.florianmichael.viaforge.gui.GuiProtocolSelector; | ||
import net.minecraft.client.gui.screen.MultiplayerScreen; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.widget.button.Button; | ||
import net.minecraft.util.text.ITextComponent; | ||
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(MultiplayerScreen.class) | ||
public class MixinMultiplayerScreen extends Screen { | ||
|
||
protected MixinMultiplayerScreen(ITextComponent p_i51108_1_) { | ||
super(p_i51108_1_); | ||
} | ||
|
||
@Inject(method = "init", at = @At("RETURN")) | ||
public void hookViaForgeButton(CallbackInfo ci) { | ||
addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft))); | ||
|
||
ViaForge.initViaVersion(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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 io.netty.channel.Channel; | ||
import net.minecraft.network.NetworkManager; | ||
import net.raphimc.vialoader.netty.CompressionReorderEvent; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(NetworkManager.class) | ||
public class MixinNetworkManager { | ||
|
||
@Shadow private Channel channel; | ||
|
||
@Inject(method = "setupCompression", at = @At("RETURN")) | ||
public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) { | ||
channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinServerListScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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.ViaForge; | ||
import de.florianmichael.viaforge.gui.GuiProtocolSelector; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.screen.ServerListScreen; | ||
import net.minecraft.client.gui.widget.button.Button; | ||
import net.minecraft.util.text.ITextComponent; | ||
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(ServerListScreen.class) | ||
public class MixinServerListScreen extends Screen { | ||
|
||
protected MixinServerListScreen(ITextComponent p_i51108_1_) { | ||
super(p_i51108_1_); | ||
} | ||
|
||
@Inject(method = "init", at = @At("RETURN")) | ||
public void hookViaForgeButton(CallbackInfo ci) { | ||
addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft))); | ||
|
||
ViaForge.initViaVersion(); | ||
} | ||
} |
Oops, something went wrong.