From e3f2d7c72724efd8c9ad88b98daec9f36b5033b0 Mon Sep 17 00:00:00 2001 From: MattiDragon <61198884+MattiDragon@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:12:35 +0300 Subject: [PATCH] Update to 1.20.2 --- .github/workflows/publish.yaml | 71 ++++--------------- build.gradle | 11 +-- changelog/2.0.0+1.20.1.md | 11 --- changelog/2.0.1+1.20.1.md | 3 - changelog/2.0.1+1.20.2.md | 1 + gradle.properties | 18 ++--- gradle/wrapper/gradle-wrapper.properties | 2 +- .../client/PowerNetworksClient.java | 6 ++ .../client/config/ConfigClient.java | 7 +- .../config/PlayerHeadImageRenderer.java | 4 +- .../powernetworks/PowerNetworks.java | 2 +- .../powernetworks/datagen/RecipeProvider.java | 8 +-- .../mixin/EntityAttachS2CPacketAccess.java | 4 +- .../networking/PowerNetworksNetworking.java | 9 ++- .../virtual/LeashSourceElement.java | 4 +- 15 files changed, 53 insertions(+), 108 deletions(-) delete mode 100644 changelog/2.0.0+1.20.1.md delete mode 100644 changelog/2.0.1+1.20.1.md create mode 100644 changelog/2.0.1+1.20.2.md diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 0d8bf68..14db151 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -8,64 +8,19 @@ on: required: true type: choice options: ["release", "beta", "alpha"] + minecraft-versions: + description: Overrides for supported versions + required: false + type: string jobs: publish: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Gradle Caching - uses: burrunan/gradle-cache-action@v1 - with: - gradle-distribution-sha-256-sum-warning: false - - - name: Set up JDK - uses: actions/setup-java@v2 - with: - java-version: '17' - distribution: 'temurin' - cache: 'gradle' - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Build with Gradle - run: ./gradlew build - - - name: Read mod version - id: versions - uses: christian-draeger/read-properties@1.1.0 - with: - path: gradle.properties - properties: "mod_version minecraft_version" - - - name: Read changelog - uses: juliangruber/read-file-action@v1 - id: changelog - with: - path: "./changelog/${{ steps.versions.outputs.mod_version }}+${{ steps.versions.outputs.minecraft_version }}.md" - - - name: Publish - uses: Kir-Antipov/mc-publish@v3.2 - with: - name: "v${{ steps.versions.outputs.mod_version }} [${{ steps.versions.outputs.minecraft_version }}]" - version: ${{ steps.versions.outputs.mod_version }}+mc.${{ steps.versions.outputs.minecraft_version }} - version-type: ${{ inputs.version-type }} - - loaders: fabric quilt - java: 17 18 19 20 - - game-versions: ${{ steps.versions.outputs.minecraft_version }} - changelog: ${{ steps.changelog.outputs.content }} - - modrinth-token: ${{ secrets.MODRINTH_TOKEN }} - modrinth-id: 8cCfmdw2 - modrinth-featured: false - - curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} - curseforge-id: 842545 - - github-token: ${{ secrets.GITHUB_TOKEN }} - github-tag: ${{ steps.versions.outputs.mod_version }}+mc.${{ steps.versions.outputs.minecraft_version }} + uses: MattiDragon/MattiDragon/.github/workflows/publish-mc-mod.yaml@c066f67d80ff22e0b63bb5ad5c4ac83f583ad211 + with: + version-type: ${{ inputs.version-type }} + minecraft-versions: ${{ inputs.minecraft-versions }} + modrinth-id: 8cCfmdw2 + curseforge-id: 842545 + secrets: + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} diff --git a/build.gradle b/build.gradle index 52c0aae..e13e654 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ plugins { - id 'fabric-loom' version '1.3-SNAPSHOT' - id 'io.github.juuxel.loom-vineflower' version '1.11.0' + id 'fabric-loom' version '1.4-SNAPSHOT' id 'maven-publish' } version project.mod_version + "+mc.$minecraft_version" group project.maven_group +base.archivesName = project.archives_base_name repositories { maven { url "https://maven.nucleoid.xyz" } @@ -13,6 +13,8 @@ repositories { maven { url "https://maven.alexiil.uk/" } maven { url "https://maven.isxander.dev/releases" } maven { url "https://maven.terraformersmc.com" } + maven { url "https://oss.sonatype.org/content/repositories/snapshots" } + maven { url 'https://maven.quiltmc.org/repository/release/' } mavenLocal() maven { url "https://jitpack.io" } } @@ -36,10 +38,10 @@ dependencies { modImplementation include("xyz.nucleoid:server-translations-api:$server_translation_api_version") modImplementation include("teamreborn:energy:$energy_version") modImplementation include("com.kneelawk:graphlib:$graphlib_version") - modImplementation include("com.github.mattidragon:ConfigToolkit:$configtoolkit_version") - annotationProcessor clientAnnotationProcessor("com.github.mattidragon:ConfigToolkit:$configtoolkit_version") // Config + modImplementation include("com.github.mattidragon:ConfigToolkit:$configtoolkit_version") + annotationProcessor clientAnnotationProcessor("com.github.mattidragon:ConfigToolkit:$configtoolkit_version") modImplementation include("dev.isxander.yacl:yet-another-config-lib-fabric:$yacl_version") modImplementation "com.terraformersmc:modmenu:$modmenu_version" @@ -94,7 +96,6 @@ tasks.withType(JavaCompile).configureEach { } java { - archivesBaseName = project.archives_base_name withSourcesJar() } diff --git a/changelog/2.0.0+1.20.1.md b/changelog/2.0.0+1.20.1.md deleted file mode 100644 index fa2202a..0000000 --- a/changelog/2.0.0+1.20.1.md +++ /dev/null @@ -1,11 +0,0 @@ -* Update to 1.20 -* Rework how config is organized and internally represented -* Add network analyser -* Rework how energy is stored and distributed - * The network now has one shared buffer -* Split transfer rate and capacity -* Improve client rendering - * Held wire item connections now render with client rendering - * Graph data is directly used, allowing for better consistency -* Connections are now actually stored in graphlib, fixing many issues -* Many bugfixes that I forgot to document \ No newline at end of file diff --git a/changelog/2.0.1+1.20.1.md b/changelog/2.0.1+1.20.1.md deleted file mode 100644 index 4e6dd36..0000000 --- a/changelog/2.0.1+1.20.1.md +++ /dev/null @@ -1,3 +0,0 @@ -* Use alternative methods in graphlib code for better compatibility -* Add option to disable adventure mode interaction -* Add analyzer to creative tab \ No newline at end of file diff --git a/changelog/2.0.1+1.20.2.md b/changelog/2.0.1+1.20.2.md new file mode 100644 index 0000000..6668318 --- /dev/null +++ b/changelog/2.0.1+1.20.2.md @@ -0,0 +1 @@ +* Update to 1.20.2 \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 127283f..7ddfade 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,20 +1,20 @@ org.gradle.jvmargs=-Xmx1G org.gradle.parallel=true -minecraft_version=1.20.1 -yarn_mappings=1.20.1+build.9 -loader_version=0.14.21 +minecraft_version=1.20.2 +yarn_mappings=1.20.2+build.2 +loader_version=0.14.22 mod_version=2.0.1 maven_group=io.github.mattidragon.powernetworks archives_base_name=power-networks -fabric_api_version=0.85.0+1.20.1 -mixin_extras_version=0.2.0-beta.9 -polymer_version=0.5.5+1.20.1 -graphlib_version=1.1.1+1.20 +fabric_api_version=0.89.3+1.20.2 +mixin_extras_version=0.2.0-rc.5 +polymer_version=0.6.0+1.20.2 +graphlib_version=1.4.0+1.20.2 server_translation_api_version=2.0.0+1.20 energy_version=3.0.0 -yacl_version=3.0.3+1.20 -modmenu_version=7.1.0 +yacl_version=3.2.1+1.20.2 +modmenu_version=8.0.0 configtoolkit_version=1.0.0 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0c85a1f..c30b486 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/client/java/io/github/mattidragon/powernetworks/client/PowerNetworksClient.java b/src/client/java/io/github/mattidragon/powernetworks/client/PowerNetworksClient.java index cdb3fc2..d907f69 100644 --- a/src/client/java/io/github/mattidragon/powernetworks/client/PowerNetworksClient.java +++ b/src/client/java/io/github/mattidragon/powernetworks/client/PowerNetworksClient.java @@ -1,13 +1,16 @@ package io.github.mattidragon.powernetworks.client; +import eu.pb4.polymer.networking.api.client.PolymerClientNetworking; import io.github.mattidragon.powernetworks.block.ModBlocks; import io.github.mattidragon.powernetworks.client.config.ConfigClient; import io.github.mattidragon.powernetworks.client.renderer.CoilBlockEntityRenderer; import io.github.mattidragon.powernetworks.networking.ConfigEditPackets; +import io.github.mattidragon.powernetworks.networking.PowerNetworksNetworking; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.block.entity.BlockEntityRendererFactories; +import net.minecraft.nbt.NbtByte; public class PowerNetworksClient implements ClientModInitializer { @Override @@ -17,5 +20,8 @@ public void onInitializeClient() { ClientPlayNetworking.registerGlobalReceiver(ConfigEditPackets.StartEditingPacket.TYPE, (packet, player, responseSender) -> MinecraftClient.getInstance().setScreen(ConfigClient.createScreen(null, packet.config(), config -> responseSender.sendPacket(new ConfigEditPackets.ApplyChangesPacket(config))))); + + PolymerClientNetworking.setClientMetadata(PowerNetworksNetworking.CLIENT_RENDERING, NbtByte.ONE); + PolymerClientNetworking.setClientMetadata(PowerNetworksNetworking.CLIENT_EDITING, NbtByte.ONE); } } \ No newline at end of file diff --git a/src/client/java/io/github/mattidragon/powernetworks/client/config/ConfigClient.java b/src/client/java/io/github/mattidragon/powernetworks/client/config/ConfigClient.java index 324503e..9791b5b 100644 --- a/src/client/java/io/github/mattidragon/powernetworks/client/config/ConfigClient.java +++ b/src/client/java/io/github/mattidragon/powernetworks/client/config/ConfigClient.java @@ -17,12 +17,11 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; -import java.util.function.Function; import static io.github.mattidragon.powernetworks.config.ConfigData.DEFAULT; public class ConfigClient { - public static final Function FLOAT_FORMATTER; + public static final ValueFormatter FLOAT_FORMATTER; static { var format = NumberFormat.getNumberInstance(Locale.ROOT); @@ -217,13 +216,13 @@ private static ConfigCategory createClientCategory(MutableClientCategory instanc .name(Text.translatable("config.power_networks.client.wireWidth")) .description(OptionDescription.of(Text.translatable("config.power_networks.client.wireWidth.description"))) .binding(DEFAULT.client().wireWidth(), instance::wireWidth, instance::wireWidth) - .controller(option -> FloatFieldControllerBuilder.create(option).range(0f, 1f).valueFormatter(FLOAT_FORMATTER)) + .controller(option -> FloatFieldControllerBuilder.create(option).range(0f, 1f).formatValue(FLOAT_FORMATTER)) .build()) .option(Option.createBuilder() .name(Text.translatable("config.power_networks.client.hangFactor")) .description(OptionDescription.of(Text.translatable("config.power_networks.client.hangFactor.description"))) .binding(DEFAULT.client().hangFactor(), instance::hangFactor, instance::hangFactor) - .controller(option -> FloatFieldControllerBuilder.create(option).range(0f, 1f).valueFormatter(FLOAT_FORMATTER)) + .controller(option -> FloatFieldControllerBuilder.create(option).range(0f, 1f).formatValue(FLOAT_FORMATTER)) .build()) .group(ListOption.createBuilder() .initial(Color.BLACK) diff --git a/src/client/java/io/github/mattidragon/powernetworks/client/config/PlayerHeadImageRenderer.java b/src/client/java/io/github/mattidragon/powernetworks/client/config/PlayerHeadImageRenderer.java index fc4f9d3..d6a3f34 100644 --- a/src/client/java/io/github/mattidragon/powernetworks/client/config/PlayerHeadImageRenderer.java +++ b/src/client/java/io/github/mattidragon/powernetworks/client/config/PlayerHeadImageRenderer.java @@ -2,7 +2,7 @@ import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; -import dev.isxander.yacl3.gui.ImageRenderer; +import dev.isxander.yacl3.gui.image.ImageRenderer; import net.minecraft.block.SkullBlock; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; @@ -27,7 +27,7 @@ public PlayerHeadImageRenderer(String value) { } @Override - public int render(DrawContext graphics, int x, int y, int renderWidth) { + public int render(DrawContext graphics, int x, int y, int renderWidth, float tickDelta) { var client = MinecraftClient.getInstance(); int size = renderWidth / 2; time += client.getLastFrameDuration(); diff --git a/src/main/java/io/github/mattidragon/powernetworks/PowerNetworks.java b/src/main/java/io/github/mattidragon/powernetworks/PowerNetworks.java index ea8165e..425a544 100644 --- a/src/main/java/io/github/mattidragon/powernetworks/PowerNetworks.java +++ b/src/main/java/io/github/mattidragon/powernetworks/PowerNetworks.java @@ -1,7 +1,7 @@ package io.github.mattidragon.powernetworks; import eu.pb4.polymer.core.api.item.PolymerItemGroupUtils; -import eu.pb4.polymer.networking.api.PolymerServerNetworking; +import eu.pb4.polymer.networking.api.server.PolymerServerNetworking; import io.github.mattidragon.configloader.api.ConfigManager; import io.github.mattidragon.powernetworks.block.ModBlocks; import io.github.mattidragon.powernetworks.config.ConfigData; diff --git a/src/main/java/io/github/mattidragon/powernetworks/datagen/RecipeProvider.java b/src/main/java/io/github/mattidragon/powernetworks/datagen/RecipeProvider.java index 3bdd575..d7f6e35 100644 --- a/src/main/java/io/github/mattidragon/powernetworks/datagen/RecipeProvider.java +++ b/src/main/java/io/github/mattidragon/powernetworks/datagen/RecipeProvider.java @@ -3,21 +3,19 @@ import io.github.mattidragon.powernetworks.item.ModItems; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider; -import net.minecraft.data.server.recipe.RecipeJsonProvider; +import net.minecraft.data.server.recipe.RecipeExporter; import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder; import net.minecraft.item.Item; import net.minecraft.item.Items; import net.minecraft.recipe.book.RecipeCategory; -import java.util.function.Consumer; - public class RecipeProvider extends FabricRecipeProvider { RecipeProvider(FabricDataOutput output) { super(output); } @Override - public void generate(Consumer exporter) { + public void generate(RecipeExporter exporter) { ShapedRecipeJsonBuilder.create(RecipeCategory.REDSTONE, ModItems.WIRE, 16) .input('I', Items.COPPER_INGOT) .input('N', Items.IRON_NUGGET) @@ -32,7 +30,7 @@ public void generate(Consumer exporter) { createCoilRecipe(ModItems.ULTIMATE_COIL, Items.NETHERITE_INGOT, exporter); } - private static void createCoilRecipe(Item coil, Item material, Consumer exporter) { + private static void createCoilRecipe(Item coil, Item material, RecipeExporter exporter) { ShapedRecipeJsonBuilder.create(RecipeCategory.REDSTONE, coil, 2) .input('I', material) .input('W', ModItems.WIRE) diff --git a/src/main/java/io/github/mattidragon/powernetworks/mixin/EntityAttachS2CPacketAccess.java b/src/main/java/io/github/mattidragon/powernetworks/mixin/EntityAttachS2CPacketAccess.java index 4e9a41c..602c321 100644 --- a/src/main/java/io/github/mattidragon/powernetworks/mixin/EntityAttachS2CPacketAccess.java +++ b/src/main/java/io/github/mattidragon/powernetworks/mixin/EntityAttachS2CPacketAccess.java @@ -9,9 +9,9 @@ public interface EntityAttachS2CPacketAccess { @Mutable @Accessor - void setAttachedId(int value); + void setAttachedEntityId(int value); @Mutable @Accessor - void setHoldingId(int value); + void setHoldingEntityId(int value); } diff --git a/src/main/java/io/github/mattidragon/powernetworks/networking/PowerNetworksNetworking.java b/src/main/java/io/github/mattidragon/powernetworks/networking/PowerNetworksNetworking.java index ebadfcf..501669e 100644 --- a/src/main/java/io/github/mattidragon/powernetworks/networking/PowerNetworksNetworking.java +++ b/src/main/java/io/github/mattidragon/powernetworks/networking/PowerNetworksNetworking.java @@ -1,8 +1,9 @@ package io.github.mattidragon.powernetworks.networking; -import eu.pb4.polymer.networking.api.PolymerServerNetworking; +import eu.pb4.polymer.networking.api.server.PolymerServerNetworking; import io.github.mattidragon.powernetworks.PowerNetworks; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.nbt.NbtByte; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -13,9 +14,6 @@ public class PowerNetworksNetworking { public static final Identifier CLIENT_EDITING = PowerNetworks.id("client_editing"); public static void register() { - PolymerServerNetworking.registerSendPacket(CLIENT_RENDERING, 0); - PolymerServerNetworking.registerSendPacket(CLIENT_EDITING, 0); - ServerPlayNetworking.registerGlobalReceiver(ConfigEditPackets.ApplyChangesPacket.TYPE, (packet, player, responseSender) -> { if (!player.hasPermissionLevel(2) || !PowerNetworks.CONFIG.get().misc().allowRemoteEdits()) { player.sendMessage(Text.translatable("power_networks.config_edit.denied").formatted(Formatting.RED)); @@ -27,6 +25,7 @@ public static void register() { } public static boolean supportsClientRendering(ServerPlayerEntity player) { - return PolymerServerNetworking.getSupportedVersion(player.networkHandler, CLIENT_RENDERING) == 0; + var value = PolymerServerNetworking.getMetadata(player.networkHandler, CLIENT_RENDERING, NbtByte.TYPE); + return value != null && value.byteValue() == 1; } } diff --git a/src/main/java/io/github/mattidragon/powernetworks/virtual/LeashSourceElement.java b/src/main/java/io/github/mattidragon/powernetworks/virtual/LeashSourceElement.java index 9309c85..06ac759 100644 --- a/src/main/java/io/github/mattidragon/powernetworks/virtual/LeashSourceElement.java +++ b/src/main/java/io/github/mattidragon/powernetworks/virtual/LeashSourceElement.java @@ -37,8 +37,8 @@ public void startWatching(ServerPlayerEntity player, Consumer