Skip to content

Commit

Permalink
Drop support for 1.17.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Jun 12, 2024
1 parent 415dca6 commit 8759d82
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 158 deletions.
21 changes: 0 additions & 21 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ preprocess {
val forge11902 = createNode("1.19.2-forge", 1_19_02, "srg")
val fabric11802 = createNode("1.18.2-fabric", 1_18_02, "yarn")
val forge11802 = createNode("1.18.2-forge", 1_18_02, "srg")
val fabric11701 = createNode("1.17.1-fabric", 1_17_01, "yarn")
val forge11701 = createNode("1.17.1-forge", 1_17_01, "srg")

fabric12006.link(neoforge12006)
neoforge12006.link(neoforge12004)
Expand All @@ -34,23 +32,4 @@ preprocess {
fabric11902.link(forge11902)
forge11902.link(forge11802)
forge11802.link(fabric11802)
fabric11802.link(fabric11701)
fabric11701.link(forge11701)

// subprojects {
// apply(plugin = "java")
// if (name == "1.20.1-fabric") {
// sourceSets.main {
// java {
// srcDir("$rootDir/src/main/java")
// }
// }
// }
// }
}

//gradle.projectsEvaluated {
// subprojects.asSequence().zipWithNext().forEach { (left, right) ->
// right.tasks.named("modrinth").get().mustRunAfter(left.tasks.named("modrinth"))
// }
//}
2 changes: 0 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ rootProject.name = "world-host"
rootProject.buildFileName = "build.gradle.kts"

listOf(
"1.17.1-forge",
"1.17.1-fabric",
"1.18.2-forge",
"1.18.2-fabric",
"1.19.2-forge",
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/io/github/gaming32/worldhost/IOFunction.java

This file was deleted.

38 changes: 9 additions & 29 deletions src/main/java/io/github/gaming32/worldhost/WorldHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.logging.LogUtils;
import io.github.gaming32.worldhost.config.WorldHostConfig;
import io.github.gaming32.worldhost.gui.screen.JoiningWorldHostScreen;
import io.github.gaming32.worldhost.gui.screen.WorldHostScreen;
Expand Down Expand Up @@ -44,6 +45,7 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.network.ServerConnectionListener;
import net.minecraft.server.players.GameProfileCache;
import org.apache.commons.io.function.IOFunction;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
Expand All @@ -53,6 +55,7 @@
import org.quiltmc.parsers.json.JsonReader;
import org.quiltmc.parsers.json.JsonWriter;
import org.semver4j.Semver;
import org.slf4j.Logger;

import java.io.BufferedReader;
import java.io.InputStream;
Expand Down Expand Up @@ -84,14 +87,6 @@

import static net.minecraft.commands.Commands.literal;

//#if MC >= 1.18.0
import com.mojang.logging.LogUtils;
import org.slf4j.Logger;
//#else
//$$ import org.apache.logging.log4j.LogManager;
//$$ import org.apache.logging.log4j.Logger;
//#endif

//#if MC >= 1.19.2
import io.github.gaming32.worldhost.mixin.MinecraftAccessor;
//#else
Expand All @@ -105,12 +100,10 @@
//#endif

//#if FABRIC
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.loader.api.FabricLoader;
//#if MC >= 1.18.2
import dev.isxander.mainmenucredits.MainMenuCredits;
import io.github.gaming32.worldhost.gui.OnlineStatusLocation;
//#endif
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.loader.api.FabricLoader;
//#else
//$$ import io.github.gaming32.worldhost.gui.screen.WorldHostConfigScreen;
//#if FORGE
Expand Down Expand Up @@ -138,10 +131,8 @@
//$$ 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;
//#else
//$$ import net.minecraftforge.fmlclient.ConfigGuiHandler;
//$$ import net.minecraftforge.client.ConfigGuiHandler;
//#endif
//#endif

Expand All @@ -160,12 +151,7 @@ public class WorldHost
"world-host";
//#endif

public static final Logger LOGGER =
//#if MC >= 1.18.0
LogUtils.getLogger();
//#else
//$$ LogManager.getLogger();
//#endif
public static final Logger LOGGER = LogUtils.getLogger();

public static final Loader MOD_LOADER =
//#if NEOFORGE
Expand Down Expand Up @@ -464,13 +450,7 @@ public static void reconnect(boolean successToast, boolean failureToast) {
}

public static String getName(GameProfile profile) {
return getIfBlank(profile.getName(), () -> profile.getId().toString());
}

// From Apache Commons Lang StringUtils 3.10+
// TODO: Remove when 1.18.2 is minimum
public static <T extends CharSequence> T getIfBlank(final T str, final Supplier<T> defaultSupplier) {
return StringUtils.isBlank(str) ? defaultSupplier == null ? null : defaultSupplier.get() : str;
return StringUtils.getIfBlank(profile.getName(), () -> profile.getId().toString());
}

public static GameProfileCache getProfileCache() {
Expand Down Expand Up @@ -795,7 +775,7 @@ public static String getModVersion(String modId) {
}

public static int getMMCLines(boolean isPause) {
//#if FABRIC && MC >= 1.18.2
//#if FABRIC
if (FabricLoader.getInstance().isModLoaded("isxander-main-menu-credits")) {
final var baseConfig = MainMenuCredits.getInstance().getConfig();
final var config = isPause ? baseConfig.PAUSE_MENU : baseConfig.MAIN_MENU;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ public void render(
iconData = icon;
} else {
//#if MC >= 1.19.4
// Mojang did "@Nullable byte[]" instead of "byte @Nullable []"
serverInfo.setIconBytes(null);
//#else
//$$ serverInfo.setIconB64(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.components.PlainTextButton;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.ComponentUtils;
Expand All @@ -22,12 +23,6 @@
//$$ import com.mojang.blaze3d.vertex.PoseStack;
//#endif

//#if MC > 1.17.1
import net.minecraft.client.gui.components.PlainTextButton;
//#else
//$$ import io.github.gaming32.worldhost.gui.PlainTextButton;
//#endif

public final class OnlineStatusButton extends PlainTextButton {
private static final ChatFormatting[] COLORS = {
ChatFormatting.RED,
Expand Down Expand Up @@ -127,15 +122,8 @@ private static Component generateStatusComponent() {
(context, i, j, f);
}

//#if MC >= 1.18.0
@Override
public boolean isHoveredOrFocused() {
return currentStatus != 1 && super.isHoveredOrFocused();
}
//#else
//$$ @Override
//$$ public boolean isHovered() {
//$$ return currentStatus != 1 && super.isHovered();
//$$ }
//#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.client.server.IntegratedServer;
import net.minecraft.network.chat.Component;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.WorldStem;
import net.minecraft.server.level.progress.ChunkProgressListenerFactory;
import net.minecraft.server.packs.repository.PackRepository;
import net.minecraft.util.HttpUtil;
Expand All @@ -35,14 +36,6 @@
//$$ import net.minecraft.server.players.GameProfileCache;
//#endif

//#if MC < 1.18.2
//$$ import net.minecraft.core.RegistryAccess;
//$$ import net.minecraft.server.ServerResources;
//$$ import net.minecraft.world.level.storage.WorldData;
//#else
import net.minecraft.server.WorldStem;
//#endif

@Mixin(IntegratedServer.class)
public abstract class MixinIntegratedServer extends MinecraftServer {
public MixinIntegratedServer(
Expand All @@ -55,26 +48,13 @@ public MixinIntegratedServer(
DataFixer dataFixer,
Services services,
ChunkProgressListenerFactory chunkProgressListenerFactory
//#elseif MC > 1.17.1
//$$ Thread thread,
//$$ LevelStorageSource.LevelStorageAccess levelStorageAccess,
//$$ PackRepository packRepository,
//$$ WorldStem worldStem,
//$$ Proxy proxy,
//$$ DataFixer dataFixer,
//$$ MinecraftSessionService minecraftSessionService,
//$$ GameProfileRepository gameProfileRepository,
//$$ GameProfileCache gameProfileCache,
//$$ ChunkProgressListenerFactory chunkProgressListenerFactory
//#else
//$$ Thread thread,
//$$ RegistryAccess.RegistryHolder registryHolder,
//$$ LevelStorageSource.LevelStorageAccess levelStorageAccess,
//$$ WorldData worldData,
//$$ PackRepository packRepository,
//$$ WorldStem worldStem,
//$$ Proxy proxy,
//$$ DataFixer dataFixer,
//$$ ServerResources serverResources,
//$$ MinecraftSessionService minecraftSessionService,
//$$ GameProfileRepository gameProfileRepository,
//$$ GameProfileCache gameProfileCache,
Expand All @@ -83,10 +63,8 @@ public MixinIntegratedServer(
) {
//#if MC > 1.18.2
super(thread, levelStorageAccess, packRepository, worldStem, proxy, dataFixer, services, chunkProgressListenerFactory);
//#elseif MC > 1.17.1
//$$ super(thread, levelStorageAccess, packRepository, worldStem, proxy, dataFixer, minecraftSessionService, gameProfileRepository, gameProfileCache, chunkProgressListenerFactory);
//#else
//$$ super(thread, registryHolder, levelStorageAccess, worldData, packRepository, proxy, dataFixer, serverResources, minecraftSessionService, gameProfileRepository, gameProfileCache, chunkProgressListenerFactory);
//$$ super(thread, levelStorageAccess, packRepository, worldStem, proxy, dataFixer, minecraftSessionService, gameProfileRepository, gameProfileCache, chunkProgressListenerFactory);
//#endif
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.gaming32.worldhost.mixin;

import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.platform.Window;
import io.github.gaming32.worldhost.toast.WHToast;
import net.minecraft.client.Minecraft;
Expand All @@ -11,8 +12,6 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import static org.lwjgl.glfw.GLFW.GLFW_PRESS;

@Mixin(MouseHandler.class)
public class MixinMouseHandler {
@Shadow @Final private Minecraft minecraft;
Expand All @@ -31,7 +30,7 @@ public class MixinMouseHandler {
cancellable = true
)
private void toastClick(long windowPointer, int button, int action, int modifiers, CallbackInfo ci) {
if (action != GLFW_PRESS) return;
if (action != InputConstants.PRESS) return;
final Window window = minecraft.getWindow();
if (WHToast.click(
xpos * window.getGuiScaledWidth() / window.getScreenWidth(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
//#if FORGELIKE
//#if NEOFORGE
//$$ import net.neoforged.neoforge.internal.BrandingControl;
//#elseif MC > 1.17.1
//$$ import net.minecraftforge.internal.BrandingControl;
//#else
//$$ import net.minecraftforge.fmllegacy.BrandingControl;
//$$ import net.minecraftforge.internal.BrandingControl;
//#endif
//$$ import java.util.function.BiConsumer;
//#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package io.github.gaming32.worldhost.mixin;

import net.minecraft.client.gui.components.PlainTextButton;
import net.minecraft.network.chat.Component;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;

//#if MC > 1.17.1
import net.minecraft.client.gui.components.PlainTextButton;
//#else
//$$ import io.github.gaming32.worldhost.gui.PlainTextButton;
//#endif

@Mixin(PlainTextButton.class)
public interface PlainTextButtonAccessor {
@Mutable
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ description = "Host your singleplayer worlds without having to run a server or s
[[dependencies.world_host]]
##if FORGE
#?? modId = "forge"
#?? versionRange = "[32,)"
#?? versionRange = "[32,48)"
##else
modId = "neoforge"
versionRange = "[20,)"
versionRange = "[20,20.5)"
##endif
##if MC < 1.20.4
#?? mandatory = true
Expand All @@ -46,7 +46,7 @@ modId = "minecraft"
##elseif MC == 1.20.4
#?? versionRange = "[1.20.3,1.20.5)"
##else
versionRange = "$mc_version"
versionRange = "[$mc_version]"
##endif
##if MC < 1.20.4
#?? mandatory = true
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ config = "world-host.mixins.json"

[[dependencies.world_host]]
modId = "neoforge"
versionRange = "[20,)"
versionRange = "[20.5,)"
type = "required"
ordering = "NONE"
side = "BOTH"
Expand All @@ -29,7 +29,7 @@ modId = "minecraft"
##if MC == 1.20.6
versionRange = "[1.20.5,1.20.7)"
##else
#?? versionRange = "$mc_version"
#?? versionRange = "[$mc_version]"
##endif
type = "required"
ordering = "NONE"
Expand Down
Loading

0 comments on commit 8759d82

Please sign in to comment.