Skip to content

Commit

Permalink
Monitor Overhaul (#410)
Browse files Browse the repository at this point in the history
Co-authored-by: Edrax Doodles <[email protected]>
Co-authored-by: River Thomas van der Meulen <[email protected]>
  • Loading branch information
3 people authored Dec 15, 2024
1 parent 0bb8366 commit 643ed85
Show file tree
Hide file tree
Showing 67 changed files with 1,465 additions and 1,215 deletions.
4 changes: 2 additions & 2 deletions LICENSE.MD
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ or other kind of organization that you work for, plus all
its affiliates.

**Affiliates** means the other organizations than an
organization has control over, is under the control of, or is
under common control with.
organization has controlEntity over, is under the controlEntity of, or is
under common controlEntity with.

**Control** means ownership of substantially all the assets of
an entity, or the power to direct its management and policies
Expand Down
21 changes: 11 additions & 10 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
![TARDIS Refined](https://wiki.tardisrefined.net/TARDIS-Refined-Wiki/tardis_refined_v2.png)

#### Bug Fixes
- Bug Fix: Added "Compatibility" with [Diagonal Windows](https://www.curseforge.com/minecraft/mc-mods/diagonal-windows)
- Bug Fix: Exception Ticking World [#388](https://github.com/WhoCraft/TardisRefined/issues/388)
- Bug Fix: Nuka Console Duplicate Control Entity Failing Flight Dance Events [#376](https://github.com/WhoCraft/TardisRefined/issues/376)
- Bug Fix: land pad dont work and crash on server [#377](https://github.com/WhoCraft/TardisRefined/issues/377)
- Bug Fix: tardis is damaged [#351](https://github.com/WhoCraft/TardisRefined/issues/351)
- Bug Fix: Diagonal Windows makes it impossible to craft the terraformer [#383](https://github.com/WhoCraft/TardisRefined/issues/383)
- Bug Fix: relogging causes TARDIS Dance events to not occur [#387](https://github.com/WhoCraft/TardisRefined/issues/387)
- Bug Fix: [Incompatibility] Tardis refined dimensions fail to load with Dimension Threads [#374](https://github.com/WhoCraft/TardisRefined/issues/374)
- Bug Fix: Console cannot be removed/changed with the console configurator outside the TARDIS dimension [#380](https://github.com/WhoCraft/TardisRefined/issues/380)
- Bug Fix: Fixed a bug where the overlay keybinds always rendered the default key
- Bug fix: Added "Compatibility" with [Diagonal Windows](https://www.curseforge.com/minecraft/mc-mods/diagonal-windows)
- Bug fix: Exception Ticking World [#388](https://github.com/WhoCraft/TardisRefined/issues/388)
- Bug fix: Nuka Console Duplicate Control Entity Failing Flight Dance Events [#376](https://github.com/WhoCraft/TardisRefined/issues/376)
- Bug fix: land pad dont work and crash on server [#377](https://github.com/WhoCraft/TardisRefined/issues/377)
- Bug fix: tardis is damaged [#351](https://github.com/WhoCraft/TardisRefined/issues/351)
- Bug fix: Diagonal Windows makes it impossible to craft the terraformer [#383](https://github.com/WhoCraft/TardisRefined/issues/383)
- Bug fix: relogging causes TARDIS Dance events to not occur [#387](https://github.com/WhoCraft/TardisRefined/issues/387)
- Bug fix: [Incompatibility] Tardis refined dimensions fail to load with Dimension Threads [#374](https://github.com/WhoCraft/TardisRefined/issues/374)
- Bug fix: Console cannot be removed/changed with the console configurator outside the TARDIS dimension [#380](https://github.com/WhoCraft/TardisRefined/issues/380)
- Bug fix: Fixed a bug where the overlay keybinds always rendered the default key
- Bug fix: Fixed a bug where a new TARDIS would believe it was at 0,0,0

#### Enhancements
- Enhancement: Added Adventure Mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
import whocraft.tardis_refined.client.screen.CancelDesktopScreen;
import whocraft.tardis_refined.client.screen.MonitorScreen;
import whocraft.tardis_refined.client.screen.selections.ShellSelectionScreen;
import whocraft.tardis_refined.client.screen.ponder.PonderListScreen;
import whocraft.tardis_refined.client.screen.screens.CancelDesktopScreen;
import whocraft.tardis_refined.client.screen.main.MonitorOS;
import whocraft.tardis_refined.client.screen.main.MonitorScreen;
import whocraft.tardis_refined.client.screen.screens.ShellSelectionScreen;
import whocraft.tardis_refined.client.screen.upgrades.UpgradesScreen;
import whocraft.tardis_refined.client.screen.waypoints.CoordInputType;
import whocraft.tardis_refined.client.screen.waypoints.WaypointListScreen;
import whocraft.tardis_refined.client.screen.waypoints.WaypointManageScreen;
import whocraft.tardis_refined.client.screen.screens.WaypointListScreen;
import whocraft.tardis_refined.client.screen.screens.WaypointManageScreen;
import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator;
import whocraft.tardis_refined.common.capability.tardis.upgrades.UpgradeHandler;
import whocraft.tardis_refined.common.tardis.TardisNavLocation;
Expand All @@ -28,11 +30,21 @@ public class ScreenHandler {

@Environment(EnvType.CLIENT)
public static void setWaypointScreen(Collection<TardisWaypoint> waypoints) {
Minecraft mc = Minecraft.getInstance();
if (mc.screen instanceof MonitorOS) {
((MonitorOS) mc.screen).switchScreenToRight(new WaypointListScreen(waypoints));
return;
}
Minecraft.getInstance().setScreen(new WaypointListScreen(waypoints));
}

@Environment(EnvType.CLIENT)
public static void setCoordinatesScreen(List<ResourceKey<Level>> levels, CoordInputType coordInputType, TardisNavLocation tardisNavLocation) {
Minecraft mc = Minecraft.getInstance();
if (mc.screen instanceof MonitorOS) {
((MonitorOS) mc.screen).switchScreenToRight(new WaypointManageScreen(levels, coordInputType, tardisNavLocation));
return;
}
Minecraft.getInstance().setScreen(new WaypointManageScreen(levels, coordInputType, tardisNavLocation));
}

Expand All @@ -42,13 +54,14 @@ public static void setEditCoordinatesScreen(TardisWaypoint waypoint) {
}

@Environment(EnvType.CLIENT)
public static void openMonitorScreen(boolean desktopGenerating, CompoundTag upgradeHandlerNbt, TardisNavLocation currentLocation, TardisNavLocation targetLocation) {
public static void openMonitorScreen(boolean desktopGenerating, CompoundTag upgradeHandlerNbt, TardisNavLocation currentLocation, TardisNavLocation targetLocation, ResourceLocation currentShellTheme) {
if (desktopGenerating) {
Minecraft.getInstance().setScreen(new CancelDesktopScreen());
} else {
assert Minecraft.getInstance().level != null;
UpgradeHandler upgradeHandlerClient = new UpgradeHandler(new TardisLevelOperator(Minecraft.getInstance().level));
upgradeHandlerClient.loadData(upgradeHandlerNbt);
Minecraft.getInstance().setScreen(new MonitorScreen(currentLocation, targetLocation, upgradeHandlerClient));
Minecraft.getInstance().setScreen(new MonitorScreen(currentLocation, targetLocation, upgradeHandlerClient, currentShellTheme));
}
}

Expand All @@ -64,6 +77,7 @@ public static void openEditCoordinatesScreen(TardisWaypoint waypoint) {

@Environment(EnvType.CLIENT)
public static void displayUpgradesScreen(CompoundTag upgradeTag) {
assert Minecraft.getInstance().level != null;
UpgradeHandler upgradeHandlerClient = new UpgradeHandler(new TardisLevelOperator(Minecraft.getInstance().level));
upgradeHandlerClient.loadData(upgradeTag);

Expand All @@ -76,6 +90,16 @@ public static void displayUpgradesScreen(CompoundTag upgradeTag) {

@Environment(EnvType.CLIENT)
public static void openShellSelection(ResourceLocation currentShell) {
Minecraft mc = Minecraft.getInstance();
if (mc.screen instanceof MonitorOS) {
((MonitorOS) mc.screen).switchScreenToRight(new ShellSelectionScreen(currentShell));
return;
}
Minecraft.getInstance().setScreen(new ShellSelectionScreen(currentShell));
}

@Environment(EnvType.CLIENT)
public static void openCraftingScreen() {
Minecraft.getInstance().setScreen(new PonderListScreen());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.multiplayer.PlayerInfo;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;
import whocraft.tardis_refined.TardisRefined;
import whocraft.tardis_refined.client.TRKeybinds;
import whocraft.tardis_refined.client.TardisClientData;
Expand All @@ -19,10 +20,6 @@
import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager;
import whocraft.tardis_refined.constants.ModMessages;

import java.util.ArrayList;
import java.util.Collection;
import java.util.UUID;

public class ExteriorViewOverlay {

public static final ResourceLocation BAR_TEXTURE = new ResourceLocation(TardisRefined.MODID, "textures/gui/bar/journey_bar.png");
Expand All @@ -35,23 +32,21 @@ public static void renderOverlay(GuiGraphics guiGraphics) {
Minecraft mc = Minecraft.getInstance();
if (!shouldRender)
return;

TardisPlayerInfo.get(mc.player).ifPresent(tardisPlayerInfo -> {
// Exit if the player is not viewing the TARDIS or the debug screen is active
if (!tardisPlayerInfo.isViewingTardis())
return;
TardisClientData tardisClientData = TardisClientData.getInstance(tardisPlayerInfo.getPlayerPreviousPos().getDimensionKey());

TardisClientData tardisClientData = TardisClientData.getInstance(tardisPlayerInfo.getPlayerPreviousPos().getDimensionKey());
PoseStack poseStack = guiGraphics.pose();
int screenWidth = mc.getWindow().getGuiScaledWidth();
int screenHeight = mc.getWindow().getGuiScaledHeight();

// Background for keybind text
int x = 10; // X position for text
int y = 10; // Initial Y position for text

// Background for text
int textBackdropWidth = 150; // Width of the backdrop box
int textBackdropHeight = 70; // Total height for the text backdrop box

int remainingFuel = (int) tardisClientData.getFuel();
int maxFuel = (int) tardisClientData.getMaximumFuel();
int fuelPercentage = maxFuel != 0 ? (int) ((double) remainingFuel / maxFuel * 100) : 0;
Expand All @@ -68,39 +63,69 @@ public static void renderOverlay(GuiGraphics guiGraphics) {
// Display fuel percentage
MutableComponent fuelMessage = Component.translatable(ModMessages.FUEL, fuelPercentage).append("%").withStyle(ChatFormatting.WHITE);

int messageWidth = mc.font.width(message);
// Get player coordinates
BlockPos pos = mc.player.blockPosition();
BlockPos targetPos = pos.east(120);

Vec3 currentPos = new Vec3(pos.getX(), pos.getY(), pos.getZ());

double progress = tardisClientData.getJourneyProgress();
int xV = (int) (currentPos.x + ((targetPos.getX() - currentPos.x) * progress));
int yV = (int) (currentPos.y + ((targetPos.getY() - currentPos.y) * progress));
int zV = (int) (currentPos.z + ((targetPos.getZ() - currentPos.z) * progress));

BlockPos landingLocation = new BlockPos(xV, yV, zV);

MutableComponent coordsMessage = Component.literal(
String.format("Coordinates: X: %d Y: %d Z: %d", landingLocation.getX(), landingLocation.getY(), landingLocation.getZ())
).withStyle(ChatFormatting.WHITE);

int coordsWidth = mc.font.width(coordsMessage);

poseStack.pushPose();

// Render keybind message
if (mc.screen == null) {
poseStack.pushPose();
int messageWidth = mc.font.width(message);
poseStack.translate(5 + messageWidth / 2f, -3 + screenHeight - mc.font.lineHeight / 2f, 0);
guiGraphics.fill(-messageWidth / 2, -3 - mc.font.lineHeight / 2, messageWidth / 2, 2 + mc.font.lineHeight / 2, 0x88000000);
guiGraphics.drawString(mc.font, message.getString(), 8 - messageWidth / 2, -mc.font.lineHeight / 2, 0xFFFFFF, false); // White text
guiGraphics.drawString(mc.font, message.getString(), 8 - messageWidth / 2, -mc.font.lineHeight / 2, 0xFFFFFF, false);
poseStack.popPose();
}

// Render fuel bar
{
poseStack.pushPose();
FUEL_BAR.animate = tardisClientData.isFlying();
poseStack.translate(20, 20, 0);
FUEL_BAR.blit(guiGraphics, 0, 0, (double) remainingFuel / maxFuel);
guiGraphics.drawString(mc.font, fuelMessage.getString(), 3, 2, 0x572200, false); // White text
guiGraphics.drawString(mc.font, fuelMessage.getString(), 3, 2, 0x572200, false);
poseStack.popPose();
}

guiGraphics.drawString(mc.font, throttleMessage.getString(), 20, 35, 0xFFFFFF, false); // White text
guiGraphics.drawString(mc.font, throttleMessage.getString(), 20, 35, 0xFFFFFF, false);

float journeyProgress = tardisClientData.getJourneyProgress() / 100.0f;

poseStack.popPose();
if(!tardisClientData.isFlying()) {
// Render player coordinates at the top-right corner
poseStack.pushPose();
poseStack.translate(screenWidth - coordsWidth - 10, 10, 0); // Adjust position
guiGraphics.fill(-2, -3, coordsWidth + 2, mc.font.lineHeight + 2, 0x88000000); // Black background
guiGraphics.drawString(mc.font, coordsMessage.getString(), 0, 0, 0xFFFFFF, false); // White text
poseStack.popPose();
}

// Render journey progress bar
if (tardisClientData.isFlying())
renderJourneyProgressBar(guiGraphics, journeyProgress);

poseStack.popPose();
});
}


private static void renderPlayerHeads(PlayerInfo player, GuiGraphics guiGraphics, Minecraft mc, int x, int y) {
// Render player's face and name
if (player == null) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
import org.joml.Matrix4f;
import whocraft.tardis_refined.client.TardisClientData;
import whocraft.tardis_refined.client.renderer.vortex.VortexRenderer;
import whocraft.tardis_refined.client.screen.selections.ShellSelectionScreen;
import whocraft.tardis_refined.client.screen.screens.ShellSelectionScreen;
import whocraft.tardis_refined.common.VortexRegistry;
import whocraft.tardis_refined.common.capability.player.TardisPlayerInfo;

import java.util.Objects;

import static whocraft.tardis_refined.client.renderer.vortex.ShellRenderer.renderShell;
import static whocraft.tardis_refined.client.screen.selections.ShellSelectionScreen.globalShellBlockEntity;
import static whocraft.tardis_refined.client.screen.main.MonitorOS.MonitorOSExtension.GLOBALSHELL_BLOCKENTITY;

public class VortexOverlay {

Expand All @@ -36,7 +34,7 @@ public class VortexOverlay {
private static long LAST_TIME = System.currentTimeMillis();

public static void update(GuiGraphics gg) {
if (globalShellBlockEntity == null) {
if (GLOBALSHELL_BLOCKENTITY == null) {
ShellSelectionScreen.generateDummyGlobalShell();
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import whocraft.tardis_refined.client.model.blockentity.console.ConsoleUnit;
import whocraft.tardis_refined.client.model.blockentity.shell.ShellModelCollection;
import whocraft.tardis_refined.client.renderer.RenderHelper;
import whocraft.tardis_refined.client.screen.selections.ShellSelectionScreen;
import whocraft.tardis_refined.client.screen.screens.ShellSelectionScreen;
import whocraft.tardis_refined.common.block.console.GlobalConsoleBlock;
import whocraft.tardis_refined.common.blockentity.console.GlobalConsoleBlockEntity;
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;
Expand Down Expand Up @@ -115,11 +115,11 @@ private void renderHoloShell(Vec3 offset, int rotation, GlobalConsoleBlockEntity
poseStack.mulPose(Axis.YP.rotationDegrees(rotation % 360));
}

if (ShellSelectionScreen.globalShellBlockEntity == null) {
if (ShellSelectionScreen.GLOBALSHELL_BLOCKENTITY == null) {
ShellSelectionScreen.generateDummyGlobalShell();
}

ShellSelectionScreen.globalShellBlockEntity.setTardisId(reactions.getLevelKey());
ShellSelectionScreen.GLOBALSHELL_BLOCKENTITY.setTardisId(reactions.getLevelKey());

// Dynamic flickering alpha for a hologram effect
float flickerAlpha = 0.2f + blockEntity.getLevel().random.nextFloat() * 0.1f;
Expand All @@ -133,7 +133,7 @@ private void renderHoloShell(Vec3 offset, int rotation, GlobalConsoleBlockEntity

model.setIgnoreAnmationAlpha(!reactions.isTakingOff() && !reactions.isLanding());
model.renderShell(
ShellSelectionScreen.globalShellBlockEntity,
ShellSelectionScreen.GLOBALSHELL_BLOCKENTITY,
false,
true,
poseStack,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private static void renderDoorOpen(GlobalDoorBlockEntity blockEntity, PoseStack
GL11.glColorMask(false, false, false, true);

// Copy render target back to main buffer

RENDER_TARGET_HELPER.end();
Minecraft.getInstance().getMainRenderTarget().bindWrite(true);
copyRenderTarget(RENDER_TARGET_HELPER.renderTarget, Minecraft.getInstance().getMainRenderTarget());
GL11.glDisable(GL11.GL_STENCIL_TEST); // Disable stencil test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import whocraft.tardis_refined.patterns.ShellPatterns;

import static whocraft.tardis_refined.client.overlays.VortexOverlay.VORTEX;
import static whocraft.tardis_refined.client.screen.selections.ShellSelectionScreen.globalShellBlockEntity;
import static whocraft.tardis_refined.client.screen.screens.ShellSelectionScreen.GLOBALSHELL_BLOCKENTITY;

public class ShellRenderer {

Expand Down Expand Up @@ -56,17 +56,17 @@ public static void renderShell(GuiGraphics guiGraphics, float control, float alp
//pose.translate(0, 1.5, 0);
VertexConsumer vertexConsumer = guiGraphics.bufferSource().getBuffer(model.renderType(model.getShellTexture(ShellPatterns.getPatternOrDefault(shellTheme, shellPattern), false)));
RenderSystem.enableBlend();
globalShellBlockEntity.setTardisId(tardisClientData.getLevelKey());
model.renderShell(globalShellBlockEntity, false, false, pose, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, alpha);
GLOBALSHELL_BLOCKENTITY.setTardisId(tardisClientData.getLevelKey());
model.renderShell(GLOBALSHELL_BLOCKENTITY, false, false, pose, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, alpha);
if (fullPattern.exteriorDoorTexture().emissive()) {
VertexConsumer vertexConsumerLighting = guiGraphics.bufferSource().getBuffer(RenderType.entityTranslucentEmissive(model.getShellTexture(ShellPatterns.getPatternOrDefault(shellTheme, shellPattern), true)));
model.renderShell(globalShellBlockEntity, false, false, pose, vertexConsumerLighting, 15728880, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, alpha);
model.renderShell(GLOBALSHELL_BLOCKENTITY, false, false, pose, vertexConsumerLighting, 15728880, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, alpha);
}


VertexConsumer lightning = guiGraphics.bufferSource().getBuffer(RenderType.entityGlint());
if (VORTEX.lightning_strike > 0.4) {
model.renderShell(globalShellBlockEntity, false, false, pose, lightning, 15728880, OverlayTexture.NO_OVERLAY, 1, 1, 1, alpha);
model.renderShell(GLOBALSHELL_BLOCKENTITY, false, false, pose, lightning, 15728880, OverlayTexture.NO_OVERLAY, 1, 1, 1, alpha);
}

guiGraphics.flush();
Expand Down
Loading

0 comments on commit 643ed85

Please sign in to comment.