Skip to content

Commit

Permalink
Drop support for 1.16.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Apr 23, 2024
1 parent 4d9bc54 commit bd682e7
Show file tree
Hide file tree
Showing 23 changed files with 44 additions and 328 deletions.
6 changes: 0 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ preprocess {
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")
val fabric11605 = createNode("1.16.5-fabric", 1_16_05, "yarn")
val forge11605 = createNode("1.16.5-forge", 1_16_05, "srg")
val fabric11601 = createNode("1.16.1-fabric", 1_16_01, "yarn")

fabric12004.link(neoforge12004)
neoforge12004.link(neoforge12002)
Expand All @@ -39,9 +36,6 @@ preprocess {
forge11802.link(fabric11802)
fabric11802.link(fabric11701)
fabric11701.link(forge11701)
forge11701.link(forge11605)
forge11605.link(fabric11605)
fabric11605.link(fabric11601)

// subprojects {
// apply(plugin = "java")
Expand Down
3 changes: 0 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ rootProject.name = "world-host"
rootProject.buildFileName = "build.gradle.kts"

listOf(
"1.16.1-fabric",
"1.16.5-forge",
"1.16.5-fabric",
"1.17.1-forge",
"1.17.1-fabric",
"1.18.2-forge",
Expand Down
62 changes: 6 additions & 56 deletions src/main/java/io/github/gaming32/worldhost/WorldHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,15 @@
//$$ import net.minecraftforge.client.ConfigScreenHandler;
//#elseif MC >= 1.18.2
//$$ import net.minecraftforge.client.ConfigGuiHandler;
//#elseif MC >= 1.17.1
//$$ import net.minecraftforge.fmlclient.ConfigGuiHandler;
//#else
//$$ import net.minecraftforge.fml.ExtensionPoint;
//$$ import net.minecraftforge.fmlclient.ConfigGuiHandler;
//#endif
//#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;
//#else
//$$ import net.minecraftforge.fml.packs.ResourcePackLoader;
//$$ import net.minecraftforge.fmllegacy.packs.ResourcePackLoader;
//#endif
//#endif

Expand Down Expand Up @@ -247,11 +243,7 @@ private static void init() {
})
//#else
//$$ ResourcePackLoader
//#if MC > 1.16.5
//$$ .getPackFor(MOD_ID)
//#else
//$$ .getResourcePackFor(MOD_ID)
//#endif
//$$ .getPackFor(MOD_ID)
//#if MC >= 1.20.4
//$$ .map(c -> c.openPrimary("worldhost"))
//#endif
Expand Down Expand Up @@ -304,19 +296,11 @@ private static void init() {
).profileCache();
//#else
//$$ profileCache = new GameProfileCache(
//$$ new YggdrasilAuthenticationService(
//$$ Minecraft.getInstance().getProxy()
//#if MC <= 1.16.1
//$$ , UUID.randomUUID().toString()
//#endif
//$$ )
//$$ .createProfileRepository(),
//$$ new YggdrasilAuthenticationService(Minecraft.getInstance().getProxy()).createProfileRepository(),
//$$ new File(CACHE_DIR, "usercache.json")
//$$ );
//#endif
//#if MC > 1.16.5
profileCache.setExecutor(Util.backgroundExecutor());
//#endif

reconnect(false, true);

Expand Down Expand Up @@ -536,10 +520,8 @@ public static ResourceLocation getSkinLocationNow(GameProfile gameProfile) {
public static void getMaybeAsync(GameProfileCache cache, String name, Consumer<Optional<GameProfile>> action) {
//#if MC >= 1.20.2
cache.getAsync(name).thenAccept(action);
//#elseif MC > 1.16.5
//$$ cache.getAsync(name, action);
//#else
//$$ action.accept(Optional.ofNullable(cache.get(name)));
//$$ cache.getAsync(name, action);
//#endif
}

Expand All @@ -563,25 +545,6 @@ public static GameProfile fetchProfile(MinecraftSessionService sessionService, G
return fetchProfile(sessionService, profile.getId(), profile);
}

public static void texture(ResourceLocation texture) {
//#if MC > 1.16.5
RenderSystem.setShaderTexture(0, texture);
//#else
//$$ Minecraft.getInstance().getTextureManager().bind(texture);
//#endif
}

//#if MC <= 1.16.5
//$$ @SuppressWarnings("deprecation")
//#endif
public static void color(float r, float g, float b, float a) {
//#if MC > 1.16.5
RenderSystem.setShaderColor(r, g, b, a);
//#else
//$$ RenderSystem.color4f(r, g, b, a);
//#endif
}

public static boolean isFriend(UUID user) {
return CONFIG.isEnableFriends() && CONFIG.getFriends().contains(user);
}
Expand Down Expand Up @@ -611,18 +574,12 @@ public static FriendlyByteBuf createByteBuf() {

@SuppressWarnings("RedundantThrows")
public static ServerStatus parseServerStatus(FriendlyByteBuf buf) throws IOException {
//#if MC > 1.16.5
return new ClientboundStatusResponsePacket(buf)
//#if MC >= 1.19.4
.status();
//#else
//$$ .getStatus();
//#endif
//#else
//$$ final ClientboundStatusResponsePacket packet = new ClientboundStatusResponsePacket();
//$$ packet.read(buf);
//$$ return packet.getStatus();
//#endif
}

public static ServerStatus createEmptyServerStatus() {
Expand Down Expand Up @@ -724,7 +681,6 @@ public static void join(long connectionId, @Nullable Screen parentScreen) {

public static void connect(Screen parentScreen, long cid, String host, int port) {
final Minecraft minecraft = Minecraft.getInstance();
//#if MC > 1.16.5
final ServerAddress serverAddress = new ServerAddress(host, port);
ConnectScreen.startConnecting(
parentScreen, minecraft, serverAddress,
Expand All @@ -741,10 +697,6 @@ public static void connect(Screen parentScreen, long cid, String host, int port)
), false
//#endif
);
//#else
//$$ minecraft.setCurrentServer(null);
//$$ minecraft.setScreen(new ConnectScreen(parentScreen, minecraft, host, port));
//#endif
}

private static int ipCommand(CommandContext<CommandSourceStack> ctx) {
Expand Down Expand Up @@ -923,11 +875,9 @@ public static CompletableFuture<Optional<String>> checkForUpdates() {
//#if MC >= 1.19.2
//$$ ConfigScreenHandler.ConfigScreenFactory.class,
//$$ () -> new ConfigScreenHandler.ConfigScreenFactory(screenFunction)
//#elseif MC >= 1.17.1
//#else
//$$ ConfigGuiHandler.ConfigGuiFactory.class,
//$$ () -> new ConfigGuiHandler.ConfigGuiFactory(screenFunction)
//#else
//$$ ExtensionPoint.CONFIGGUIFACTORY, () -> screenFunction
//#endif
//$$ );
//$$ }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
//#if FABRIC
package io.github.gaming32.worldhost.compat;

import io.github.gaming32.worldhost.gui.screen.WorldHostConfigScreen;

//#if MC > 1.16.1
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
//#else
//$$ import io.github.prospector.modmenu.api.ConfigScreenFactory;
//$$ import io.github.prospector.modmenu.api.ModMenuApi;
//#endif
import io.github.gaming32.worldhost.gui.screen.WorldHostConfigScreen;

public class WorldHostModMenuCompat implements ModMenuApi {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void render(
if (friendProfile != null) {
assert minecraft != null;
final ResourceLocation skinTexture = WorldHost.getSkinLocationNow(friendProfile);
WorldHost.color(1f, 1f, 1f, 1f);
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
RenderSystem.enableBlend();
final int size = addFriendButton.getY() - 110;
final int x = width / 2 - size / 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ protected void init() {

if (list == null) {
list = new FriendsList();
//#if MC > 1.16.1
if (minecraft != null && minecraft.level != null) {
list.setRenderBackground(false);
}
//#endif
}
setListSize(list, 32, WorldHost.BEDROCK_SUPPORT ? 80 : 64);
addWidget(list);
Expand Down Expand Up @@ -174,7 +172,6 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {

public class FriendsList extends ObjectSelectionList<FriendsEntry> {
public FriendsList() {
//noinspection DataFlowIssue
super(
FriendsScreen.this.minecraft,
//#if MC >= 1.20.3
Expand Down Expand Up @@ -240,13 +237,11 @@ public FriendsEntry(GameProfile profile) {
);
}

//#if MC > 1.16.5
@NotNull
@Override
public Component getNarration() {
return Components.immutable(getName());
}
//#endif

@Override
public void render(
Expand All @@ -259,7 +254,7 @@ public void render(
int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta
) {
final ResourceLocation skinTexture = WorldHost.getSkinLocationNow(profile);
WorldHost.color(1f, 1f, 1f, 1f);
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
RenderSystem.enableBlend();
blit(context, skinTexture, x, y, 32, 32, 8, 8, 8, 8, 64, 64);
blit(context, skinTexture, x, y, 32, 32, 40, 8, 8, 8, 64, 64);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ public void friendsListUpdate(Map<UUID, Long> friends) {

public class OnlineFriendsList extends ObjectSelectionList<OnlineFriendsListEntry> {
public OnlineFriendsList() {
//noinspection DataFlowIssue
super(
OnlineFriendsScreen.this.minecraft,
//#if MC >= 1.20.3
Expand Down Expand Up @@ -311,13 +310,11 @@ public OnlineFriendsListEntry(UUID friendUuid, long connectionId) {
iconTextureId = new ResourceLocation("world-host", "servers/" + friendUuid + "/icon");
}

//#if MC >= 1.17.0
@NotNull
@Override
public Component getNarration() {
return Components.translatable("narrator.select", getName());
}
//#endif

@Override
public void render(
Expand Down Expand Up @@ -345,7 +342,7 @@ public void render(
final int labelWidth = font.width(sideLabel);
WorldHostScreen.drawString(context, font, sideLabel, x + entryWidth - labelWidth - 17, y + 1, 0x808080, false);

WorldHost.color(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
if (incompatibleVersion) {
RenderSystem.enableBlend();
blit(context, GUI_ICONS_LOCATION, x + entryWidth - 15, y, 0, 216, 10, 8, 256, 256);
Expand All @@ -364,15 +361,13 @@ public void render(
} else {
//#if MC >= 1.19.4
// Mojang did "@Nullable byte[]" instead of "byte @Nullable []"
//noinspection DataFlowIssue
serverInfo.setIconBytes(null);
//#else
//$$ serverInfo.setIconB64(null);
//#endif
}
}

// Since when does a value marked as @Nullable never satisfy == null?
//noinspection ConstantValue
if (icon == null) {
final ResourceLocation skinTexture = WorldHost.getSkinLocationNow(profile);
Expand All @@ -381,7 +376,7 @@ public void render(
blit(context, skinTexture, x, y, 32, 32, 40, 8, 8, 8, 64, 64);
RenderSystem.disableBlend();
} else {
WorldHost.texture(iconTextureId);
RenderSystem.setShaderTexture(0, iconTextureId);
RenderSystem.enableBlend();
blit(context, iconTextureId, x, y, 0, 0, 32, 32, 32, 32);
RenderSystem.disableBlend();
Expand All @@ -405,7 +400,7 @@ public void render(
|| hovered
) {
fill(context, x, y, x + 32, y + 32, 0xa0909090);
WorldHost.color(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
//#if MC >= 1.20.2
if (relX < 32 && relX > 16) {
context.blitSprite(JOIN_HIGHLIGHTED_SPRITE, x, y, 32, 32);
Expand Down Expand Up @@ -565,13 +560,11 @@ private boolean uploadServerIcon(
public boolean mouseClicked(double mouseX, double mouseY, int button) {
select(this);

//#if MC > 1.16.1
final double relX = mouseX - list.getRowLeft();
if (relX < 32.0 && relX > 16.0) {
connect();
return true;
}
//#endif

if (Util.getMillis() - clickTime < 250L) {
connect();
Expand Down
Loading

0 comments on commit bd682e7

Please sign in to comment.