Skip to content

Commit

Permalink
Port to NeoForge 20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Nov 5, 2023
1 parent eebd995 commit 490fa84
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 42 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repositories {

preprocess {
val fabric12002 = createNode("1.20.2-fabric", 1_20_02, "yarn")
val neoforge12002 = createNode("1.20.2-neoforge", 1_20_02, "yarn")
val fabric12001 = createNode("1.20.1-fabric", 1_20_01, "yarn")
val forge12001 = createNode("1.20.1-forge", 1_20_01, "srg")
val fabric11904 = createNode("1.19.4-fabric", 1_19_04, "yarn")
Expand All @@ -24,6 +25,7 @@ preprocess {
val forge11605 = createNode("1.16.5-forge", 1_16_05, "srg")
val fabric11601 = createNode("1.16.1-fabric", 1_16_01, "yarn")

fabric12002.link(neoforge12002)
fabric12002.link(fabric12001)
fabric12001.link(forge12001)
forge12001.link(forge11904)
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ listOf(
"1.19.4-fabric",
"1.20.1-forge",
"1.20.1-fabric",
"1.20.2-neoforge",
"1.20.2-fabric",
).forEach { version ->
include(":$version")
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/io/github/gaming32/worldhost/Loader.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
import java.util.Locale;

public enum Loader {
FABRIC, FORGE;
FABRIC, FORGE, NEOFORGE;

private final String lowercase = name().toLowerCase(Locale.ROOT);

@Override
public String toString() {
return lowercase;
}

public boolean isForgeLike() {
return this == FORGE || this == NEOFORGE;
}
}
29 changes: 22 additions & 7 deletions src/main/java/io/github/gaming32/worldhost/WorldHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,25 @@
//$$ import net.minecraft.client.gui.screens.Screen;
//$$ import net.minecraft.server.packs.PackType;
//$$ import net.minecraft.server.packs.PackResources;
//#if FORGE
//$$ import net.minecraftforge.api.distmarker.Dist;
//$$ import net.minecraftforge.eventbus.api.SubscribeEvent;
//$$ import net.minecraftforge.fml.ModList;
//$$ import net.minecraftforge.fml.ModLoadingContext;
//$$ import net.minecraftforge.fml.common.Mod;
//$$ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
//#else
//$$ import net.neoforged.api.distmarker.Dist;
//$$ import net.neoforged.bus.api.SubscribeEvent;
//$$ import net.neoforged.fml.ModList;
//$$ import net.neoforged.fml.ModLoadingContext;
//$$ import net.neoforged.fml.common.Mod;
//$$ import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
//#endif
//$$ import java.util.function.BiFunction;
//#if MC >= 1.19.2
//#if NEOFORGE
//$$ import net.neoforged.neoforge.client.ConfigScreenHandler;
//#elseif MC >= 1.19.2
//$$ import net.minecraftforge.client.ConfigScreenHandler;
//#elseif MC >= 1.18.2
//$$ import net.minecraftforge.client.ConfigGuiHandler;
Expand All @@ -106,7 +117,9 @@
//#else
//$$ import net.minecraftforge.fml.ExtensionPoint;
//#endif
//#if MC > 1.17.1
//#if NEOFORGE
//$$ import net.neoforged.neoforge.resource.ResourcePackLoader;
//#elseif MC > 1.17.1
//$$ import net.minecraftforge.resource.ResourcePackLoader;
//#elseif MC > 1.16.5
//$$ import net.minecraftforge.fmllegacy.packs.ResourcePackLoader;
Expand All @@ -115,7 +128,7 @@
//#endif
//#endif

//#if FORGE
//#if FORGELIKE
//$$ @Mod(WorldHost.MOD_ID)
//#endif
public class WorldHost
Expand All @@ -124,7 +137,7 @@ public class WorldHost
//#endif
{
public static final String MOD_ID =
//#if FORGE
//#if FORGELIKE
//$$ "world_host";
//#else
"world-host";
Expand All @@ -138,7 +151,9 @@ public class WorldHost
//#endif

public static final Loader MOD_LOADER =
//#if FORGE
//#if NEOFORGE
//$$ Loader.NEOFORGE;
//#elseif FORGE
//$$ Loader.FORGE;
//#else
Loader.FABRIC;
Expand Down Expand Up @@ -573,7 +588,7 @@ public static ServerStatus createEmptyServerStatus() {
//#if MC >= 1.19.4
return new ServerStatus(
Components.EMPTY, Optional.empty(), Optional.empty(), Optional.empty(), false
//#if FORGE
//#if FORGELIKE
//$$ , Optional.empty()
//#endif
);
Expand Down Expand Up @@ -784,7 +799,7 @@ public static int getMMCLines(boolean isPause) {
}
//#endif

//#if FORGE
//#if FORGELIKE
//$$ @Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
//$$ public static class ClientModEvents {
//$$ @SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public class OnlineFriendsListEntry extends ObjectSelectionList.Entry<OnlineFrie

private final ResourceLocation iconTextureId;
//#if MC >= 1.19.4
private byte @Nullable [] iconData;
private byte[] iconData;
//#else
//$$ @Nullable
//$$ private String iconData;
Expand Down Expand Up @@ -350,7 +350,7 @@ public void render(
}

//#if MC >= 1.19.4
final byte @Nullable [] icon = serverInfo.getIconBytes();
final byte[] icon = serverInfo.getIconBytes();
if (!Arrays.equals(icon, iconData)) {
//#else
//$$ final String icon = serverInfo.getIconB64();
Expand Down Expand Up @@ -512,7 +512,7 @@ private String getName() {

private boolean uploadServerIcon(
//#if MC >= 1.19.4
byte @Nullable [] newIconData
byte[] newIconData
//#else
//$$ @Nullable String newIconData
//#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
//$$ import net.fabricmc.loader.api.FabricLoader;
//#endif
//#else
//#if MC > 1.17.1
//#if NEOFORGE
//$$ import net.neoforged.neoforge.internal.BrandingControl;
//#elseif MC > 1.17.1
//$$ import net.minecraftforge.internal.BrandingControl;
//#elseif MC > 1.16.5
//$$ import net.minecraftforge.fmllegacy.BrandingControl;
Expand Down
20 changes: 17 additions & 3 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
modLoader = "javafml"
loaderVersion = "[32,)"
##if FORGE
#?? loaderVersion = "[32,)"
##else
loaderVersion = "[1,)"
##endif
issueTrackerURL = "https://github.com/Gaming32/world-host/issues"
license = "MIT"

Expand All @@ -12,10 +16,20 @@ logoFile = "icon.png"
authors = "Gaming32"
description = "Host your singleplayer worlds without having to run a server or setup port forwarding! In the future, we also plan to support Bedrock Edition clients through the use of Geyser."

##if NEOFORGE
#?? [[mixins]]
#?? config = "world-host.mixins.json"
##endif

[[dependencies.world_host]]
modId = "forge"
##if FORGE
#?? modId = "forge"
#?? versionRange = "[32,)"
##else
modId = "neoforge"
versionRange = "[20,)"
##endif
mandatory = true
versionRange = "[32,)"
ordering = "NONE"
side = "BOTH"

Expand Down
Loading

0 comments on commit 490fa84

Please sign in to comment.