Skip to content

Commit

Permalink
1.6.3 update
Browse files Browse the repository at this point in the history
  • Loading branch information
okx-code committed Jul 18, 2024
1 parent f6d5d8b commit 0e1fb02
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
package sh.okx.civmodern.common.gui.screen;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.regex.Pattern;

import com.google.common.collect.Lists;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.narration.NarratableEntry;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
Expand All @@ -24,6 +31,7 @@
public class RadarConfigScreen extends Screen implements ScreenCloseable {

public static final ResourceLocation ROLLBACK_ICON = new ResourceLocation("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;
private final Screen parent;
Expand Down Expand Up @@ -315,7 +323,10 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta)

guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 15, 0xffffff);

super.render(guiGraphics, mouseX, mouseY, delta);
// Don't call super because we don't want the dark background to allow people to see the radar easily
for (Renderable renderable : this.renderables) {
renderable.render(guiGraphics, mouseX, mouseY, delta);
}
}

private Component getRadarToggleMessage() {
Expand All @@ -326,6 +337,12 @@ private Component getRadarToggleMessage() {
}
}

@Override
protected <T extends GuiEventListener & Renderable & NarratableEntry> T addRenderableWidget(T widget) {
this.renderables.add(widget);
return super.addRenderableWidget(widget);
}

@Override
public void close() {
fgPicker.close();
Expand Down
17 changes: 7 additions & 10 deletions common/src/main/java/sh/okx/civmodern/common/radar/Radar.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package sh.okx.civmodern.common.radar;

import com.google.common.eventbus.Subscribe;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.platform.Lighting;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
Expand Down Expand Up @@ -283,28 +282,26 @@ private void renderEntity(GuiGraphics guiGraphics, Player player, Entity entity,
}

guiGraphics.pose().pushPose();
guiGraphics.pose().translate(dx * scale, dz * scale, 0);
guiGraphics.pose().translate(dx * scale, dz * scale, 150);
if (config.isNorthUp()) {
guiGraphics.pose().mulPose(Axis.ZP.rotationDegrees(180));
} else {
guiGraphics.pose().mulPose(Axis.ZP.rotationDegrees(player.getViewYRot(delta)));
}
guiGraphics.pose().scale(config.getIconSize(), config.getIconSize(), 0);

BakedModel bakedModel = Minecraft.getInstance().getItemRenderer().getModel(item, player.level(), player, 0);
guiGraphics.pose().scale(config.getIconSize(), config.getIconSize(), 1);
guiGraphics.pose().mulPoseMatrix(new Matrix4f().scaling(1.0f, -1.0f, 1.0f));
guiGraphics.pose().scale(16.0f, 16.0f, 16.0f);

boolean notUseBlockLight = !bakedModel.usesBlockLight();

if (notUseBlockLight)
if (notUseBlockLight) {
Lighting.setupForFlatItems();

}
Minecraft.getInstance().getItemRenderer().render(item, ItemDisplayContext.GUI, false, guiGraphics.pose(), guiGraphics.bufferSource(), 0xF000F0, OverlayTexture.NO_OVERLAY, bakedModel);
guiGraphics.bufferSource().endBatch();

if (notUseBlockLight)
guiGraphics.flush();
if (notUseBlockLight) {
Lighting.setupFor3DItems();
}

guiGraphics.pose().popPose();
}
Expand Down
10 changes: 5 additions & 5 deletions common/src/main/resources/assets/civmodern/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
"civmodern.screen.radar.background_transparency": "BG Transparency: %s",
"civmodern.screen.compacted.title": "Civ Modern Config (Compacted Items)",
"civmodern.screen.ice.title": "Civ Modern Config (Ice Road Macro)",
"civmodern.screen.ice.cardinal.pitch.enable": "Snap pitch to cardinal: Enabled",
"civmodern.screen.ice.cardinal.pitch.disable": "Snap pitch to cardinal: Disabled",
"civmodern.screen.ice.cardinal.yaw.enable": "Snap yaw to cardinal: Enabled",
"civmodern.screen.ice.cardinal.yaw.disable": "Snap yaw to cardinal: Disabled",
"civmodern.screen.ice.cardinal.pitch.enable": "Snap pitch: Enabled",
"civmodern.screen.ice.cardinal.pitch.disable": "Snap pitch: Disabled",
"civmodern.screen.ice.cardinal.yaw.enable": "Snap yaw: Enabled",
"civmodern.screen.ice.cardinal.yaw.disable": "Snap yaw: Disabled",
"civmodern.screen.ice.eat.enable": "Auto eat held item: Enabled",
"civmodern.screen.ice.eat.disable": "Auto eat held item: Disabled",
"civmodern.screen.ice.stop.enable": "Stop on low food: Enabled",
"civmodern.screen.ice.stop.disable": "Stop on low food: Disabled",
"civmodern.radar.enter" : "§r%s §eappeared at §b[%s§b]",
"civmodern.radar.hover" : "Click to highlight position\nControl click to add waypoint",
"civmodern.radar.leave" : "§r%s §edisappeared at §b[%s§b]"
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx3072M

archives_base_name=civmodern
maven_group=sh.okx.civmodern
mod_version=1.6.2
mod_version=1.6.3
mod_description=Civ Modern
copyright_licence=GPLv3
mod_home_url=https://github.com/okx-code/civmodern
Expand Down

0 comments on commit 0e1fb02

Please sign in to comment.