From 4f792f2ed42eb13a1c63ac3d5d4424357aac5a2b Mon Sep 17 00:00:00 2001 From: okx-code Date: Wed, 21 Aug 2024 20:47:04 +0100 Subject: [PATCH] Update to 1.21.1 --- .github/workflows/release.yml | 34 ------------- build.gradle | 5 -- .../gui/screen/CompactedConfigScreen.java | 2 +- .../gui/screen/IceRoadConfigScreen.java | 3 +- .../common/gui/screen/RadarConfigScreen.java | 2 +- .../common/gui/widget/HsbColourPicker.java | 29 ++++++----- .../sh/okx/civmodern/common/radar/Radar.java | 49 +++++++++---------- .../fabric/FabricCivModernBootstrap.java | 2 +- gradle.properties | 10 ++-- 9 files changed, 45 insertions(+), 91 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 5760a2e..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: "CivModern Release Gradle CI" - -on: - release: - types: [published] - -permissions: - contents: write - -jobs: - release: - runs-on: "ubuntu-latest" - steps: - - uses: "actions/checkout@v3" - - - name: "Set up JDK 21" - uses: "actions/setup-java@v3" - with: - java-version: 21 - distribution: "corretto" - cache: "gradle" - - - name: "Compiling CivModern" - run: "./gradlew build" - - - name: "Publishing CivModern" - run: | - gh release upload ${{ github.event.release.tag_name }} "LICENSE.txt" --clobber - for file in $(find "dist/" -maxdepth 1 -type f -name "*.jar"); do - echo "Uploading $file" - gh release upload ${{ github.event.release.tag_name }} "$file" --clobber - done - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle b/build.gradle index 1efd4a5..7d01a16 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,6 @@ subprojects { minecraft("com.mojang:minecraft:${rootProject.minecraft_version}") mappings(loom.layered() { officialMojangMappings() - parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip") }) } } @@ -36,10 +35,6 @@ allprojects { group = rootProject.maven_group repositories { - maven { - name = "ParchmentMC" - url = "https://maven.parchmentmc.org" - } maven { url "https://api.modrinth.com/maven" content { diff --git a/common/src/main/java/sh/okx/civmodern/common/gui/screen/CompactedConfigScreen.java b/common/src/main/java/sh/okx/civmodern/common/gui/screen/CompactedConfigScreen.java index d7daa89..8f04d3c 100644 --- a/common/src/main/java/sh/okx/civmodern/common/gui/screen/CompactedConfigScreen.java +++ b/common/src/main/java/sh/okx/civmodern/common/gui/screen/CompactedConfigScreen.java @@ -85,7 +85,7 @@ protected void init() { config.setColour(colour); }, colourProvider::setTemporaryCompactedColour, () -> {}); - addRenderableWidget(new ImageButton(leftWidth + 60 + 8 + 20 + 8, height / 6, 20, 20, new ResourceLocation("civmodern", "gui/rollback.png"), imbg -> { + addRenderableWidget(new ImageButton(leftWidth + 60 + 8 + 20 + 8, height / 6, 20, 20, ResourceLocation.tryBuild("civmodern", "gui/rollback.png"), imbg -> { int colour = 0xffff58; widget.setValue("#FFFF58"); config.setColour(colour); diff --git a/common/src/main/java/sh/okx/civmodern/common/gui/screen/IceRoadConfigScreen.java b/common/src/main/java/sh/okx/civmodern/common/gui/screen/IceRoadConfigScreen.java index 03c9829..a53356d 100644 --- a/common/src/main/java/sh/okx/civmodern/common/gui/screen/IceRoadConfigScreen.java +++ b/common/src/main/java/sh/okx/civmodern/common/gui/screen/IceRoadConfigScreen.java @@ -47,9 +47,8 @@ protected void init() { @Override public void render(GuiGraphics guiGraphics, int i, int j, float f) { - super.render(guiGraphics, i, j, f); - guiGraphics.drawString(font, this.title, (int) (this.width / 2f - font.width(this.title) / 2f), 15, 0xffffff); + super.render(guiGraphics, i, j, f); } @Override diff --git a/common/src/main/java/sh/okx/civmodern/common/gui/screen/RadarConfigScreen.java b/common/src/main/java/sh/okx/civmodern/common/gui/screen/RadarConfigScreen.java index acdbabb..44256da 100644 --- a/common/src/main/java/sh/okx/civmodern/common/gui/screen/RadarConfigScreen.java +++ b/common/src/main/java/sh/okx/civmodern/common/gui/screen/RadarConfigScreen.java @@ -30,7 +30,7 @@ public class RadarConfigScreen extends Screen implements ScreenCloseable { - public static final ResourceLocation ROLLBACK_ICON = new ResourceLocation("civmodern", "gui/rollback.png"); + public static final ResourceLocation ROLLBACK_ICON = ResourceLocation.tryBuild("civmodern", "gui/rollback.png"); private final List renderables = new ArrayList<>(); // copied from Screen because it's private there private final AbstractCivModernMod mod; private final CivMapConfig config; diff --git a/common/src/main/java/sh/okx/civmodern/common/gui/widget/HsbColourPicker.java b/common/src/main/java/sh/okx/civmodern/common/gui/widget/HsbColourPicker.java index c248179..5c0c6c8 100644 --- a/common/src/main/java/sh/okx/civmodern/common/gui/widget/HsbColourPicker.java +++ b/common/src/main/java/sh/okx/civmodern/common/gui/widget/HsbColourPicker.java @@ -22,7 +22,7 @@ public class HsbColourPicker extends AbstractWidget { - private static final ResourceLocation COLOUR_PICKER_ICON = new ResourceLocation("civmodern", "gui/colour.png"); + private static final ResourceLocation COLOUR_PICKER_ICON = ResourceLocation.tryBuild("civmodern", "gui/colour.png"); private final Texture hueSelector; private final Texture saturationBrightnessTexture; @@ -81,25 +81,24 @@ public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float // Saturation and brightness selector RenderSystem.setShader(GameRenderer::getPositionTexShader); Matrix4f matrix4f = guiGraphics.pose().last().pose(); - BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder(); - - bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); - bufferBuilder.vertex(matrix4f, this.getX(), renderY + height, 0).uv(0, 0).endVertex(); - bufferBuilder.vertex(matrix4f, this.getX(), renderY + height + 128, 0).uv(0, 1).endVertex(); - bufferBuilder.vertex(matrix4f, this.getX() + 128, renderY + height + 128, 0).uv(1, 1).endVertex(); - bufferBuilder.vertex(matrix4f, this.getX() + 128, renderY + height, 0).uv(1, 0).endVertex(); - BufferUploader.drawWithShader(bufferBuilder.end()); + BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); + + bufferBuilder.addVertex(matrix4f, this.getX(), renderY + height, 0).setUv(0, 0); + bufferBuilder.addVertex(matrix4f, this.getX(), renderY + height + 128, 0).setUv(0, 1); + bufferBuilder.addVertex(matrix4f, this.getX() + 128, renderY + height + 128, 0).setUv(1, 1); + bufferBuilder.addVertex(matrix4f, this.getX() + 128, renderY + height, 0).setUv(1, 0); + BufferUploader.drawWithShader(bufferBuilder.buildOrThrow()); // guiGraphics.blit(this.saturationBrightnessTexture, this.getX(), renderY + height, 0, 0, 0, 101, 101, 128, 128); // Hue selector hueSelector.bind(); RenderSystem.setShader(GameRenderer::getPositionTexShader); - bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); - bufferBuilder.vertex(matrix4f, this.getX() + 106, renderY + height, 0).uv(0, 0).endVertex(); - bufferBuilder.vertex(matrix4f, this.getX() + 106, renderY + height + 101, 0).uv(0, 1).endVertex(); - bufferBuilder.vertex(matrix4f, this.getX() + 106 + 10, renderY + height + 101, 0).uv(1, 1).endVertex(); - bufferBuilder.vertex(matrix4f, this.getX() + 106 + 10, renderY + height, 0).uv(1, 0).endVertex(); - BufferUploader.drawWithShader(bufferBuilder.end()); + bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); + bufferBuilder.addVertex(matrix4f, this.getX() + 106, renderY + height, 0).setUv(0, 0); + bufferBuilder.addVertex(matrix4f, this.getX() + 106, renderY + height + 101, 0).setUv(0, 1); + bufferBuilder.addVertex(matrix4f, this.getX() + 106 + 10, renderY + height + 101, 0).setUv(1, 1); + bufferBuilder.addVertex(matrix4f, this.getX() + 106 + 10, renderY + height, 0).setUv(1, 0); + BufferUploader.drawWithShader(bufferBuilder.buildOrThrow()); // Gui.blit(matrixStack, this.x + 106, renderY + height, 10, 101, 0, 0, 1, 360, 1, 360); RenderSystem.disableBlend(); diff --git a/common/src/main/java/sh/okx/civmodern/common/radar/Radar.java b/common/src/main/java/sh/okx/civmodern/common/radar/Radar.java index b1fb4db..ed17aa1 100644 --- a/common/src/main/java/sh/okx/civmodern/common/radar/Radar.java +++ b/common/src/main/java/sh/okx/civmodern/common/radar/Radar.java @@ -4,6 +4,7 @@ import com.mojang.blaze3d.platform.Lighting; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.BufferUploader; import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; @@ -343,14 +344,14 @@ private void renderPlayers(GuiGraphics guiGraphics, float delta) { if (entry != null) { location = entry.getSkin().texture(); } else { - location = new ResourceLocation("textures/entity/steve.png"); + location = ResourceLocation.withDefaultNamespace("textures/entity/steve.png"); } guiGraphics.blit(location, -4, -4, 8, 8, 8.0F, 8, 8, 8, 64, 64); RenderSystem.disableBlend(); guiGraphics.pose().scale(0.6f, 0.6f, 0); Component component = Component.literal( player.getScoreboardName() + " (" + (hideY() ? ((int) Math.round(Math.sqrt(dx * dx + dz * dz))) : (int) player.getY()) + ")"); - minecraft.font.drawInBatch(component, -minecraft.font.width(component) / 2f, 7, 0xffffff, false, guiGraphics.pose().last().pose(), guiGraphics.bufferSource(), Font.DisplayMode.NORMAL, 0, 0); + minecraft.font.drawInBatch(component, -minecraft.font.width(component) / 2f, 7, 0xffffff, false, guiGraphics.pose().last().pose(), guiGraphics.bufferSource(), Font.DisplayMode.NORMAL, 0, 0xff); guiGraphics.pose().popPose(); } @@ -363,16 +364,15 @@ private void renderCircleBackground(PoseStack stack) { RenderSystem.setShader(GameRenderer::getPositionColorShader); Tesselator tessellator = Tesselator.getInstance(); - BufferBuilder buffer = tessellator.getBuilder(); - buffer.begin(Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR); + BufferBuilder buffer = tessellator.begin(Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR); float radius = radius() + 0.5f; for (int i = 0; i <= 360; i++) { float x = (float) Math.sin(i * Math.PI / 180.0D) * radius; float y = (float) Math.cos(i * Math.PI / 180.0D) * radius; - buffer.vertex(stack.last().pose(), x, y, 0).color(bgColour).endVertex(); + buffer.addVertex(stack.last().pose(), x, y, 0).setColor(bgColour); } - tessellator.end(); + BufferUploader.drawWithShader(buffer.buildOrThrow()); RenderSystem.disableBlend(); } @@ -384,8 +384,7 @@ private void renderCircleBorder(PoseStack stack, float radius) { RenderSystem.setShader(GameRenderer::getPositionColorShader); Tesselator tessellator = Tesselator.getInstance(); - BufferBuilder buffer = tessellator.getBuilder(); - buffer.begin(Mode.TRIANGLE_STRIP, DefaultVertexFormat.POSITION_COLOR); + BufferBuilder buffer = tessellator.begin(Mode.TRIANGLE_STRIP, DefaultVertexFormat.POSITION_COLOR); float thickness = radius == radius() ? 1f : 0.5f; @@ -396,10 +395,10 @@ private void renderCircleBorder(PoseStack stack, float radius) { float x1 = (float) Math.sin(i * Math.PI / 180.0D) * (radius + thickness); float y1 = (float) Math.cos(i * Math.PI / 180.0D) * (radius + thickness); - buffer.vertex(pose, x0, y0, 0).color(fgColour).endVertex(); - buffer.vertex(pose, x1, y1, 0).color(fgColour).endVertex(); + buffer.addVertex(pose, x0, y0, 0).setColor(fgColour); + buffer.addVertex(pose, x1, y1, 0).setColor(fgColour); } - tessellator.end(); + BufferUploader.drawWithShader(buffer.buildOrThrow()); glDisable(GL_POLYGON_SMOOTH); RenderSystem.disableBlend(); @@ -414,8 +413,7 @@ private void renderAngle(PoseStack matrixStack, float delta) { float radius = radius() + 0.5f; Tesselator tesselator = Tesselator.getInstance(); - BufferBuilder buffer = tesselator.getBuilder(); - buffer.begin(Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + BufferBuilder buffer = tesselator.begin(Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); float thickness = 1f; float left = -thickness / 2; @@ -425,13 +423,13 @@ private void renderAngle(PoseStack matrixStack, float delta) { Matrix4f last = matrixStack.last().pose(); last.mul(Axis.ZP.rotationDegrees(Minecraft.getInstance().player.getViewYRot(delta)).get(new Matrix4f())); - buffer.vertex(last, left, -radius, 0).color(fgColour).endVertex(); - buffer.vertex(last, left, 0, 0).color(fgColour).endVertex(); - buffer.vertex(last, right, 0, 0).color(fgColour).endVertex(); - buffer.vertex(last, right, -radius, 0).color(fgColour).endVertex(); + buffer.addVertex(last, left, -radius, 0).setColor(fgColour); + buffer.addVertex(last, left, 0, 0).setColor(fgColour); + buffer.addVertex(last, right, 0, 0).setColor(fgColour); + buffer.addVertex(last, right, -radius, 0).setColor(fgColour); matrixStack.popPose(); - tesselator.end(); + BufferUploader.drawWithShader(buffer.buildOrThrow()); glDisable(GL_POLYGON_SMOOTH); RenderSystem.disableBlend(); } @@ -445,8 +443,7 @@ private void renderLines(PoseStack matrixStack) { float radius = radius() + 0.5f; Tesselator tesselator = Tesselator.getInstance(); - BufferBuilder buffer = tesselator.getBuilder(); - buffer.begin(Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + BufferBuilder buffer = tesselator.begin(Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); float thickness = 0.5f; float left = -thickness / 2; @@ -457,23 +454,23 @@ private void renderLines(PoseStack matrixStack) { int numberOfLines = 4; float rotationRadians = (float) Math.PI / numberOfLines; for (int i = 0; i < numberOfLines; i++) { - buffer.vertex(last, left, -radius, 0f).color(fgColour).endVertex(); - buffer.vertex(last, left, radius, 0f).color(fgColour).endVertex(); - buffer.vertex(last, right, radius, 0f).color(fgColour).endVertex(); - buffer.vertex(last, right, -radius, 0f).color(fgColour).endVertex(); + buffer.addVertex(last, left, -radius, 0f).setColor(fgColour); + buffer.addVertex(last, left, radius, 0f).setColor(fgColour); + buffer.addVertex(last, right, radius, 0f).setColor(fgColour); + buffer.addVertex(last, right, -radius, 0f).setColor(fgColour); Matrix4f mul = new Matrix4f(); last.mul(Axis.ZP.rotation(rotationRadians).get(mul)); } matrixStack.popPose(); - tesselator.end(); + BufferUploader.drawWithShader(buffer.buildOrThrow()); glDisable(GL_POLYGON_SMOOTH); RenderSystem.disableBlend(); } public static void playPlayerSound(String soundName, UUID playerKey) { - SoundEvent soundEvent = BuiltInRegistries.SOUND_EVENT.get(new ResourceLocation("block.note_block." + soundName)); + SoundEvent soundEvent = BuiltInRegistries.SOUND_EVENT.get(ResourceLocation.withDefaultNamespace("block.note_block." + soundName)); if (soundEvent == null) return; float pitch = .5f + 1.5f * new Random(playerKey.hashCode()).nextFloat(); diff --git a/fabric/src/main/java/sh/okx/civmodern/fabric/FabricCivModernBootstrap.java b/fabric/src/main/java/sh/okx/civmodern/fabric/FabricCivModernBootstrap.java index 7b91244..b4cf930 100644 --- a/fabric/src/main/java/sh/okx/civmodern/fabric/FabricCivModernBootstrap.java +++ b/fabric/src/main/java/sh/okx/civmodern/fabric/FabricCivModernBootstrap.java @@ -26,7 +26,7 @@ public void onInitializeClient() { mod.eventBus.post(new ClientTickEvent()); }); HudRenderCallback.EVENT.register((guiGraphics, tickDelta) -> { - mod.eventBus.post(new PostRenderGameOverlayEvent(guiGraphics, tickDelta)); + mod.eventBus.post(new PostRenderGameOverlayEvent(guiGraphics, tickDelta.getGameTimeDeltaPartialTick(true))); }); } diff --git a/gradle.properties b/gradle.properties index edb8215..329ef5a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,21 +2,19 @@ org.gradle.jvmargs=-Xmx3072M archives_base_name=civmodern maven_group=sh.okx.civmodern -mod_version=1.6.4 +mod_version=1.6.5 mod_description=Civ Modern copyright_licence=GPLv3 mod_home_url=https://github.com/okx-code/civmodern mod_source_url=https://github.com/okx-code/civmodern mod_issues_url=https://github.com/okx-code/civmodern/issues -minecraft_version=1.20.6 +minecraft_version=1.21.1 architectury_version=11.1.13 -# https://parchmentmc.org/docs/getting-started -parchment_version=2024.06.16 enabled_platforms=fabric,forge # https://fabricmc.net/versions.html fabric_loader_version=0.15.11 -fabric_api_version=0.100.8+1.20.6 +fabric_api_version=0.102.1+1.21.1 -forge_version=1.20.6-50.1.0 +forge_version=1.21.1-52.0.4