Skip to content

Commit

Permalink
Fix VFP + drop VFP support on <1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Dec 19, 2023
1 parent 1e21dd1 commit 3638259
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
//$$ import com.mojang.blaze3d.vertex.PoseStack;
//#endif

//#if MC >= 1.19.4 && FABRIC
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import io.github.gaming32.worldhost.versions.ButtonBuilder;
//#if MC >= 1.20.4 && FABRIC
import de.florianmichael.viafabricplus.screen.base.ProtocolSelectionScreen;
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
import net.fabricmc.loader.api.FabricLoader;
//#if MC >= 1.20.1
import de.florianmichael.viafabricplus.screen.base.ProtocolSelectionScreen;
Expand Down Expand Up @@ -117,33 +117,24 @@ protected void init() {

updateButtonActivationStates();

//#if MC >= 1.19.4 && FABRIC
//#if MC >= 1.20.4 && FABRIC
if (FabricLoader.getInstance().isModLoaded("viafabricplus")) {
vfpInit();
}
//#endif
}

//#if MC >= 1.19.4 && FABRIC
// Based on https://github.com/ViaVersion/ViaFabricPlus/blob/main/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinMultiplayerScreen.java
//#if MC >= 1.20.4 && FABRIC
// Based on https://github.com/ViaVersion/ViaFabricPlus/blob/main/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerScreen.java
private void vfpInit() {
final ButtonBuilder builder = button(
Components.literal("ViaFabricPlus"),
b -> ProtocolSelectionScreen.INSTANCE.open(this)
Button.Builder builder = Button.builder(
Component.literal("ViaFabricPlus"),
button -> ProtocolSelectionScreen.INSTANCE.open(this)
).size(98, 20);
builder = GeneralSettings.withOrientation(
builder, GeneralSettings.global().multiplayerScreenButtonOrientation.getIndex(), width, height
);

//#if MC >= 1.20.1
switch (GeneralSettings.INSTANCE.multiplayerScreenButtonOrientation.getIndex()) {
//#else
//$$ switch (GeneralSettings.INSTANCE.mainButtonOrientation.getIndex()) {
//#endif
case 0 -> builder.pos(5, 5);
case 1 -> builder.pos(width - 98 - 5, 5);
case 2 -> builder.pos(5, height - 20 - 5);
case 3 -> builder.pos(width - 95 - 5, height - 20 - 5);
}

addRenderableWidget(builder.width(98).build());
addRenderableWidget(builder.build());
}
//#endif

Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
"breaks": {
//#if MC == 1.19.4
//?? "modmenu": "<6.2.0"
//#elseif MC == 1.20.1
//?? "viafabricplus": "<2.8.5"
//#endif
},
"suggests": {
Expand Down
14 changes: 3 additions & 11 deletions version.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,9 @@ dependencies {
modCompileOnly("dev.isxander:main-menu-credits:1.1.2")
}

if (isFabric) {
when {
mcVersion >= 1_20_02 -> "2.9.0"
mcVersion >= 1_20_01 -> "2.8.7-SNAPSHOT"
mcVersion >= 1_20_00 -> "2.7.6"
mcVersion >= 1_19_04 -> "2.7.5"
else -> null
}?.let {
modCompileOnly("de.florianmichael:viafabricplus:$it") {
isTransitive = false
}
if (isFabric && mcVersion >= 1_20_04) {
modCompileOnly("de.florianmichael:viafabricplus:3.0.2") {
isTransitive = false
}
}

Expand Down

0 comments on commit 3638259

Please sign in to comment.