Skip to content

Commit

Permalink
feat: 1.20.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Apehum committed Apr 26, 2024
1 parent b023124 commit 82e2418
Show file tree
Hide file tree
Showing 37 changed files with 534 additions and 123 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/prerelease-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ jobs:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: github
settings-path: ${{ github.workspace }}
distribution: temurin
java-version: |
8
16
17
21
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ jobs:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
distribution: temurin
java-version: |
8
16
17
21
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
Expand All @@ -45,6 +47,9 @@ jobs:
1.20
1.20.1
1.20.2
1.20.3
1.20.4
1.20.5
modrinth-unfeature-mode: 'subset'
modrinth-id: 1bZhdhsH
Expand All @@ -67,6 +72,9 @@ jobs:
1.20
1.20.1
1.20.2
1.20.3
1.20.4
1.20.5
modrinth-unfeature-mode: 'subset'
modrinth-id: 1bZhdhsH
Expand Down
2 changes: 0 additions & 2 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ subprojects {
configurations.api.get().allDependencies.forEach {
if (it is ProjectDependency) return@forEach

println(it.name)

val dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", it.group)
dependencyNode.appendNode("artifactId", it.name)
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ plugins {
alias(libs.plugins.idea.ext)
alias(libs.plugins.crowdin.plugin) apply(false)

kotlin("jvm") version("1.6.10")
kotlin("plugin.lombok") version("1.6.10")
kotlin("kapt") version("1.6.10")
kotlin("jvm") version("1.9.23")
kotlin("plugin.lombok") version("1.9.23")
kotlin("kapt") version("1.9.23")

id("gg.essential.multi-version.root") apply(false)
id("su.plo.voice.relocate") version("1.0.1") apply(false)
Expand Down
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {

dependencies {
implementation(libs.guava)
implementation(libs.gson) // not sure why, but there is somewhere old gson
}

repositories {
Expand Down
File renamed without changes.
Empty file added client/1.20.5-fabric/.gitkeep
Empty file.
12 changes: 7 additions & 5 deletions client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import gg.essential.gradle.multiversion.excludeKotlinDefaultImpls
import gg.essential.gradle.multiversion.mergePlatformSpecifics
import gg.essential.gradle.util.RelocationTransform.Companion.registerRelocationAttribute
import gg.essential.gradle.util.noServerRunConfigs
import gg.essential.util.prebundleNow
import gg.essential.gradle.util.prebundle

val mavenGroup: String by rootProject
val isMainProject = project.name == file("../mainProject").readText().trim()
Expand Down Expand Up @@ -54,7 +54,7 @@ val universalCraft by configurations.creating {

fun uStatsVersion() = rootProject.libs.versions.ustats.map {
val minecraftVersion = when (platform.mcVersion) {
12001, 12002, 12003 -> "1.20"
12001, 12002, 12004, 12005 -> "1.20"
else -> platform.mcVersionStr
}

Expand All @@ -76,7 +76,8 @@ dependencies {
11904 -> "0.76.0+1.19.4"
12001 -> "0.84.0+1.20.1"
12002 -> "0.89.1+1.20.2"
12003 -> "0.91.1+1.20.3"
12004 -> "0.97.0+1.20.4"
12005 -> "0.97.6+1.20.5"
else -> throw GradleException("Unsupported platform $platform")
}

Expand All @@ -89,8 +90,9 @@ dependencies {
}) {
isTransitive = false
}
modApi(prebundleNow(universalCraft))
shadowCommon(prebundleNow(universalCraft))
// prebundleNow was trying to access maven repo too early (?)
modApi(prebundle(universalCraft))
shadowCommon(prebundle(universalCraft))

"su.plo.ustats:${uStatsVersion()}".also {
modApi(it) {
Expand Down
1 change: 1 addition & 0 deletions client/changelog.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Fixed stacktrace spam on bad packets [#397](https://github.com/plasmoapp/plasmo-voice/issues/397)
- 1.20.5 support
2 changes: 1 addition & 1 deletion client/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
essential.defaults.loom=1
essential.defaults.loom.mappings=official
essential.defaults.loom.fabric-loader=net.fabricmc:fabric-loader:0.14.22
essential.defaults.loom.fabric-loader=net.fabricmc:fabric-loader:0.15.10

org.gradle.daemon=false
org.gradle.parallel=true
Expand Down
7 changes: 5 additions & 2 deletions client/root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ group = "$mavenGroup.client-root"

preprocess {

val fabric12003 = createNode("1.20.3-fabric", 12003, "official")
val fabric12005 = createNode("1.20.5-fabric", 12005, "official")
val fabric12004 = createNode("1.20.4-fabric", 12004, "official")

// val forge12002 = createNode("1.20.2-forge", 12002, "official")
val fabric12002 = createNode("1.20.2-fabric", 12002, "official")
Expand All @@ -21,7 +22,9 @@ preprocess {
val forge11902 = createNode("1.19.2-forge", 11902, "official")
val fabric11902 = createNode("1.19.2-fabric", 11902, "official")

fabric12003.link(fabric12002)
fabric12005.link(fabric12004)

fabric12004.link(fabric12002)

fabric12002.link(fabric12001, file("1.20.2-1.20.1.txt"))
// forge12002.link(fabric12002)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,39 @@

import java.util.List;

//#if MC>=12005
//$$ import com.mojang.serialization.JsonOps;
//$$ import com.google.gson.*;
//$$ import net.minecraft.network.chat.ComponentSerialization;
//#endif

public final class ComponentTextConverter implements MinecraftTextConverter<Component> {

//#if MC>=12005
//$$ private static final Gson GSON = (new GsonBuilder()).disableHtmlEscaping().create();
//#endif

@Override // todo: legacy
public @NotNull String convertToJson(@NotNull Component text) {
//#if MC>=12005
//$$ return GSON.toJson(
//$$ ComponentSerialization.CODEC.encodeStart(JsonOps.INSTANCE, text)
//$$ .getOrThrow(JsonParseException::new)
//$$ );
//#else
return Component.Serializer.toJson(text);
//#endif
}

@Override // todo: legacy
public Component convertFromJson(@NotNull String json) {
//#if MC>=12005
//$$ JsonElement jsonElement = JsonParser.parseString(json);
//$$ return jsonElement == null ? null : ComponentSerialization.CODEC.parse(JsonOps.INSTANCE, jsonElement)
//$$ .getOrThrow(JsonParseException::new);
//#else
return Component.Serializer.fromJson(json);
//#endif
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public final class ClientTextConverter extends TranslatableTextConverter<Compone

@Override
public @NotNull String convertToJson(@NotNull Component text) {
return Component.Serializer.toJson(text);
return textConverter.convertToJson(text);
}

@Override
public Component convertFromJson(@NotNull String json) {
return Component.Serializer.fromJson(json);
return textConverter.convertFromJson(json);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ public void setScrollTop(double scrollTop) {
}

protected void renderList(@NotNull UMatrixStack stack, int x, int y, int mouseX, int mouseY, float delta) {
//#if MC>=12005
//$$ RenderUtil.enableScissor(0, 0, width, y1 - y0 + 6);
//#else
RenderUtil.enableScissor(0, 0, width, y1 - y0 + 4);
//#endif
for (int index = 0; index < entries.size(); index++) {
Entry entry = entries.get(index);
EntryPosition position = entryPositions.get(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@

public interface GuiWidget {

//#if MC>=12005
//$$ ResourceLocation MENU_LIST_BACKGROUND_LOCATION = new ResourceLocation("textures/gui/menu_list_background.png");
//$$ ResourceLocation INWORLD_MENU_LIST_BACKGROUND_LOCATION = new ResourceLocation("textures/gui/inworld_menu_list_background.png");
//$$
//$$ ResourceLocation FOOTER_SEPARATOR_LOCATION = new ResourceLocation("textures/gui/footer_separator.png");
//$$ ResourceLocation INWORLD_FOOTER_SEPARATOR_LOCATION = new ResourceLocation("textures/gui/inworld_footer_separator.png");
//#else
ResourceLocation BACKGROUND_LOCATION = new ResourceLocation("textures/gui/options_background.png");
//#endif

int getWidth();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@

import static su.plo.lib.mod.server.utils.ServerPlayerKt.serverLevel;

//#if FABRIC
//#if MC>=12005
//$$ import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
//$$ import su.plo.voice.codec.PacketServicePayload;
//$$ import su.plo.voice.codec.PacketTcpPayload;
//$$ import su.plo.voice.proto.packets.Packet;
//$$ import su.plo.voice.proto.packets.PacketHandler;
//$$ import su.plo.voice.proto.packets.tcp.PacketTcpCodec;
//$$ import su.plo.voice.server.ModVoiceServer;
//$$
//$$ import java.io.IOException;
//$$ import com.google.common.io.ByteStreams;
//#endif
//#endif

//#if MC>=12002
//$$ import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
//$$ import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -102,11 +117,47 @@ public boolean isOnline() {

@Override
public void sendPacket(@NotNull String channel, byte[] data) {
//#if MC>=12005
//$$ try {
//$$ switch (channel) {
//$$ case ModVoiceServer.CHANNEL_STRING:
//$$ // todo: this is actually unnecessary re-encoding, but I don't think anything can be done without rewriting good chunk of code
//$$ // I'll try to fix it in slib and PV 2.1.x
//$$ Packet<PacketHandler> packet = PacketTcpCodec.decode(ByteStreams.newDataInput(data))
//$$ .orElseThrow(() -> new IOException("data is not Plasmo Voice packet"));
//$$
//$$ instance.connection.send(
//$$ ServerPlayNetworking.createS2CPacket(
//$$ new PacketTcpPayload(packet)
//$$ )
//$$ );
//$$
//$$ break;
//$$
//$$ case ModVoiceServer.SERVICE_CHANNEL_STRING:
//$$
//$$ instance.connection.send(
//$$ ServerPlayNetworking.createS2CPacket(
//$$ new PacketServicePayload(data)
//$$ )
//$$ );
//$$
//$$ break;
//$$
//$$ default:
//$$ throw new IllegalArgumentException("This method is now not supported for custom channels due to 1.20.5 changes. It'll be fixed in PV 2.1.x");
//$$ }
//$$ } catch (IOException e) {
//$$ e.printStackTrace();
//$$ return;
//$$ }
//#else
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
buf.writeResourceLocation(resources.getLocation(channel));
buf.writeBytes(data);

instance.connection.send(new ClientboundCustomPayloadPacket(buf));
//#endif
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

//#if MC>=11903
import net.minecraft.core.registries.BuiltInRegistries;

//#if MC>=12005
//$$ import net.minecraft.core.Holder;
//#endif

//#else
//$$ import net.minecraft.core.Registry;
//#endif
Expand Down Expand Up @@ -63,6 +68,13 @@ public int hashCode() {
}

//#if MC>=11900

//#if MC>=12005
//$$ private Holder.Reference<GameEvent> parseGameEvent(@NotNull String gameEventName) {
//$$ return BuiltInRegistries.GAME_EVENT.getHolder(new ResourceLocation(gameEventName))
//$$ .orElseThrow(() -> new IllegalArgumentException("Invalid game event"));
//$$ }
//#else
private GameEvent parseGameEvent(@NotNull String gameEventName) {
//#if MC>=11903
return BuiltInRegistries.GAME_EVENT.get(new ResourceLocation(gameEventName));
Expand All @@ -71,4 +83,6 @@ private GameEvent parseGameEvent(@NotNull String gameEventName) {
//#endif
}
//#endif

//#endif
}
26 changes: 25 additions & 1 deletion client/src/main/java/su/plo/voice/client/ModVoiceClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;

//#if MC>=12005
//$$ import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
//$$ import su.plo.voice.codec.PacketFlagTcpPayload;
//$$ import su.plo.voice.codec.PacketFlagTcpPayloadCodec;
//$$ import su.plo.voice.codec.PacketTcpPayload;
//$$ import su.plo.voice.codec.PacketTcpPayloadCodec;
//#endif

//#else
//$$ import net.minecraftforge.fml.common.Mod;
//$$ import net.minecraftforge.api.distmarker.Dist;
Expand Down Expand Up @@ -134,12 +143,27 @@ public void onInitializeClient() {

ClientLifecycleEvents.CLIENT_STOPPING.register((minecraft) -> onShutdown());
HudRenderCallback.EVENT.register(hudRenderer::render);
WorldRenderEvents.END.register(
WorldRenderEvents.LAST.register(
(context) -> levelRenderer.render(context.world(), context.matrixStack(), context.camera(), context.tickDelta())
);
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> onServerDisconnect());

//#if MC>=12005
//$$ PayloadTypeRegistry.playS2C().register(
//$$ PacketTcpPayload.TYPE,
//$$ new PacketTcpPayloadCodec()
//$$ );
//$$ ClientPlayNetworking.registerGlobalReceiver(PacketTcpPayload.TYPE, handler);
//$$
//$$ PayloadTypeRegistry.playS2C().register(
//$$ PacketFlagTcpPayload.TYPE,
//$$ new PacketFlagTcpPayloadCodec()
//$$ );
//$$ ClientPlayNetworking.registerGlobalReceiver(PacketFlagTcpPayload.TYPE, (payload, context) -> {});
//#else
ClientPlayNetworking.registerGlobalReceiver(ModVoiceServer.CHANNEL, handler);
ClientPlayNetworking.registerGlobalReceiver(ModVoiceServer.FLAG_CHANNEL, (client, handler, buf, responseSender) -> {});
//#endif

KeyBindingHelper.registerKeyBinding(MENU_KEY);
}
Expand Down
Loading

0 comments on commit 82e2418

Please sign in to comment.