Skip to content

Commit

Permalink
Update to 1.21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
okx-code committed Aug 21, 2024
1 parent 16719b8 commit 4f792f2
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 91 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/release.yml

This file was deleted.

5 changes: 0 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
}
}
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Renderable> renderables = new ArrayList<>(); // copied from Screen because it's private there
private final AbstractCivModernMod mod;
private final CivMapConfig config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
49 changes: 23 additions & 26 deletions common/src/main/java/sh/okx/civmodern/common/radar/Radar.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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;

Expand All @@ -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();
Expand All @@ -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;
Expand All @@ -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();
}
Expand All @@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
});
}

Expand Down
10 changes: 4 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4f792f2

Please sign in to comment.