diff --git a/LICENSE.MD b/LICENSE.MD index 3f09b052c..aed8dcb63 100644 --- a/LICENSE.MD +++ b/LICENSE.MD @@ -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 diff --git a/changelog.md b/changelog.md index cd6018eb4..01cf4caf0 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/common/src/main/java/whocraft/tardis_refined/client/ScreenHandler.java b/common/src/main/java/whocraft/tardis_refined/client/ScreenHandler.java index 8eceb4dd4..2e0e872ae 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/ScreenHandler.java +++ b/common/src/main/java/whocraft/tardis_refined/client/ScreenHandler.java @@ -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; @@ -28,11 +30,21 @@ public class ScreenHandler { @Environment(EnvType.CLIENT) public static void setWaypointScreen(Collection 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> 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)); } @@ -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)); } } @@ -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); @@ -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()); + } } diff --git a/common/src/main/java/whocraft/tardis_refined/client/overlays/ExteriorViewOverlay.java b/common/src/main/java/whocraft/tardis_refined/client/overlays/ExteriorViewOverlay.java index aabd0c62f..611903db1 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/overlays/ExteriorViewOverlay.java +++ b/common/src/main/java/whocraft/tardis_refined/client/overlays/ExteriorViewOverlay.java @@ -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; @@ -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"); @@ -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; @@ -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; diff --git a/common/src/main/java/whocraft/tardis_refined/client/overlays/VortexOverlay.java b/common/src/main/java/whocraft/tardis_refined/client/overlays/VortexOverlay.java index f7c8bd999..c7c932aa8 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/overlays/VortexOverlay.java +++ b/common/src/main/java/whocraft/tardis_refined/client/overlays/VortexOverlay.java @@ -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 { @@ -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; } diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/console/GlobalConsoleRenderer.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/console/GlobalConsoleRenderer.java index 4474f5957..f9e62bda5 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/console/GlobalConsoleRenderer.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/console/GlobalConsoleRenderer.java @@ -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; @@ -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; @@ -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, diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/RenderTargetHelper.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/RenderTargetHelper.java index 920e746bb..a3863a750 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/RenderTargetHelper.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/RenderTargetHelper.java @@ -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 diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/ShellRenderer.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/ShellRenderer.java index 75be7f8cc..87d5a2591 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/ShellRenderer.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/ShellRenderer.java @@ -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 { @@ -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(); diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/VortexRenderer.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/VortexRenderer.java index b828491d8..42af66979 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/VortexRenderer.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/VortexRenderer.java @@ -27,19 +27,16 @@ public class VortexRenderer { private static final RandomSource RAND = RandomSource.create(); - public VortexRegistry vortexType; - public final RenderHelper.DynamicTimeKeep time = new RenderHelper.DynamicTimeKeep(2); + private final List vortex_quads = new ArrayList<>(); + public float opacity = 1; + public float lightning_strike = 0; public VortexRenderer(VortexRegistry type) { this.vortexType = type; } - private final List vortex_quads = new ArrayList<>(); - public float opacity = 1; - public float lightning_strike = 0; - /** * Renders the Time Vortex */ @@ -67,11 +64,11 @@ public void renderVortex(PoseStack pose, float opacity, boolean half) { Tesselator tesselator = beginTextureColor(Mode.QUADS); for (int i = 0; i < this.vortexType.getRows() / 2f; i++) { if (vortex_quads.size() < i + 1) { - vortex_quads.add(new VortexQuad(this.vortexType, this.time)); + vortex_quads.add(new VortexQuad()); break; } pose.pushPose(); - vortex_quads.get(i).renderQuad(pose, i / (this.vortexType.getRows() / 2f), this.opacity); + vortex_quads.get(i).renderQuad(pose, time, vortexType, i / (this.vortexType.getRows() / 2f), this.opacity); this.lightning_strike += vortex_quads.get(i).lightning_strike * vortex_quads.get(i).lightning_strike / (this.vortexType.getRows() / 2f); pose.popPose(); } @@ -181,20 +178,16 @@ private static class VortexQuad { private float u = 0, v = 0; private final float uvSize = 0.125f; private float lightning_a; - private final VortexRegistry vortexType; - private final RenderHelper.DynamicTimeKeep time; public float lightning_strike = 0; - public VortexQuad(VortexRegistry type, RenderHelper.DynamicTimeKeep time) { - this.vortexType = type; - this.time = time; + public VortexQuad() { } - private void rndQuad() { + private void rndQuad(VortexRegistry vortexType) { valid = true; prev_tO = 1; rndUV(); - lightning = RAND.nextBoolean() && this.vortexType.hasLightning(); + lightning = RAND.nextBoolean() && vortexType.hasLightning(); } private void rndUV() { @@ -203,8 +196,8 @@ private void rndUV() { } - public void renderQuad(PoseStack poseStack, float time_offset, float opacity) { - if (!valid) rndQuad(); + public void renderQuad(PoseStack poseStack, RenderHelper.DynamicTimeKeep time, VortexRegistry vortexType, float time_offset, float opacity) { + if (!valid) rndQuad(vortexType); float tO = -(time.getFloat(time_offset) * 2) - 1; if (tO > prev_tO || !valid) { @@ -236,12 +229,12 @@ public void renderQuad(PoseStack poseStack, float time_offset, float opacity) { alpha = Math.min(alpha, 1); alpha *= opacity; poseStack.pushPose(); - RenderHelper.rotateZYX(poseStack, 0, -this.vortexType.getTwist(), 0); - RenderHelper.rotateZYX(poseStack, 0, tO * this.vortexType.getRows() * this.vortexType.getTwist(), 0); - vertexUVColor(poseStack, x - s, tO, z + s, u0, v1, val, alpha, tO, !lightning); - vertexUVColor(poseStack, x + s, tO, z + s, u1, v1, val, alpha, tO, !lightning); - vertexUVColor(poseStack, x + s, tO, z - s, u1, v0, val, alpha, tO, !lightning); - vertexUVColor(poseStack, x - s, tO, z - s, u0, v0, val, alpha, tO, !lightning); + RenderHelper.rotateZYX(poseStack, 0, -vortexType.getTwist(), 0); + RenderHelper.rotateZYX(poseStack, 0, tO * vortexType.getRows() * vortexType.getTwist(), 0); + vertexUVColor(poseStack, x - s, tO, z + s, u0, v1, val, alpha, tO, !lightning, vortexType); + vertexUVColor(poseStack, x + s, tO, z + s, u1, v1, val, alpha, tO, !lightning, vortexType); + vertexUVColor(poseStack, x + s, tO, z - s, u1, v0, val, alpha, tO, !lightning, vortexType); + vertexUVColor(poseStack, x - s, tO, z - s, u0, v0, val, alpha, tO, !lightning, vortexType); poseStack.popPose(); prev_tO = tO; @@ -250,8 +243,8 @@ public void renderQuad(PoseStack poseStack, float time_offset, float opacity) { } - private void vertexUVColor(@NotNull PoseStack pose, float x, float y, float z, float u, float v, float val, float a, float o, boolean tint) { - float[] color = this.vortexType.getGradient().getRGBf(o); + private void vertexUVColor(@NotNull PoseStack pose, float x, float y, float z, float u, float v, float val, float a, float o, boolean tint, VortexRegistry vortexType) { + float[] color = vortexType.getGradient().getRGBf(o); if (tint) RenderHelper.vertexUVColor(pose, x, y, z, u, v, val * color[0], val * color[1], val * color[2], a); else diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/MonitorScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/MonitorScreen.java deleted file mode 100644 index dc0f9e746..000000000 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/MonitorScreen.java +++ /dev/null @@ -1,124 +0,0 @@ -package whocraft.tardis_refined.client.screen; - -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import whocraft.tardis_refined.TardisRefined; -import whocraft.tardis_refined.client.screen.components.GenericMonitorSelectionList; -import whocraft.tardis_refined.client.screen.components.SelectionListEntry; -import whocraft.tardis_refined.client.screen.selections.DesktopSelectionScreen; -import whocraft.tardis_refined.client.screen.selections.HumSelectionScreen; -import whocraft.tardis_refined.client.screen.selections.SelectionScreen; -import whocraft.tardis_refined.client.screen.selections.VortexSelectionScreen; -import whocraft.tardis_refined.common.VortexRegistry; -import whocraft.tardis_refined.common.capability.tardis.upgrades.UpgradeHandler; -import whocraft.tardis_refined.common.network.messages.C2SEjectPlayer; -import whocraft.tardis_refined.common.network.messages.player.C2SBeginShellView; -import whocraft.tardis_refined.common.network.messages.screens.C2SRequestShellSelection; -import whocraft.tardis_refined.common.network.messages.waypoints.C2SRequestWaypoints; -import whocraft.tardis_refined.common.tardis.TardisNavLocation; -import whocraft.tardis_refined.common.util.MiscHelper; -import whocraft.tardis_refined.constants.ModMessages; -import whocraft.tardis_refined.registry.TRUpgrades; - -import java.awt.*; - - -public class MonitorScreen extends SelectionScreen { - - public static ResourceLocation MONITOR_TEXTURE = new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor.png"); - private final TardisNavLocation currentLocation; - private final TardisNavLocation targetLocation; - private final UpgradeHandler upgradeHandler; - protected int imageWidth = 256; - protected int imageHeight = 173; - private int leftPos, topPos; - private boolean noUpgrades = false; - - - public MonitorScreen(TardisNavLocation currentLocation, TardisNavLocation targetLocation, UpgradeHandler upgradeHandler) { - super(Component.translatable(ModMessages.UI_MONITOR_MAIN_TITLE)); - this.currentLocation = currentLocation; - this.targetLocation = targetLocation; - this.upgradeHandler = upgradeHandler; - } - - @Override - public boolean isPauseScreen() { - return false; - } - - @Override - protected void init() { - - this.leftPos = (this.width - this.imageWidth) / 2; - this.topPos = (this.height - this.imageHeight) / 2; - - //Super method already creates the list, we don't need to create it a second time. - super.init(); - } - - @Override - public GenericMonitorSelectionList createSelectionList() { - int leftPos = this.width / 2 - 75; - GenericMonitorSelectionList selectionList = new GenericMonitorSelectionList<>(this.minecraft, 250, 80, leftPos - 70, this.topPos + 30, this.topPos + this.imageHeight - 45, 10); - selectionList.setRenderBackground(false); - - selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_EXTERNAL_SHELL), entry -> new C2SRequestShellSelection().send(), leftPos, TRUpgrades.CHAMELEON_CIRCUIT_SYSTEM.get().isUnlocked(upgradeHandler))); - - selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_DESKTOP_CONFIGURATION), entry -> Minecraft.getInstance().setScreen(new DesktopSelectionScreen()), leftPos, TRUpgrades.INSIDE_ARCHITECTURE.get().isUnlocked(upgradeHandler))); - - selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_MONITOR_WAYPOINTS), entry -> new C2SRequestWaypoints().send(), leftPos, TRUpgrades.WAYPOINTS.get().isUnlocked(upgradeHandler))); - selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_MONITOR_SHELL_VIEW), entry -> new C2SBeginShellView().send(), leftPos, TRUpgrades.WAYPOINTS.get().isUnlocked(upgradeHandler))); - selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_MONITOR_VORTEX), entry -> Minecraft.getInstance().setScreen(new VortexSelectionScreen(VortexRegistry.VORTEX_REGISTRY.getKey(VortexRegistry.FLOW.get()))), leftPos)); - - - selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_MONITOR_SELECT_HUM), entry -> Minecraft.getInstance().setScreen(new HumSelectionScreen()), leftPos)); - selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_MONITOR_EJECT), entry -> { - new C2SEjectPlayer().send(); - Minecraft.getInstance().setScreen(null); - }, leftPos)); - - - if (selectionList.children().isEmpty()) { - noUpgrades = true; - } - - return selectionList; - } - - @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - super.render(guiGraphics, i, j, f); - int textOffset = height / 2 - 35; - - int upgradesLeftPos = this.width / 2 - 75; - - - if (noUpgrades) { - guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable(ModMessages.UI_NO_INSTALLED_SUBSYSTEMS).getString(), upgradesLeftPos, this.topPos + 30, ChatFormatting.GOLD.getColor()); - } - - this.renderTransparentBackground(guiGraphics); - - /*Render Back drop*/ - RenderSystem.setShader(GameRenderer::getPositionTexShader); - guiGraphics.blit(MONITOR_TEXTURE, leftPos, topPos, 0, 0, imageWidth, imageHeight); - - int textScale = 40; - - guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable(ModMessages.UI_MONITOR_GPS).getString() + ":", width / 2 - 96, textOffset + 50, Color.WHITE.getRGB()); - ScreenHelper.renderWidthScaledText(currentLocation.getDirection().getName().toUpperCase() + " @ " + currentLocation.getPosition().toShortString(), guiGraphics, Minecraft.getInstance().font, width / 2 - 96, textOffset + 60, Color.LIGHT_GRAY.getRGB(), textScale * 2, 0.75F, false); - ScreenHelper.renderWidthScaledText(MiscHelper.getCleanDimensionName(currentLocation.getDimensionKey()), guiGraphics, Minecraft.getInstance().font, width / 2 - 96, textOffset + 70, Color.LIGHT_GRAY.getRGB(), textScale - 3, 1.5F, false); - - guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable(ModMessages.UI_MONITOR_DESTINATION).getString() + ":", width / 2 + 10, textOffset + 50, Color.WHITE.getRGB()); - ScreenHelper.renderWidthScaledText(targetLocation.getDirection().getName().toUpperCase() + " @ " + targetLocation.getPosition().toShortString(), guiGraphics, Minecraft.getInstance().font, width / 2 + 10, textOffset + 60, Color.LIGHT_GRAY.getRGB(), textScale * 2, 0.75F, false); - ScreenHelper.renderWidthScaledText(MiscHelper.getCleanDimensionName(targetLocation.getDimensionKey()), guiGraphics, Minecraft.getInstance().font, width / 2 + 10, textOffset + 70, Color.LIGHT_GRAY.getRGB(), textScale - 3, 1.5F, false); - - } - -} diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/components/GenericMonitorSelectionList.java b/common/src/main/java/whocraft/tardis_refined/client/screen/components/GenericMonitorSelectionList.java index 48bdd980c..388c63b68 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/components/GenericMonitorSelectionList.java +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/components/GenericMonitorSelectionList.java @@ -30,7 +30,7 @@ public GenericMonitorSelectionList(Minecraft minecraft, int width, int height, i @Override protected int getScrollbarPosition() { - return this.x0 + this.width; + return this.x1 - 6; } @Override diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/main/MonitorOS.java b/common/src/main/java/whocraft/tardis_refined/client/screen/main/MonitorOS.java new file mode 100644 index 000000000..f4b74bd51 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/main/MonitorOS.java @@ -0,0 +1,367 @@ +package whocraft.tardis_refined.client.screen.main; + +import com.mojang.blaze3d.platform.Lighting; +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.blaze3d.vertex.VertexSorting; +import com.mojang.math.Axis; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.ObjectSelectionList; +import net.minecraft.client.gui.components.SpriteIconButton; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.Registries; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; +import org.joml.Matrix4f; +import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.client.TardisClientData; +import whocraft.tardis_refined.client.model.blockentity.shell.ShellModel; +import whocraft.tardis_refined.client.model.blockentity.shell.ShellModelCollection; +import whocraft.tardis_refined.client.renderer.vortex.VortexRenderer; +import whocraft.tardis_refined.client.screen.ScreenHelper; +import whocraft.tardis_refined.client.screen.components.CommonTRWidgets; +import whocraft.tardis_refined.client.screen.components.SelectionListEntry; +import whocraft.tardis_refined.client.screen.screens.VortexSelectionScreen; +import whocraft.tardis_refined.common.VortexRegistry; +import whocraft.tardis_refined.common.blockentity.shell.GlobalShellBlockEntity; +import whocraft.tardis_refined.common.tardis.themes.ShellTheme; +import whocraft.tardis_refined.patterns.ShellPattern; +import whocraft.tardis_refined.patterns.ShellPatterns; +import whocraft.tardis_refined.registry.TRBlockRegistry; + +import java.awt.*; +import java.util.List; +import java.util.UUID; + +public class MonitorOS extends Screen { + + public static ResourceLocation FRAME = new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor/frame_brass.png"); + protected static final int frameWidth = 256, frameHeight = 180; + protected static final int monitorWidth = 230, monitorHeight = 130; + public final ResourceLocation backdrop; + public static final VortexRenderer VORTEX = new VortexRenderer(VortexRegistry.CLOUDS.get()); + public static ResourceLocation currentVortex = VortexRegistry.VORTEX_REGISTRY.getKey(VortexRegistry.CLOUDS.get()); + public static ResourceLocation NOISE = new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor/noise.png"); + public static ResourceLocation SYMBLS = new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor/gallifreyan_symbols.png"); + + public MonitorOS LEFT; + public MonitorOS RIGHT; + public MonitorOS PREVIOUS; + + public static final ResourceLocation BUTTON_LOCATION = new ResourceLocation(TardisRefined.MODID, "save"); + public static final ResourceLocation BCK_LOCATION = new ResourceLocation(TardisRefined.MODID, "back"); + public int shakeX, shakeY, age, transitionStartTime = -1; + public float shakeAlpha; + private MonitorOSRun onSubmit; + private MonitorOSRun onCancel; + + public MonitorOS(Component title, ResourceLocation backdrop) { + super(title); + this.backdrop = backdrop; + } + + @Override + protected void init() { + super.init(); + ObjectSelectionList list = createSelectionList(); + if (list != null) this.addRenderableWidget(list); + } + + @Override + public void renderBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { + } + + public void render2Background(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { + int hPos = (width - monitorWidth) / 2; + int vPos = (height - monitorHeight) / 2; + + guiGraphics.enableScissor(0, 0, width, vPos + shakeY); + super.renderBackground(guiGraphics, mouseX, mouseY, partialTick); + guiGraphics.disableScissor(); + guiGraphics.enableScissor(0, vPos + shakeY, hPos + shakeX, height - vPos + shakeY); + super.renderBackground(guiGraphics, mouseX, mouseY, partialTick); + guiGraphics.disableScissor(); + guiGraphics.enableScissor(width - hPos + shakeX, vPos + shakeY, width, height - vPos + shakeY); + super.renderBackground(guiGraphics, mouseX, mouseY, partialTick); + guiGraphics.disableScissor(); + guiGraphics.enableScissor(0, height - vPos + shakeY, width, height); + super.renderBackground(guiGraphics, mouseX, mouseY, partialTick); + guiGraphics.disableScissor(); + } + + + public void renderVortex(@NotNull GuiGraphics guiGraphics) { + PoseStack poseStack = guiGraphics.pose(); + + int hPos = (width - monitorWidth) / 2; + int vPos = (height - monitorHeight) / 2; + + guiGraphics.enableScissor(hPos + shakeX, vPos + shakeY, width - hPos + shakeX, height - vPos + shakeY); + RenderSystem.backupProjectionMatrix(); + assert minecraft != null; + Matrix4f perspective = new Matrix4f(); + perspective.perspective((float) Math.toRadians(minecraft.options.fov().get()), (float) width / (float) height, 0.01f, 9999, false, perspective); + perspective.translate(0, 0, 11000f); + RenderSystem.setProjectionMatrix(perspective, VertexSorting.DISTANCE_TO_ORIGIN); + poseStack.pushPose(); + poseStack.mulPose(Axis.YP.rotationDegrees(20)); + + // Blindly assume that the player is not doing weird stuff to open the menu outside a TARDIS + assert Minecraft.getInstance().level != null; + TardisClientData tardisClientData = TardisClientData.getInstance(Minecraft.getInstance().level.dimension()); + + VORTEX.vortexType = VortexRegistry.VORTEX_REGISTRY.get(this instanceof VortexSelectionScreen ? VortexSelectionScreen.currentVortex : tardisClientData.getVortex()); + VORTEX.time.speed = 0.3; + VORTEX.renderVortex(guiGraphics, 1, false); + RenderSystem.restoreProjectionMatrix(); + poseStack.popPose(); + guiGraphics.disableScissor(); + } + + public void renderBackdrop(@NotNull GuiGraphics guiGraphics) { + if (backdrop == null) return; + int hPos = (width - monitorWidth) / 2; + int vPos = (height - monitorHeight) / 2; + guiGraphics.blit(backdrop, hPos, vPos, 0, 0, monitorWidth, monitorHeight); + int b = height - vPos, r = width - hPos; + guiGraphics.fill(hPos, vPos, r, b, 0x40000000); + } + + @Override + public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { + render2Background(guiGraphics, mouseX, mouseY, partialTick); + RenderSystem.enableBlend(); + renderVortex(guiGraphics); + + int hPos = (width - monitorWidth) / 2; + int vPos = (height - monitorHeight) / 2; + + guiGraphics.enableScissor(hPos, vPos, width - hPos, height - vPos); + + PoseStack poseStack = guiGraphics.pose(); + poseStack.pushPose(); + poseStack.translate(shakeX, shakeY, 0); + + int symb = 0 % 64; + poseStack.pushPose(); + poseStack.translate(hPos + 10, vPos + 10, 0); + poseStack.scale(2, 2, 1); + poseStack.mulPose(Axis.ZP.rotationDegrees((float) (System.currentTimeMillis() % 5400L) / 15L)); + poseStack.translate(-31 / 2f, -31 / 2f, 0); + guiGraphics.blit(SYMBLS, 0, 0, 32 * (symb % 8), 32 * (symb / 8), 32, 32); + poseStack.popPose(); + + symb = 3 % 64; + poseStack.pushPose(); + poseStack.translate(hPos + monitorWidth - 10, vPos + monitorHeight - 10, 0); + poseStack.scale(2, 2, 1); + poseStack.mulPose(Axis.ZP.rotationDegrees((float) (System.currentTimeMillis() % 5400L) / 15L)); + poseStack.translate(-31 / 2f, -31 / 2f, 0); + guiGraphics.blit(SYMBLS, 0, 0, 32 * (symb % 8), 32 * (symb / 8), 32, 32); + poseStack.popPose(); + + symb = 9 % 64; + poseStack.pushPose(); + poseStack.translate(hPos + 10, vPos + monitorHeight - 10, 0); + poseStack.scale(2, 2, 1); + poseStack.mulPose(Axis.ZP.rotationDegrees(-(float) (System.currentTimeMillis() % 5400L) / 15L)); + poseStack.translate(-31 / 2f, -31 / 2f, 0); + guiGraphics.blit(SYMBLS, 0, 0, 32 * (symb % 8), 32 * (symb / 8), 32, 32); + poseStack.popPose(); + + symb = 8 % 64; + poseStack.pushPose(); + poseStack.translate(hPos + monitorWidth - 10, vPos + 10, 0); + poseStack.scale(2, 2, 1); + poseStack.mulPose(Axis.ZP.rotationDegrees(-(float) (System.currentTimeMillis() % 5400L) / 15L)); + poseStack.translate(-31 / 2f, -31 / 2f, 0); + guiGraphics.blit(SYMBLS, 0, 0, 32 * (symb % 8), 32 * (symb / 8), 32, 32); + poseStack.popPose(); + + boolean right = RIGHT != null && PREVIOUS != null && RIGHT == PREVIOUS && transitionStartTime >= 0; + boolean left = LEFT != null && PREVIOUS != null && LEFT == PREVIOUS && transitionStartTime >= 0; + float t = (age - transitionStartTime + partialTick) / 10f; + float o = -0.5f * Mth.cos(Mth.PI * t) + 0.5f; + + if (right || left) RenderSystem.setShaderColor(1, 1, 1, o); + RenderSystem.enableBlend(); + renderBackdrop(guiGraphics); + RenderSystem.enableBlend(); + if (right || left) RenderSystem.setShaderColor(1, 1, 1, 1 - o); + if (right) { + RIGHT.renderBackdrop(guiGraphics); + poseStack.translate(monitorWidth * o, 0, 0); + RIGHT.doRender(guiGraphics, mouseX, mouseY, partialTick); + } + + if (left) { + LEFT.renderBackdrop(guiGraphics); + poseStack.translate(-monitorWidth * o, 0, 0); + LEFT.doRender(guiGraphics, mouseX, mouseY, partialTick); + } + + if (right || left) poseStack.translate(right ? -monitorWidth : monitorWidth, 0, 0); + RenderSystem.setShaderColor(1, 1, 1, 1); + doRender(guiGraphics, mouseX, mouseY, partialTick); + + poseStack.popPose(); + + guiGraphics.disableScissor(); + RenderSystem.enableBlend(); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, (shakeAlpha + 1 - partialTick) / 100.0f); + guiGraphics.blit(NOISE, hPos + shakeX, vPos + shakeY, (int) (Math.random() * 736), (int) (414 * (System.currentTimeMillis() % 1000) / 1000.0), monitorWidth, monitorHeight); + RenderSystem.setShaderColor(1, 1, 1, 1); + + renderFrame(guiGraphics, mouseX, mouseY, partialTick); + RenderSystem.disableBlend(); + } + + public void doRender(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { + inMonitorRender(guiGraphics, mouseX, mouseY, partialTick); + RenderSystem.setShaderColor(1, 1, 1, 1); + super.render(guiGraphics, mouseX, mouseY, partialTick); + ScreenHelper.renderWidthScaledText(title.getString(), guiGraphics, Minecraft.getInstance().font, width / 2f, 5 + (height - monitorHeight) / 2f, Color.LIGHT_GRAY.getRGB(), 300, true); + } + + public void inMonitorRender(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { + } + + public void renderFrame(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { + int hPos = (width - frameWidth) / 2; + int vPos = -13 + (height - monitorHeight) / 2; + + guiGraphics.blit(FRAME, hPos + shakeX, vPos + shakeY, 0, 0, frameWidth, frameHeight); + } + + @Override + public void tick() { + super.tick(); + this.age++; + if (transitionStartTime >= 0 && age - transitionStartTime >= 10) transitionStartTime = -1; + + if (minecraft == null || minecraft.level == null) return; + boolean isCrashed = TardisClientData.getInstance(minecraft.level.dimension()).isCrashing(); + + this.shakeAlpha--; + + if (isCrashed) this.shakeAlpha = 50; + if (shakeAlpha < 0) shakeAlpha = 0; + + if (shakeAlpha > 0) { + this.shakeX = (int) (this.shakeAlpha * (Math.random() - 0.5) * 0.5); + this.shakeY = (int) (this.shakeAlpha * (Math.random() - 0.5) * 0.5); + } + } + + public void switchScreenToLeft(MonitorOS next) { + this.LEFT = next; + next.PREVIOUS = this; + next.RIGHT = this; + next.transition(); + Minecraft.getInstance().setScreen(next); + } + + public void switchScreenToRight(MonitorOS next) { + this.RIGHT = next; + next.PREVIOUS = this; + next.LEFT = this; + next.transition(); + Minecraft.getInstance().setScreen(next); + } + + public void transition() { + transitionStartTime = age; + } + + public void setEvents(MonitorOSRun onSubmit, MonitorOSRun onCancel) { + this.onSubmit = onSubmit; + this.onCancel = onCancel; + } + + public void addSubmitButton(int x, int y) { + if (onSubmit != null) { + SpriteIconButton spriteiconbutton = this.addRenderableWidget(CommonTRWidgets.imageButton(20, Component.translatable("Submit"), (arg) -> this.onSubmit.onPress(), true, BUTTON_LOCATION)); + spriteiconbutton.setPosition(x, y); + } + } + + public void addCancelButton(int x, int y) { + if (onCancel != null) { + SpriteIconButton spriteiconbutton = this.addRenderableWidget(CommonTRWidgets.imageButton(20, Component.translatable("Cancel"), (arg) -> this.onCancel.onPress(), true, BCK_LOCATION)); + spriteiconbutton.setPosition(x, y); + } + } + + public ObjectSelectionList createSelectionList() { + return null; + } + + @Override + public boolean isPauseScreen() { + return false; + } + + public interface MonitorOSRun { + void onPress(); + } + + public static class MonitorOSExtension extends MonitorOS { + + public MonitorOSExtension(Component title, ResourceLocation currentShellThem) { + super(title, null); + CURRENTSHELLTHEME = currentShellThem; + PATTERNCOLLECTION = ShellPatterns.getPatternCollectionForTheme(CURRENTSHELLTHEME); + THEMELIST = ShellTheme.SHELL_THEME_REGISTRY.keySet().stream().toList(); + generateDummyGlobalShell(); + } + + @Override + protected void init() { + super.init(); + if (CURRENTSHELLTHEME == null) CURRENTSHELLTHEME = THEMELIST.get(0); + if (PATTERN == null) PATTERN = PATTERNCOLLECTION.get(0); + } + + public static GlobalShellBlockEntity GLOBALSHELL_BLOCKENTITY; + public static ResourceLocation CURRENTSHELLTHEME; + public static ShellPattern PATTERN; + public static List THEMELIST; + public static List PATTERNCOLLECTION; + + public void renderShell(GuiGraphics guiGraphics, int x, int y, float scale) { + ShellModel model = ShellModelCollection.getInstance().getShellEntry(CURRENTSHELLTHEME).getShellModel(PATTERN); + model.setDoorPosition(false); + Lighting.setupForEntityInInventory(); + PoseStack pose = guiGraphics.pose(); + pose.pushPose(); + pose.translate((float) x, y, 100.0F); + pose.scale(-scale, scale, scale); + pose.mulPose(Axis.XP.rotationDegrees(-15F)); + pose.mulPose(Axis.YP.rotationDegrees((float) (System.currentTimeMillis() % 5400L) / 15L)); + + VertexConsumer vertexConsumer = guiGraphics.bufferSource().getBuffer(model.renderType(model.getShellTexture(PATTERN, false))); + model.renderShell(GLOBALSHELL_BLOCKENTITY, false, false, pose, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F); + guiGraphics.flush(); + pose.popPose(); + Lighting.setupFor3DItems(); + } + + public static void generateDummyGlobalShell() { + GLOBALSHELL_BLOCKENTITY = new GlobalShellBlockEntity(BlockPos.ZERO, TRBlockRegistry.GLOBAL_SHELL_BLOCK.get().defaultBlockState()); + assert Minecraft.getInstance().level != null; + GLOBALSHELL_BLOCKENTITY.setLevel(Minecraft.getInstance().level); + ResourceKey generatedLevelKey = ResourceKey.create(Registries.DIMENSION, new ResourceLocation(TardisRefined.MODID, UUID.randomUUID().toString())); + GLOBALSHELL_BLOCKENTITY.setTardisId(generatedLevelKey); + GLOBALSHELL_BLOCKENTITY.setShellTheme(ShellTheme.POLICE_BOX.getId()); + GLOBALSHELL_BLOCKENTITY.setPattern(ShellPatterns.DEFAULT); + } + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/main/MonitorScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/main/MonitorScreen.java new file mode 100644 index 000000000..aa7d1b3fe --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/main/MonitorScreen.java @@ -0,0 +1,180 @@ +package whocraft.tardis_refined.client.screen.main; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Axis; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.components.Tooltip; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; +import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.client.screen.ScreenHelper; +import whocraft.tardis_refined.client.screen.components.BackgroundlessButton; +import whocraft.tardis_refined.client.screen.components.GenericMonitorSelectionList; +import whocraft.tardis_refined.client.screen.components.SelectionListEntry; +import whocraft.tardis_refined.client.screen.ponder.PonderListScreen; +import whocraft.tardis_refined.client.screen.ponder.PonderScreen; +import whocraft.tardis_refined.client.screen.screens.DesktopSelectionScreen; +import whocraft.tardis_refined.client.screen.screens.HumSelectionScreen; +import whocraft.tardis_refined.client.screen.screens.VortexSelectionScreen; +import whocraft.tardis_refined.common.VortexRegistry; +import whocraft.tardis_refined.common.capability.tardis.upgrades.UpgradeHandler; +import whocraft.tardis_refined.common.crafting.astral_manipulator.ManipulatorCraftingRecipe; +import whocraft.tardis_refined.common.crafting.astral_manipulator.ManipulatorRecipes; +import whocraft.tardis_refined.common.network.messages.C2SEjectPlayer; +import whocraft.tardis_refined.common.network.messages.player.C2SBeginShellView; +import whocraft.tardis_refined.common.network.messages.screens.C2SRequestShellSelection; +import whocraft.tardis_refined.common.network.messages.waypoints.C2SRequestWaypoints; +import whocraft.tardis_refined.common.tardis.TardisNavLocation; +import whocraft.tardis_refined.common.util.MiscHelper; +import whocraft.tardis_refined.constants.ModMessages; +import whocraft.tardis_refined.registry.TRUpgrades; + +import java.awt.*; + + +public class MonitorScreen extends MonitorOS.MonitorOSExtension { + + private final TardisNavLocation currentLocation; + private final TardisNavLocation targetLocation; + private final UpgradeHandler upgradeHandler; + + private boolean noUpgrades = false; + + public MonitorScreen(TardisNavLocation currentLocation, TardisNavLocation targetLocation, UpgradeHandler upgradeHandler, ResourceLocation currentShellTheme) { + super(Component.translatable(ModMessages.UI_MONITOR_MAIN_TITLE), currentShellTheme); + this.currentLocation = currentLocation; + this.targetLocation = targetLocation; + this.upgradeHandler = upgradeHandler; + } + + private Button ejectbtn; + private int ejectbtntime; + private boolean ejectbtnshow; + + @Override + protected void init() { + super.init(); + int hPos = (width - monitorWidth) / 2; + int vPos = (height - monitorHeight) / 2; + + //shellSelectButton.active = TRUpgrades.CHAMELEON_CIRCUIT_SYSTEM.get().isUnlocked(upgradeHandler); +/* + Button vortxSelectButton = addRenderableWidget( + Button.builder(Component.translatable(ModMessages.UI_MONITOR_VORTEX), + button -> this.switchScreenToLeft(new VortexSelectionScreen(currentVortex))) + .pos(hPos + 5, -20 + height / 2) + .size(70, 20).build()); + vortxSelectButton.active = true; +*/ + BackgroundlessButton extView = addRenderableWidget(BackgroundlessButton.backgroundlessBuilder(Component.literal(""), button -> new C2SBeginShellView().send()).pos(hPos + 20, -30 + height / 2).size(40, 60).build()); + extView.setTooltip(Tooltip.create(Component.translatable(ModMessages.UI_MONITOR_SHELL_VIEW))); + extView.active = true; + + ejectbtn = addRenderableWidget(Button.builder(Component.translatable(ModMessages.UI_MONITOR_EJECT), button -> { + new C2SEjectPlayer().send(); + Minecraft.getInstance().setScreen(null); + }).pos(-35 + hPos + monitorWidth / 2, vPos + monitorHeight - 20).size(70, 20).build()); + + } + + @Override + public void renderBackdrop(@NotNull GuiGraphics guiGraphics) { + super.renderBackdrop(guiGraphics); + + PoseStack poseStack = guiGraphics.pose(); + + int hPos = (width - monitorWidth) / 2; + int vPos = (height - monitorHeight) / 2; + + poseStack.pushPose(); + int b = height - vPos, r = width - hPos; + int l1 = hPos + monitorWidth / 5, l2 = (int) (hPos + monitorWidth / 2.5f); + + guiGraphics.fill(l1, vPos, r, b, -1072689136); + poseStack.translate(l1, vPos, 0); + poseStack.mulPose(Axis.ZP.rotationDegrees(90)); + guiGraphics.fillGradient(0, 0, monitorHeight, l1 - hPos, -1072689136, 0x00000000); + poseStack.popPose(); + } + + @Override + public void inMonitorRender(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { + PoseStack poseStack = guiGraphics.pose(); + int upgradesLeftPos = width / 2 - 75; + int hPos = (width - monitorWidth) / 2; + int vPos = (height - monitorHeight) / 2; + + + this.ejectbtnshow = (mouseY >= vPos + monitorHeight - 20 && mouseY <= vPos + monitorHeight) && (mouseX >= -35 + hPos + monitorWidth / 2 && mouseX <= 70 - 35 + hPos + monitorWidth / 2); + + ejectbtn.setPosition(-35 + hPos + monitorWidth / 2, vPos + monitorHeight - ejectbtntime); + ejectbtn.active = ejectbtntime == 20; + + + if (noUpgrades && ChatFormatting.GOLD.getColor() != null) { + guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable(ModMessages.UI_NO_INSTALLED_SUBSYSTEMS).getString(), upgradesLeftPos, vPos + 30, ChatFormatting.GOLD.getColor()); + } + + poseStack.pushPose(); + poseStack.translate(0, 0, 1000); + renderShell(guiGraphics, hPos + 40, -1 + height / 2, 15F); + poseStack.popPose(); + + int textScale = 40; + + poseStack.pushPose(); + poseStack.translate(hPos + 10, vPos + 10, 0); + guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable(ModMessages.UI_MONITOR_GPS).getString() + ":", 0, 0, Color.WHITE.getRGB()); + ScreenHelper.renderWidthScaledText(currentLocation.getDirection().getName().toUpperCase() + " @ " + currentLocation.getPosition().toShortString(), guiGraphics, Minecraft.getInstance().font, 0, 10, Color.LIGHT_GRAY.getRGB(), textScale * 2, 0.75F, false); + ScreenHelper.renderWidthScaledText(MiscHelper.getCleanDimensionName(currentLocation.getDimensionKey()), guiGraphics, Minecraft.getInstance().font, 0, 20, Color.LIGHT_GRAY.getRGB(), textScale - 3, 1.5F, false); + poseStack.popPose(); + + poseStack.pushPose(); + poseStack.translate(hPos + 10, vPos + monitorHeight - 35, 0); + guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable(ModMessages.UI_MONITOR_DESTINATION).getString() + ":", 0, 0, Color.WHITE.getRGB()); + ScreenHelper.renderWidthScaledText(targetLocation.getDirection().getName().toUpperCase() + " @ " + targetLocation.getPosition().toShortString(), guiGraphics, Minecraft.getInstance().font, 0, 10, Color.LIGHT_GRAY.getRGB(), textScale * 2, 0.75F, false); + ScreenHelper.renderWidthScaledText(MiscHelper.getCleanDimensionName(targetLocation.getDimensionKey()), guiGraphics, Minecraft.getInstance().font, 0, 20, Color.LIGHT_GRAY.getRGB(), textScale - 3, 1.5F, false); + poseStack.popPose(); + } + + @Override + public void tick() { + super.tick(); + + if (ejectbtnshow) ejectbtntime += 5 - ejectbtntime / 4; + else ejectbtntime -= 5 - (20 - ejectbtntime) / 4; + if (ejectbtntime > 20) ejectbtntime = 20; + if (ejectbtntime < 5) ejectbtntime = 5; + + } + + @Override + public GenericMonitorSelectionList createSelectionList() { + int hPos = -20 + width / 2; + int vPos = 20 + (height - monitorHeight) / 2; + GenericMonitorSelectionList selectionList = new GenericMonitorSelectionList<>(this.minecraft, 15 + monitorWidth / 2, 80, hPos, vPos, height - vPos, 12); + selectionList.setRenderBackground(false); + selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_EXTERNAL_SHELL), entry -> new C2SRequestShellSelection().send(), hPos, TRUpgrades.CHAMELEON_CIRCUIT_SYSTEM.get().isUnlocked(upgradeHandler))); + selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_DESKTOP_CONFIGURATION), entry -> switchScreenToRight(new DesktopSelectionScreen()), hPos, TRUpgrades.INSIDE_ARCHITECTURE.get().isUnlocked(upgradeHandler))); + selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_MONITOR_WAYPOINTS), entry -> new C2SRequestWaypoints().send(), hPos, TRUpgrades.WAYPOINTS.get().isUnlocked(upgradeHandler))); + //selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_MONITOR_SHELL_VIEW), entry -> new C2SBeginShellView().send(), hPos, TRUpgrades.WAYPOINTS.get().isUnlocked(upgradeHandler))); + selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_MONITOR_VORTEX), entry -> switchScreenToRight(new VortexSelectionScreen(currentVortex)), hPos)); + selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_MONITOR_SELECT_HUM), entry -> switchScreenToRight(new HumSelectionScreen()), hPos)); + //selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_MONITOR_EJECT), entry -> { + // new C2SEjectPlayer().send(); + // Minecraft.getInstance().setScreen(null); + //}, hPos)); + + if (selectionList.children().isEmpty()) { + noUpgrades = true; + return null; + } + + return selectionList; + } + +} diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/ponder/PonderListScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/ponder/PonderListScreen.java new file mode 100644 index 000000000..27af9bc15 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/ponder/PonderListScreen.java @@ -0,0 +1,50 @@ +package whocraft.tardis_refined.client.screen.ponder; + +import com.mojang.brigadier.StringReader; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.components.ObjectSelectionList; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.client.screen.components.GenericMonitorSelectionList; +import whocraft.tardis_refined.client.screen.components.SelectionListEntry; +import whocraft.tardis_refined.client.screen.main.MonitorOS; +import whocraft.tardis_refined.common.crafting.astral_manipulator.ManipulatorCraftingRecipe; +import whocraft.tardis_refined.common.hum.HumEntry; +import whocraft.tardis_refined.common.hum.TardisHums; +import whocraft.tardis_refined.common.util.MiscHelper; + +import java.util.Collection; +import java.util.Comparator; +import java.util.List; + +public class PonderListScreen extends MonitorOS { + + public PonderListScreen() { + super(Component.literal(""), new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor/backdrop.png")); + } + + @Override + public ObjectSelectionList createSelectionList() { + int vPos = (height - monitorHeight) / 2; + int leftPos = this.width / 2 - 75; + GenericMonitorSelectionList selectionList = new GenericMonitorSelectionList<>(this.minecraft, 150, 80, leftPos, vPos + 15, vPos + monitorHeight - 30, 12); + selectionList.setRenderBackground(false); + + if (Minecraft.getInstance().level == null) return null; + if (ManipulatorCraftingRecipe.getAllRecipes(Minecraft.getInstance().level).isEmpty()) return null; + + List recipes = ManipulatorCraftingRecipe.getAllRecipes(Minecraft.getInstance().level); + + + for (ManipulatorCraftingRecipe recipe : recipes) { + Component name = PonderScreen.getResultName(recipe); + + selectionList.children().add(new SelectionListEntry(name, (entry) -> { + Minecraft.getInstance().setScreen(new PonderScreen(recipe)); + }, leftPos)); + } + + return selectionList; + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/ponder/PonderScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/ponder/PonderScreen.java new file mode 100644 index 000000000..6f4864454 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/ponder/PonderScreen.java @@ -0,0 +1,177 @@ +package whocraft.tardis_refined.client.screen.ponder; + +import com.mojang.blaze3d.platform.Lighting; +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Axis; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.ObjectSelectionList; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.NotNull; +import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.client.ScreenHandler; +import whocraft.tardis_refined.client.screen.components.GenericMonitorSelectionList; +import whocraft.tardis_refined.client.screen.components.SelectionListEntry; +import whocraft.tardis_refined.client.screen.main.MonitorOS; +import whocraft.tardis_refined.common.crafting.astral_manipulator.ManipulatorBlockResult; +import whocraft.tardis_refined.common.crafting.astral_manipulator.ManipulatorCraftingIngredient; +import whocraft.tardis_refined.common.crafting.astral_manipulator.ManipulatorCraftingRecipe; +import whocraft.tardis_refined.common.crafting.astral_manipulator.ManipulatorItemResult; + +import java.util.HashMap; +import java.util.Map; + +public class PonderScreen extends MonitorOS { + + private final ManipulatorCraftingRecipe recipe; + private final int xSize, ySize, zSize; + private int age = 0; + + // Variables for rotation + private float rotationX = -45F; + private float rotationY = 45F; + private boolean isDragging = false; + + public PonderScreen(ManipulatorCraftingRecipe recipe) { + super(getResultName(recipe), new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor/backdrop.png")); + + this.setEvents(() -> { + + }, ScreenHandler::openCraftingScreen); + + this.recipe = recipe; + int minX = 100, maxX = -100, minY = 100, maxY = -100, minZ = 100, maxZ = -100; + for (ManipulatorCraftingIngredient ingredient : recipe.ingredients()) { + BlockPos pos = ingredient.relativeBlockPos(); + minX = Math.min(minX, pos.getX()); + maxX = Math.max(maxX, pos.getX()); + minY = Math.min(minY, pos.getY()); + maxY = Math.max(maxY, pos.getY()); + minZ = Math.min(minZ, pos.getZ()); + maxZ = Math.max(maxZ, pos.getZ()); + } + xSize = maxX - minX; + ySize = maxY - minY; + zSize = maxZ - minZ; + } + + public static Component getResultName(ManipulatorCraftingRecipe recipe) { + if (recipe.result() instanceof ManipulatorBlockResult blockResult) { + BlockState blockState = blockResult.recipeOutput(); + return blockState.getBlock().getName(); + } else if (recipe.result() instanceof ManipulatorItemResult itemResult) { + ItemStack itemStack = itemResult.recipeOutput(); + return itemStack.getHoverName(); + } + return Component.literal("What on earth are you crafting?"); + } + + @Override + protected void init() { + super.init(); + int vPos = (height - monitorHeight) / 2; + addCancelButton(width / 2 - 105, height - vPos - 25); + } + + @Override + public ObjectSelectionList createSelectionList() { + int leftPos = width / 2; + int topPos = (height - monitorHeight) / 2; + GenericMonitorSelectionList selectionList = new GenericMonitorSelectionList<>( + this.minecraft, 105, 80, leftPos, topPos + 15, topPos + monitorHeight - 30, 12 + ); + selectionList.setRenderBackground(false); + + // Map to track item names and their counts + Map itemCounts = new HashMap<>(); + for (ManipulatorCraftingIngredient ingredient : recipe.ingredients()) { + String itemName = new ItemStack(ingredient.inputBlockState().getBlock()).getHoverName().getString(); + itemCounts.put(itemName, itemCounts.getOrDefault(itemName, 0) + 1); + } + + // Add entries to the selection list with item count + for (Map.Entry entry : itemCounts.entrySet()) { + String itemNameWithCount = entry.getValue() + "x " + entry.getKey(); + SelectionListEntry selectionListEntry = new SelectionListEntry( + Component.literal(itemNameWithCount), (entryCallback) -> { + }, leftPos); + selectionList.children().add(selectionListEntry); + } + + return selectionList; + } + + @Override + public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { + super.render(guiGraphics, mouseX, mouseY, partialTick); + assert minecraft != null; + + if (recipe.ingredients().isEmpty()) return; + + PoseStack pose = guiGraphics.pose(); + + Lighting.setupFor3DItems(); + pose.pushPose(); + pose.translate((float) width / 2 - 50, height / 2f, 500); + pose.mulPose(Axis.XP.rotationDegrees(rotationX / 2)); + pose.mulPose(Axis.YP.rotationDegrees(rotationY)); + pose.scale(-20, -20, -20); + pose.translate(-xSize / 2f, -ySize / 2f, -zSize / 2f); + + int i = 0; + int e = age / 10; + for (ManipulatorCraftingIngredient ingredient : recipe.ingredients()) { + if (i > e % recipe.ingredients().size()) break; + BlockState s = ingredient.inputBlockState(); + BlockPos pos = ingredient.relativeBlockPos(); + pose.pushPose(); + pose.translate(pos.getX(), pos.getY(), pos.getZ()); + assert minecraft.level != null; + RenderSystem.setShaderColor(1, 1, 1, 1); + minecraft.getBlockRenderer().renderSingleBlock(s, guiGraphics.pose(), guiGraphics.bufferSource(), LightTexture.FULL_BLOCK, OverlayTexture.NO_OVERLAY); + pose.popPose(); + i++; + } + + guiGraphics.flush(); + Lighting.setupFor3DItems(); + pose.popPose(); + } + + @Override + public void tick() { + super.tick(); + age++; + } + + @Override + public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { + if (isDragging) { + rotationY += (float) (deltaX * 0.5f); + rotationX -= (float) (deltaY * 0.5f); + rotationX = Math.max(-90, Math.min(90, rotationX)); + } + return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY); + } + + @Override + public boolean mouseClicked(double mouseX, double mouseY, int button) { + isDragging = true; + return super.mouseClicked(mouseX, mouseY, button); + } + + @Override + public boolean mouseReleased(double mouseX, double mouseY, int button) { + if (button == 0) { // Left mouse button + isDragging = false; + return true; + } + return super.mouseReleased(mouseX, mouseY, button); + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/CancelDesktopScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/CancelDesktopScreen.java similarity index 59% rename from common/src/main/java/whocraft/tardis_refined/client/screen/CancelDesktopScreen.java rename to common/src/main/java/whocraft/tardis_refined/client/screen/screens/CancelDesktopScreen.java index 5ab13d988..607f9147e 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/CancelDesktopScreen.java +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/CancelDesktopScreen.java @@ -1,27 +1,27 @@ -package whocraft.tardis_refined.client.screen; +package whocraft.tardis_refined.client.screen.screens; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; -import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; +import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.client.screen.ScreenHelper; +import whocraft.tardis_refined.client.screen.main.MonitorOS; +import whocraft.tardis_refined.client.screen.main.MonitorScreen; import whocraft.tardis_refined.common.network.messages.C2SCancelDesktopChange; import whocraft.tardis_refined.constants.ModMessages; import java.awt.*; -public class CancelDesktopScreen extends Screen { - - protected int imageWidth = 256; - protected int imageHeight = 173; - private int leftPos, topPos; - +public class CancelDesktopScreen extends MonitorOS { public CancelDesktopScreen() { - super(Component.translatable(ModMessages.UI_DESKTOP_CANCEL_DESKTOP)); + super(Component.translatable(ModMessages.UI_DESKTOP_CANCEL_DESKTOP), new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor/backdrop.png")); } @Override @@ -29,7 +29,6 @@ public boolean isPauseScreen() { return true; } - @Override protected void init() { super.init(); @@ -42,30 +41,13 @@ protected void init() { Minecraft.getInstance().setScreen(null); }).bounds(this.width / 2 - (175 / 2), this.height / 2 + 30, 175, 20).build()); - this.leftPos = (this.width - this.imageWidth) / 2; - this.topPos = (this.height - this.imageHeight) / 2; } - @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - this.renderTransparentBackground(guiGraphics); - - RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - guiGraphics.blit(MonitorScreen.MONITOR_TEXTURE, leftPos, topPos, 0, 0, imageWidth, imageHeight); - - ScreenHelper.renderWidthScaledText(Component.translatable(ModMessages.UI_DESKTOP_CANCEL_TITLE).getString(), guiGraphics, Minecraft.getInstance().font, width / 2, height / 2 - 30, Color.LIGHT_GRAY.getRGB(), 300, true); - ScreenHelper.renderWidthScaledText(Component.translatable(ModMessages.UI_DESKTOP_CANCEL_DESCRIPTION).getString(), guiGraphics, Minecraft.getInstance().font, width / 2, this.height / 2 - 20, Color.WHITE.getRGB(), 210, true); - ScreenHelper.renderWidthScaledText(Component.translatable(ModMessages.UI_DESKTOP_CANCEL_DESKTOP).getString(), guiGraphics, Minecraft.getInstance().font, width / 2, this.height / 2 - 10, Color.WHITE.getRGB(), 210, true); - - - super.render(guiGraphics, i, j, f); - + public void inMonitorRender(@NotNull GuiGraphics guiGraphics, int i, int j, float f) { + ScreenHelper.renderWidthScaledText(Component.translatable(ModMessages.UI_DESKTOP_CANCEL_TITLE).getString(), guiGraphics, Minecraft.getInstance().font, width / 2f, height / 2f - 30, Color.LIGHT_GRAY.getRGB(), 300, true); + ScreenHelper.renderWidthScaledText(Component.translatable(ModMessages.UI_DESKTOP_CANCEL_DESCRIPTION).getString(), guiGraphics, Minecraft.getInstance().font, width / 2f, this.height / 2f - 20, Color.WHITE.getRGB(), 210, true); + ScreenHelper.renderWidthScaledText(Component.translatable(ModMessages.UI_DESKTOP_CANCEL_DESKTOP).getString(), guiGraphics, Minecraft.getInstance().font, width / 2f, this.height / 2f - 10, Color.WHITE.getRGB(), 210, true); } - @Override - public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) { - - } } diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/selections/DesktopSelectionScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/DesktopSelectionScreen.java similarity index 56% rename from common/src/main/java/whocraft/tardis_refined/client/screen/selections/DesktopSelectionScreen.java rename to common/src/main/java/whocraft/tardis_refined/client/screen/screens/DesktopSelectionScreen.java index 886103e52..ffeba3a93 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/selections/DesktopSelectionScreen.java +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/DesktopSelectionScreen.java @@ -1,18 +1,20 @@ -package whocraft.tardis_refined.client.screen.selections; +package whocraft.tardis_refined.client.screen.screens; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.brigadier.StringReader; +import com.mojang.math.Axis; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.ObjectSelectionList; -import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.client.screen.components.GenericMonitorSelectionList; import whocraft.tardis_refined.client.screen.components.SelectionListEntry; +import whocraft.tardis_refined.client.screen.main.MonitorOS; import whocraft.tardis_refined.common.network.messages.C2SChangeDesktop; import whocraft.tardis_refined.common.tardis.TardisDesktops; import whocraft.tardis_refined.common.tardis.themes.DesktopTheme; @@ -20,43 +22,35 @@ import whocraft.tardis_refined.constants.ModMessages; import whocraft.tardis_refined.registry.TRSoundRegistry; -import static whocraft.tardis_refined.client.screen.selections.ShellSelectionScreen.NOISE; +import java.util.Collection; +import java.util.Comparator; -public class DesktopSelectionScreen extends SelectionScreen { +public class DesktopSelectionScreen extends MonitorOS { - public static ResourceLocation MONITOR_TEXTURE = new ResourceLocation(TardisRefined.MODID, "textures/gui/desktop.png"); - public static ResourceLocation MONITOR_TEXTURE_OVERLAY = new ResourceLocation(TardisRefined.MODID, "textures/gui/desktop_overlay.png"); public static ResourceLocation previousImage = TardisDesktops.FACTORY_THEME.getPreviewTexture(); - protected int imageWidth = 256; - protected int imageHeight = 173; private DesktopTheme currentDesktopTheme; - private int leftPos, topPos; public DesktopSelectionScreen() { - super(Component.translatable(ModMessages.UI_DESKTOP_SELECTION)); + super(Component.translatable(ModMessages.UI_DESKTOP_CONFIGURATION), new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor/backdrop.png")); } public static void selectDesktop(DesktopTheme theme) { + assert Minecraft.getInstance().player != null; new C2SChangeDesktop(Minecraft.getInstance().player.level().dimension(), theme).send(); Minecraft.getInstance().setScreen(null); } @Override protected void init() { - this.setEvents(() -> { - DesktopSelectionScreen.selectDesktop(currentDesktopTheme); - }, () -> { - Minecraft.getInstance().setScreen(null); + super.init(); + this.setEvents(() -> DesktopSelectionScreen.selectDesktop(currentDesktopTheme), () -> { + if (PREVIOUS != null) + this.switchScreenToLeft(PREVIOUS); }); this.currentDesktopTheme = grabDesktop(); - - this.leftPos = (this.width - this.imageWidth) / 2; - this.topPos = (this.height - this.imageHeight) / 2; - - addSubmitButton(width / 2 + 90, (height) / 2 + 35); - addCancelButton(width / 2 + 40, (height) / 2 + 35); - - super.init(); + int vPos = (height - monitorHeight) / 2; + addSubmitButton(width / 2 + 25, height - vPos - 25); + addCancelButton(width / 2 + 5, height - vPos - 25); } private DesktopTheme grabDesktop() { @@ -67,74 +61,60 @@ private DesktopTheme grabDesktop() { } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - this.renderTransparentBackground(guiGraphics); - - PoseStack poseStack = guiGraphics.pose(); + public void renderBackdrop(@NotNull GuiGraphics guiGraphics) { + super.renderBackdrop(guiGraphics); + } - /*Render Back drop*/ - RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - guiGraphics.blit(MONITOR_TEXTURE, leftPos, topPos, 0, 0, imageWidth, imageHeight); + @Override + public void inMonitorRender(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { + PoseStack poseStack = guiGraphics.pose(); + int hPos = (width - monitorWidth) / 2; + int vPos = (height - monitorHeight) / 2; /*Render Interior Image*/ RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + guiGraphics.blit(backdrop, 5 + width / 2, -50 + height / 2, 110, monitorHeight, 110, 95); poseStack.pushPose(); - poseStack.translate(width / 2 - 110, height / 2 - 72, 0); - poseStack.scale(0.31333333F, 0.31333333F, 0.313333330F); - + int trim = 15; + poseStack.translate(hPos + trim - 5, vPos + trim + 5, 0); + float scale = (monitorHeight - 2 * trim) / 400.0f; + guiGraphics.blit(backdrop, -5, -5, 0, monitorHeight, 110, 110); + poseStack.scale(scale, scale, scale); guiGraphics.blit(currentDesktopTheme.getPreviewTexture(), 0, 0, 0, 0, 400, 400, 400, 400); double alpha = (100.0D - this.age * 3.0D) / 100.0D; RenderSystem.enableBlend(); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, (float) alpha); - guiGraphics.blit(previousImage, (int) ((Math.random() * 14) - 2), (int) ((Math.random() * 14) - 2), 400, 400, 400, 400); + guiGraphics.blit(previousImage, 0, 0, 400, 400, 400, 400); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, (float) alpha); RenderSystem.setShaderTexture(0, NOISE); - guiGraphics.blit(NOISE, 0, 0, this.noiseX, this.noiseY, 400, 400); + guiGraphics.blit(NOISE, 0, 0, (int) (Math.random() * 736), (int) (414 * (System.currentTimeMillis() % 1000) / 1000.0), 400, 400); RenderSystem.disableBlend(); poseStack.popPose(); - - /*Render Back drop*/ - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - guiGraphics.blit(MONITOR_TEXTURE_OVERLAY, leftPos, topPos, 0, 0, imageWidth, imageHeight); - - super.render(guiGraphics, i, j, f); - - - } - - @Override - public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) { - } @Override - public Component getSelectedDisplayName() { - return Component.Serializer.fromJson(currentDesktopTheme.getName()); - } - - @Override - public ObjectSelectionList createSelectionList() { - int leftPos = width / 2 + 45; - GenericMonitorSelectionList selectionList = new GenericMonitorSelectionList<>(this.minecraft, 57, 80, leftPos, this.topPos + 30, this.topPos + this.imageHeight - 60, 12); + public ObjectSelectionList createSelectionList() { + int leftPos = 5 + width / 2; + int topPos = (height - monitorHeight) / 2; + GenericMonitorSelectionList selectionList = new GenericMonitorSelectionList<>(this.minecraft, 100, 80, leftPos, topPos + 15, topPos + monitorHeight - 30, 12); selectionList.setRenderBackground(false); - for (DesktopTheme desktop : TardisDesktops.getRegistry().values()) { + Collection values = TardisDesktops.getRegistry().values(); + values = values.stream().sorted(Comparator.comparing(DesktopTheme::getName)).toList(); + for (DesktopTheme desktop : values) { Component name = Component.literal(MiscHelper.getCleanName(desktop.getIdentifier().getPath())); - // Check for if the tellraw name is incomplete, or fails to pass. try { - var json = Component.Serializer.fromJson(new StringReader(desktop.getName())); - name = json; + name = Component.Serializer.fromJson(new StringReader(desktop.getName())); } catch (Exception ex) { - TardisRefined.LOGGER.error("Could not process Name for datapack desktop " + desktop.getIdentifier().toString()); + TardisRefined.LOGGER.error("Could not process Name for datapack desktop {}", desktop.getIdentifier().toString()); } selectionList.children().add(new SelectionListEntry(name, (entry) -> { @@ -155,5 +135,4 @@ public ObjectSelectionList createSelectionList() { return selectionList; } - } \ No newline at end of file diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/selections/HumSelectionScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/HumSelectionScreen.java similarity index 52% rename from common/src/main/java/whocraft/tardis_refined/client/screen/selections/HumSelectionScreen.java rename to common/src/main/java/whocraft/tardis_refined/client/screen/screens/HumSelectionScreen.java index 299aa8fb9..d747df9b2 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/selections/HumSelectionScreen.java +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/HumSelectionScreen.java @@ -1,110 +1,62 @@ -package whocraft.tardis_refined.client.screen.selections; +package whocraft.tardis_refined.client.screen.screens; -import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.brigadier.StringReader; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.ObjectSelectionList; -import net.minecraft.client.renderer.GameRenderer; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.client.screen.components.GenericMonitorSelectionList; import whocraft.tardis_refined.client.screen.components.SelectionListEntry; +import whocraft.tardis_refined.client.screen.main.MonitorOS; import whocraft.tardis_refined.common.hum.HumEntry; import whocraft.tardis_refined.common.hum.TardisHums; import whocraft.tardis_refined.common.network.messages.hums.C2SChangeHum; import whocraft.tardis_refined.common.util.MiscHelper; +import whocraft.tardis_refined.constants.ModMessages; import java.util.Collection; import java.util.Comparator; -public class HumSelectionScreen extends SelectionScreen { - public static ResourceLocation MONITOR_TEXTURE = new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor.png"); - protected int imageWidth = 256; - protected int imageHeight = 173; - private HumEntry currentHumEntry; - private int leftPos, topPos; +public class HumSelectionScreen extends MonitorOS { + private HumEntry currentHumEntry; public HumSelectionScreen() { - super(Component.translatable("")); + super(Component.translatable(ModMessages.UI_MONITOR_SELECT_HUM), new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor/backdrop.png")); } public static void selectHum(HumEntry theme) { + assert Minecraft.getInstance().player != null; new C2SChangeHum(Minecraft.getInstance().player.level().dimension(), theme).send(); - Minecraft.getInstance().setScreen(null); - } - - @Override - public void addSubmitButton(int x, int y) { - super.addSubmitButton(x, y); - } - - @Override - public boolean isPauseScreen() { - return false; + //Minecraft.getInstance().setScreen(null); } @Override protected void init() { - this.setEvents(() -> { - HumSelectionScreen.selectHum(currentHumEntry); - }, () -> { - Minecraft.getInstance().setScreen(null); + super.init(); + this.setEvents(() -> HumSelectionScreen.selectHum(currentHumEntry), () -> { + if (PREVIOUS != null) + this.switchScreenToLeft(PREVIOUS); }); this.currentHumEntry = grabHum(); - - this.leftPos = (this.width - this.imageWidth) / 2; - this.topPos = (this.height - this.imageHeight) / 2; - - //Super method already creates the list, we don't need to create it a second time. - super.init(); - - addSubmitButton(width / 2 + 85, (height) / 2 + 35); - addCancelButton(width / 2 - 105, (height) / 2 + 35); - } - - @Override - public boolean mouseClicked(double d, double e, int i) { - return super.mouseClicked(d, e, i); + int vPos = (height - monitorHeight) / 2; + addSubmitButton(width / 2 + 85, height - vPos - 25); + addCancelButton(width / 2 - 105, height - vPos - 25); } private HumEntry grabHum() { - for (HumEntry humEntry : TardisHums.getRegistry().values()) { + for (HumEntry humEntry : TardisHums.getRegistry().values()) return humEntry; - } - return null; - } - - @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - this.renderTransparentBackground(guiGraphics); - - - /*Render Back drop*/ - RenderSystem.setShader(GameRenderer::getPositionTexShader); - guiGraphics.blit(MONITOR_TEXTURE, leftPos, topPos, 0, 0, imageWidth, imageHeight); - - - super.render(guiGraphics, i, j, f); + return null; } @Override - public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) { - - } - - @Override - public Component getSelectedDisplayName() { - return Component.Serializer.fromJson(currentHumEntry.getNameComponent()); - } - - @Override - public ObjectSelectionList createSelectionList() { + public ObjectSelectionList createSelectionList() { + int vPos = (height - monitorHeight) / 2; int leftPos = this.width / 2 - 75; - GenericMonitorSelectionList selectionList = new GenericMonitorSelectionList<>(this.minecraft, 150, 80, leftPos, this.topPos + 30, this.topPos + this.imageHeight - 60, 12); + GenericMonitorSelectionList selectionList = new GenericMonitorSelectionList<>(this.minecraft, 150, 80, leftPos, vPos + 15, vPos + monitorHeight - 30, 12); selectionList.setRenderBackground(false); Collection knownHums = TardisHums.getRegistry().values(); @@ -115,10 +67,9 @@ public ObjectSelectionList createSelectionList() { // Check for if the tellraw name is incomplete, or fails to pass. try { - var json = Component.Serializer.fromJson(new StringReader(humEntry.getNameComponent())); - name = json; + name = Component.Serializer.fromJson(new StringReader(humEntry.getNameComponent())); } catch (Exception ex) { - TardisRefined.LOGGER.error("Could not process Name for hum " + humEntry.getIdentifier().toString()); + TardisRefined.LOGGER.error("Could not process Name for hum {}", humEntry.getIdentifier().toString()); } selectionList.children().add(new SelectionListEntry(name, (entry) -> { diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/screens/ShellSelectionScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/ShellSelectionScreen.java new file mode 100644 index 000000000..13d2bb7a0 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/ShellSelectionScreen.java @@ -0,0 +1,141 @@ +package whocraft.tardis_refined.client.screen.screens; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.brigadier.StringReader; +import com.mojang.math.Axis; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.Button; +import net.minecraft.core.Holder; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; +import whocraft.tardis_refined.client.screen.components.GenericMonitorSelectionList; +import whocraft.tardis_refined.client.screen.components.SelectionListEntry; +import whocraft.tardis_refined.client.screen.main.MonitorOS; +import whocraft.tardis_refined.common.network.messages.C2SChangeShell; +import whocraft.tardis_refined.common.tardis.TardisDesktops; +import whocraft.tardis_refined.common.tardis.themes.DesktopTheme; +import whocraft.tardis_refined.common.tardis.themes.ShellTheme; +import whocraft.tardis_refined.constants.ModMessages; +import whocraft.tardis_refined.patterns.ShellPatterns; + +import java.util.Collection; +import java.util.Comparator; + +public class ShellSelectionScreen extends MonitorOS.MonitorOSExtension { + + private Button patternButton; + + public ShellSelectionScreen(ResourceLocation currentShellTheme) { + super(Component.translatable(ModMessages.UI_SHELL_SELECTION), currentShellTheme); + } + + @Override + protected void init() { + super.init(); + this.setEvents( + () -> selectShell(CURRENTSHELLTHEME), + () -> { + //selectShell(CURRENTSHELLTHEME); + if (PREVIOUS != null) + this.switchScreenToLeft(PREVIOUS); + } + ); + + int vPos = (height - monitorHeight) / 2; + + addSubmitButton(width / 2 + 90, height - vPos - 25); + addCancelButton(width / 2 - 11, height - vPos - 25); + + patternButton = addRenderableWidget(Button.builder(Component.literal(""), button -> { + PATTERN = ShellPatterns.next(PATTERNCOLLECTION, PATTERN); + button.setMessage(Component.Serializer.fromJson(new StringReader(PATTERN.name()))); + }).pos(width / 2 + 14, height - vPos - 25).size(70, 20).build()); + boolean themeHasPatterns = PATTERNCOLLECTION.size() > 1; + patternButton.visible = themeHasPatterns; + if (themeHasPatterns) //Update the button name now that we have confirmed that there is more than one pattern in the shell + this.patternButton.setMessage(Component.Serializer.fromJson(new StringReader(PATTERN.name()))); + } + + @Override + public void renderBackdrop(@NotNull GuiGraphics guiGraphics) { + super.renderBackdrop(guiGraphics); + + PoseStack poseStack = guiGraphics.pose(); + + int hPos = (width - monitorWidth) / 2; + int vPos = (height - monitorHeight) / 2; + + poseStack.pushPose(); + + int b = height - vPos, r = width - hPos; + int l1 = hPos + monitorWidth / 4, l2 = hPos + monitorWidth / 2; + + guiGraphics.fill(l2, vPos, r, b, -1072689136); + + poseStack.mulPose(Axis.ZP.rotationDegrees(-90)); + poseStack.translate(-height, 0, 0); + guiGraphics.fillGradient(vPos, l1, b, l2, 0x00000000, -1072689136); + poseStack.popPose(); + } + + @Override + public void inMonitorRender(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { + renderShell(guiGraphics, width / 2 - 70, height / 2 - 5, 25F); + } + + @Override + public GenericMonitorSelectionList createSelectionList() { + int leftPos = width / 2; + int topPos = (height - monitorHeight) / 2; + GenericMonitorSelectionList selectionList = new GenericMonitorSelectionList<>(this.minecraft, 105, 80, leftPos, topPos + 15, topPos + monitorHeight - 30, 12); + selectionList.setRenderBackground(false); + + Collection values = ShellTheme.SHELL_THEME_REGISTRY.stream().toList(); + values = values.stream() + .sorted(Comparator.comparing(theme -> theme.getDisplayName().toString())) + .toList(); + + for (ShellTheme shellTheme : values) { + ResourceLocation shellThemeId = ShellTheme.getKey(shellTheme); + + SelectionListEntry selectionListEntry = new SelectionListEntry(shellTheme.getDisplayName(), (entry) -> { + CURRENTSHELLTHEME = shellThemeId; + + for (Object child : selectionList.children()) { + if (child instanceof SelectionListEntry current) { + current.setChecked(false); + } + } + PATTERNCOLLECTION = ShellPatterns.getPatternCollectionForTheme(CURRENTSHELLTHEME); + PATTERN = PATTERNCOLLECTION.get(0); + + boolean themeHasPatterns = PATTERNCOLLECTION.size() > 1; + + //Hide the pattern button if there is only one pattern available for the shell, else show it. (i.e. The default) + patternButton.visible = themeHasPatterns; + + if (themeHasPatterns) //Update the button name now that we have confirmed that there is more than one pattern in the shell + this.patternButton.setMessage(Component.Serializer.fromJson(new StringReader(PATTERN.name()))); + + entry.setChecked(true); + }, leftPos); + + if (CURRENTSHELLTHEME.toString().equals(shellThemeId.toString())) { + selectionListEntry.setChecked(true); + } + + selectionList.children().add(selectionListEntry); + } + + return selectionList; + } + + public void selectShell(ResourceLocation themeId) { + assert Minecraft.getInstance().player != null; + new C2SChangeShell(Minecraft.getInstance().player.level().dimension(), themeId, PATTERN).send(); + //Minecraft.getInstance().setScreen(null); + } + +} diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/screens/VortexSelectionScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/VortexSelectionScreen.java new file mode 100644 index 000000000..e336aafca --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/VortexSelectionScreen.java @@ -0,0 +1,115 @@ +package whocraft.tardis_refined.client.screen.screens; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Axis; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.core.Holder; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; +import whocraft.tardis_refined.client.renderer.vortex.VortexRenderer; +import whocraft.tardis_refined.client.screen.components.GenericMonitorSelectionList; +import whocraft.tardis_refined.client.screen.components.SelectionListEntry; +import whocraft.tardis_refined.client.screen.main.MonitorOS; +import whocraft.tardis_refined.common.VortexRegistry; +import whocraft.tardis_refined.common.network.messages.C2SChangeVortex; +import whocraft.tardis_refined.common.tardis.themes.ShellTheme; +import whocraft.tardis_refined.constants.ModMessages; + +import java.util.Collection; +import java.util.Comparator; +import java.util.List; + +public class VortexSelectionScreen extends MonitorOS { + + private final List vortexList; + + public VortexSelectionScreen(ResourceLocation currentVortex) { + super(Component.translatable(ModMessages.UI_MONITOR_VORTEX), null); + this.vortexList = VortexRegistry.VORTEX_REGISTRY.keySet().stream().toList(); + VortexSelectionScreen.currentVortex = currentVortex; + } + + @Override + protected void init() { + super.init(); + this.setEvents(() -> selectVortex(currentVortex), () -> { + //selectVortex(currentVortex); + if (PREVIOUS != null) + this.switchScreenToLeft(PREVIOUS); + }); + if (currentVortex == null) + currentVortex = this.vortexList.get(0); + int vPos = (height - monitorHeight) / 2; + addSubmitButton(width / 2 + 90, height - vPos - 25); + addCancelButton(width / 2 - 11, height - vPos - 25); + } + + public void selectVortex(ResourceLocation themeId) { + assert Minecraft.getInstance().player != null; + new C2SChangeVortex(Minecraft.getInstance().player.level().dimension(), themeId).send(); + //Minecraft.getInstance().setScreen(null); + } + + @Override + public void renderBackdrop(@NotNull GuiGraphics guiGraphics) { + super.renderBackdrop(guiGraphics); + + PoseStack poseStack = guiGraphics.pose(); + + int hPos = (width - monitorWidth) / 2; + int vPos = (height - monitorHeight) / 2; + + poseStack.pushPose(); + + int b = height - vPos, r = width - hPos; + int l1 = hPos + monitorWidth / 4, l2 = hPos + monitorWidth / 2; + + guiGraphics.fill(l2, vPos, r, b, -1072689136); + + poseStack.mulPose(Axis.ZP.rotationDegrees(-90)); + poseStack.translate(-height, 0, 0); + guiGraphics.fillGradient(vPos, l1, b, l2, 0x00000000, -1072689136); + poseStack.popPose(); + } + + @Override + public GenericMonitorSelectionList createSelectionList() { + int leftPos = width / 2; + int topPos = (height - monitorHeight) / 2; + GenericMonitorSelectionList selectionList = new GenericMonitorSelectionList<>(this.minecraft, 105, 80, leftPos, topPos + 15, topPos + monitorHeight - 30, 12); + + selectionList.setRenderBackground(false); + + Collection values = VortexRegistry.VORTEX_REGISTRY.stream().toList(); + values = values.stream() + .sorted(Comparator.comparing(theme -> theme.getDisplayName().toString())) + .toList(); + + for (VortexRegistry vort : values) { + ResourceLocation vortId = VortexRegistry.VORTEX_REGISTRY.getKey(vort); + + SelectionListEntry selectionListEntry = new SelectionListEntry(vort.getDisplayName(), (entry) -> { + currentVortex = vortId; + + for (Object child : selectionList.children()) { + if (child instanceof SelectionListEntry current) { + current.setChecked(false); + } + } + + entry.setChecked(true); + }, leftPos); + + + if (currentVortex.toString().equals(vortId.toString())) { + selectionListEntry.setChecked(true); + } + + selectionList.children().add(selectionListEntry); + } + + return selectionList; + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/waypoints/WaypointListScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/WaypointListScreen.java similarity index 65% rename from common/src/main/java/whocraft/tardis_refined/client/screen/waypoints/WaypointListScreen.java rename to common/src/main/java/whocraft/tardis_refined/client/screen/screens/WaypointListScreen.java index 3edb07402..ebd30429a 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/waypoints/WaypointListScreen.java +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/WaypointListScreen.java @@ -1,4 +1,4 @@ -package whocraft.tardis_refined.client.screen.waypoints; +package whocraft.tardis_refined.client.screen.screens; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; @@ -6,83 +6,67 @@ import net.minecraft.client.gui.components.Tooltip; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.client.screen.ScreenHelper; import whocraft.tardis_refined.client.screen.components.CommonTRWidgets; import whocraft.tardis_refined.client.screen.components.GenericMonitorSelectionList; import whocraft.tardis_refined.client.screen.components.SelectionListEntry; -import whocraft.tardis_refined.client.screen.selections.SelectionScreen; +import whocraft.tardis_refined.client.screen.main.MonitorOS; +import whocraft.tardis_refined.client.screen.waypoints.CoordInputType; import whocraft.tardis_refined.common.network.messages.waypoints.C2SOpenCoordinatesDisplayMessage; import whocraft.tardis_refined.common.network.messages.waypoints.C2SOpenEditCoordinatesDisplayMessage; import whocraft.tardis_refined.common.network.messages.waypoints.C2SRemoveWaypointEntry; import whocraft.tardis_refined.common.network.messages.waypoints.C2STravelToWaypoint; +import whocraft.tardis_refined.common.tardis.TardisDesktops; import whocraft.tardis_refined.common.tardis.TardisWaypoint; +import whocraft.tardis_refined.common.tardis.themes.DesktopTheme; import whocraft.tardis_refined.constants.ModMessages; import java.awt.*; -import java.util.ArrayList; import java.util.Collection; +import java.util.Comparator; -public class WaypointListScreen extends SelectionScreen { +public class WaypointListScreen extends MonitorOS { public static final ResourceLocation TRASH_LOCATION = new ResourceLocation(TardisRefined.MODID, "trash"); public static final ResourceLocation OKAY_TEXTURE = new ResourceLocation(TardisRefined.MODID, "okay"); public static final ResourceLocation EDIT_TEXTURE = new ResourceLocation(TardisRefined.MODID, "edit"); - public static ResourceLocation MONITOR_TEXTURE = new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor.png"); private final Component noWaypointsLabel = Component.translatable(ModMessages.UI_MONITOR_NO_WAYPOINTS); - protected int imageWidth = 256; - protected int imageHeight = 173; - private int leftPos, topPos; private SpriteIconButton loadButton; private SpriteIconButton editButton; private SpriteIconButton trashButton; - private Collection WAYPOINTS = new ArrayList<>(); + private final Collection WAYPOINTS; private TardisWaypoint waypoint = null; public WaypointListScreen(Collection waypoints) { - super(Component.translatable(ModMessages.UI_MONITOR_MAIN_TITLE)); + super(Component.translatable(ModMessages.UI_MONITOR_MAIN_TITLE), new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor/backdrop.png")); this.WAYPOINTS = waypoints; } - - @Override - public boolean isPauseScreen() { - return false; - } - - @Override protected void init() { - this.leftPos = (this.width - this.imageWidth) / 2; - this.topPos = (this.height - this.imageHeight) / 2; - - //Super method already creates the list, we don't need to create it a second time. super.init(); setEvents(() -> { - if (waypoint != null) { + if (waypoint != null) new C2STravelToWaypoint(waypoint.getId()).send(); - Minecraft.getInstance().setScreen(null); - } - Minecraft.getInstance().setScreen(null); - }, new SelectionScreenRun() { - @Override - public void onPress() { - if (waypoint != null) { - new C2SRemoveWaypointEntry(waypoint.getId()).send(); - } - } + }, () -> { + if (waypoint != null) + new C2SRemoveWaypointEntry(waypoint.getId()).send(); + this.switchScreenToLeft(PREVIOUS); + }); - SpriteIconButton newWaypointButton = this.addRenderableWidget(CommonTRWidgets.imageButton(20, Component.translatable("Submit"), (arg) -> { - new C2SOpenCoordinatesDisplayMessage(CoordInputType.WAYPOINT).send(); - }, true, BUTTON_LOCATION)); + SpriteIconButton newWaypointButton = this.addRenderableWidget(CommonTRWidgets.imageButton(20, Component.translatable("Submit"), (arg) -> new C2SOpenCoordinatesDisplayMessage(CoordInputType.WAYPOINT).send(), true, BUTTON_LOCATION)); newWaypointButton.setTooltip(Tooltip.create(Component.translatable(ModMessages.UI_MONITOR_WAYPOINT_CREATE))); newWaypointButton.setPosition(width / 2 + 85, (height) / 2 - 60); + int vPos = (height - monitorHeight) / 2; + addCancelButton(width / 2 - 105, height - vPos - 25); this.loadButton = this.addRenderableWidget(CommonTRWidgets.imageButton(20, Component.translatable("Submit"), (arg) -> { if (waypoint != null) { @@ -108,24 +92,24 @@ public void onPress() { this.editButton.active = false; - this.trashButton = this.addRenderableWidget(CommonTRWidgets.imageButton(20, Component.translatable("Submit"), (arg) -> { - new C2SRemoveWaypointEntry(waypoint.getId()).send(); - - }, true, TRASH_LOCATION)); + this.trashButton = this.addRenderableWidget(CommonTRWidgets.imageButton(20, Component.translatable("Submit"), (arg) -> new C2SRemoveWaypointEntry(waypoint.getId()).send(), true, TRASH_LOCATION)); this.trashButton.setPosition(width / 2 + 85, (height) / 2 - 20); this.trashButton.setTooltip(Tooltip.create(Component.translatable(ModMessages.UI_MONITOR_WAYPOINT_DELETE))); this.trashButton.active = false; } - @Override - public GenericMonitorSelectionList createSelectionList() { - int leftPos = this.width / 2 - 100; - GenericMonitorSelectionList selectionList = new GenericMonitorSelectionList<>(this.minecraft, 250, 80, leftPos - 70, this.topPos + 45, this.topPos + this.imageHeight - 45, 12); + public GenericMonitorSelectionList createSelectionList() { + int vPos = (height - monitorHeight) / 2; + int leftPos = this.width / 2 - 75; + GenericMonitorSelectionList selectionList = new GenericMonitorSelectionList<>(this.minecraft, 150, 80, leftPos, vPos + 15, vPos + monitorHeight - 30, 12); selectionList.setRenderBackground(false); - for (TardisWaypoint waypointEntry : WAYPOINTS) { + Collection values = WAYPOINTS; + values = values.stream().sorted(Comparator.comparing(TardisWaypoint::getName)).toList(); + + for (TardisWaypoint waypointEntry : values) { selectionList.children().add(new SelectionListEntry(Component.literal(waypointEntry.getLocation().getName()), entry -> { entry.setChecked(true); this.waypoint = waypointEntry; @@ -145,29 +129,13 @@ public GenericMonitorSelectionList createSelectionList() { return selectionList; } - - @Override - public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) { - // super.renderBackground(guiGraphics, i, j, f); - } - @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - + public void inMonitorRender(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { int textOffset = height / 2 - 60; int textScale = 40; - this.renderTransparentBackground(guiGraphics); - - guiGraphics.blit(MONITOR_TEXTURE, leftPos, topPos, 0, 0, imageWidth, imageHeight); - - ScreenHelper.renderWidthScaledText(Component.translatable(ModMessages.UI_MONITOR_WAYPOINTS).getString(), guiGraphics, Minecraft.getInstance().font, width / 2 - 96, textOffset, Color.LIGHT_GRAY.getRGB(), textScale * 2, 1F, false); - - if (WAYPOINTS.isEmpty()) { - ScreenHelper.renderWidthScaledText(noWaypointsLabel.getString(), guiGraphics, Minecraft.getInstance().font, width / 2 - 96, textOffset + 15, Color.LIGHT_GRAY.getRGB(), textScale * 2, 1F, false); - } - - super.render(guiGraphics, i, j, f); + if (WAYPOINTS.isEmpty()) + ScreenHelper.renderWidthScaledText(noWaypointsLabel.getString(), guiGraphics, Minecraft.getInstance().font, width / 2f - 96, textOffset + 15, Color.LIGHT_GRAY.getRGB(), textScale * 2, 1F, false); } } diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/waypoints/WaypointManageScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/WaypointManageScreen.java similarity index 70% rename from common/src/main/java/whocraft/tardis_refined/client/screen/waypoints/WaypointManageScreen.java rename to common/src/main/java/whocraft/tardis_refined/client/screen/screens/WaypointManageScreen.java index d40cb773a..d7cc44e23 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/waypoints/WaypointManageScreen.java +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/WaypointManageScreen.java @@ -1,17 +1,19 @@ -package whocraft.tardis_refined.client.screen.waypoints; +package whocraft.tardis_refined.client.screen.screens; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.SpriteIconButton; -import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.client.screen.ScreenHelper; import whocraft.tardis_refined.client.screen.components.CommonTRWidgets; +import whocraft.tardis_refined.client.screen.main.MonitorOS; +import whocraft.tardis_refined.client.screen.waypoints.CoordInputType; import whocraft.tardis_refined.common.network.messages.waypoints.C2SEditWaypoint; import whocraft.tardis_refined.common.network.messages.waypoints.C2SRequestWaypoints; import whocraft.tardis_refined.common.network.messages.waypoints.C2SUploadWaypoint; @@ -23,56 +25,48 @@ import java.awt.*; import java.util.List; -import static whocraft.tardis_refined.client.screen.selections.SelectionScreen.BUTTON_LOCATION; +public class WaypointManageScreen extends MonitorOS { -public class WaypointManageScreen extends Screen { - - public static ResourceLocation MONITOR_TEXTURE = new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor.png"); private final CoordInputType coordInputType; - protected int imageWidth = 256; - protected int imageHeight = 173; protected EditBox waypointName; - private int leftPos, topPos; private TardisWaypoint preExistingWaypoint = null; - private TardisNavLocation tardisNavLocation = TardisNavLocation.ORIGIN; + private final TardisNavLocation tardisNavLocation; private SpriteIconButton onSaveWaypoint; - - public WaypointManageScreen(List> worlds, CoordInputType coordInputType, TardisNavLocation tardisNavLocation) { - super(Component.translatable(coordInputType == CoordInputType.WAYPOINT ? ModMessages.UI_MONITOR_UPLOAD_WAYPOINTS : ModMessages.UI_MONITOR_UPLOAD_COORDS)); + public WaypointManageScreen(List> ignoredWorlds, CoordInputType coordInputType, TardisNavLocation tardisNavLocation) { + super(Component.translatable(coordInputType == CoordInputType.WAYPOINT ? ModMessages.UI_MONITOR_UPLOAD_WAYPOINTS : ModMessages.UI_MONITOR_UPLOAD_COORDS), new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor/backdrop.png")); this.coordInputType = coordInputType; this.tardisNavLocation = tardisNavLocation; tardisNavLocation.setName("Waypoint"); } public WaypointManageScreen(TardisWaypoint waypoint) { - super(Component.translatable("Edit waypoint")); + super(Component.translatable("Edit waypoint"), new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor/backdrop.png")); this.preExistingWaypoint = waypoint; this.tardisNavLocation = waypoint.getLocation(); this.coordInputType = CoordInputType.WAYPOINT; + + this.setEvents(() -> { + + }, () -> { + new C2SRequestWaypoints().send(); + }); + } @Override protected void init() { super.init(); - this.leftPos = (this.width - this.imageWidth) / 2; - this.topPos = (this.height - this.imageHeight) / 2; - - int yPosition = 30; // Move yPosition to the top of the screen - int xPosition = this.width / 2 + 15; - int widgetHeight = 20; - - int waypointNameWidth = this.width / 2 - 70; + int waypointNameWidth = monitorWidth / 2; int waypointNameHeight = this.height / 2; - + int yPosition = height / 2; + int xPosition = this.width / 2 - (waypointNameWidth / 2); yPosition += 30; - xPosition = this.width / 2 - (waypointNameWidth / 2); - - onSaveWaypoint = this.addRenderableWidget(CommonTRWidgets.imageButton(waypointNameWidth, Component.translatable(ModMessages.UI_MONITOR_WAYPOINT_SUBMIT), (arg) -> { + onSaveWaypoint = this.addRenderableWidget(CommonTRWidgets.imageButton(waypointNameWidth, Component.translatable(ModMessages.SUBMIT), (arg) -> { if (preExistingWaypoint != null) { tardisNavLocation.setName(this.waypointName.getValue()); @@ -86,8 +80,7 @@ protected void init() { }, false, BUTTON_LOCATION)); - - onSaveWaypoint.setPosition(xPosition, yPosition + 100); + onSaveWaypoint.setPosition(xPosition, yPosition); addWidget(onSaveWaypoint); if (coordInputType == CoordInputType.WAYPOINT) { @@ -107,28 +100,23 @@ protected void init() { }); // Waypoint Stuff this.addWidget(waypointName); + + int vPos = (height - monitorHeight) / 2; + addCancelButton(width / 2 - 105, height - vPos - 25); + } } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - this.renderTransparentBackground(guiGraphics); - super.render(guiGraphics, i, j, f); - guiGraphics.blit(MONITOR_TEXTURE, leftPos, topPos, 0, 0, imageWidth, imageHeight); + public void inMonitorRender(@NotNull GuiGraphics guiGraphics, int i, int j, float f) { - if (coordInputType == CoordInputType.WAYPOINT) { + if (coordInputType == CoordInputType.WAYPOINT) this.waypointName.render(guiGraphics, i, j, f); - } - - if (waypointName.getValue().isEmpty()) { - onSaveWaypoint.active = false; - } else { - onSaveWaypoint.active = true; - } + onSaveWaypoint.active = !waypointName.getValue().isEmpty(); - int headerHeight = height / 2 - imageHeight / 3; - int starterCordHeight = height / 2 - imageHeight / 3 + 7; + int headerHeight = height / 2 - monitorHeight / 3; + int starterCordHeight = height / 2 - monitorHeight / 3 + 7; int centerX = width / 2; String baseDirection = tardisNavLocation.getDirection().getName(); @@ -136,17 +124,14 @@ public void render(GuiGraphics guiGraphics, int i, int j, float f) { String dimensionName = MiscHelper.getCleanDimensionName(tardisNavLocation.getDimensionKey()); - ScreenHelper.renderWidthScaledText(Component.translatable(ModMessages.UI_WAYPOINT_NEW_WAYPOINT).getString(), guiGraphics, Minecraft.getInstance().font, centerX, headerHeight, Color.LIGHT_GRAY.getRGB(), 80, 1F, true); - if (preExistingWaypoint == null) { + if (preExistingWaypoint == null) ScreenHelper.renderWidthScaledText(Component.translatable(ModMessages.UI_WAYPOINT_TAKEN).getString(), guiGraphics, Minecraft.getInstance().font, centerX, headerHeight + 10, Color.LIGHT_GRAY.getRGB(), 80, 1F, true); - } ScreenHelper.renderWidthScaledText(tardisNavLocation.getPosition().toShortString(), guiGraphics, Minecraft.getInstance().font, centerX, starterCordHeight + 15, Color.white.getRGB(), 80, 1F, true); ScreenHelper.renderWidthScaledText(direction + ", " + dimensionName, guiGraphics, Minecraft.getInstance().font, centerX, starterCordHeight + 25, Color.white.getRGB(), 100, 1F, true); - } @Override @@ -159,14 +144,4 @@ public boolean charTyped(char c, int i) { return super.charTyped(c, i); } - @Override - public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) { - - } - - @Override - public boolean isPauseScreen() { - return false; - } - } diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/selections/SelectionScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/selections/SelectionScreen.java deleted file mode 100644 index 23aba83ee..000000000 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/selections/SelectionScreen.java +++ /dev/null @@ -1,101 +0,0 @@ -package whocraft.tardis_refined.client.screen.selections; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.components.ObjectSelectionList; -import net.minecraft.client.gui.components.SpriteIconButton; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.RandomSource; -import whocraft.tardis_refined.TardisRefined; -import whocraft.tardis_refined.client.screen.ScreenHelper; -import whocraft.tardis_refined.client.screen.components.CommonTRWidgets; -import whocraft.tardis_refined.constants.ModMessages; - -import java.awt.*; - -public class SelectionScreen extends Screen { - - public static final ResourceLocation BUTTON_LOCATION = new ResourceLocation(TardisRefined.MODID, "save"); - public static final ResourceLocation BCK_LOCATION = new ResourceLocation(TardisRefined.MODID, "back"); - private final Component title; - public int noiseX, noiseY, age; - public double noiseAlpha; - private SelectionScreenRun onSubmit; - private SelectionScreenRun onCancel; - private ObjectSelectionList list; - - - public SelectionScreen(Component title) { - super(Component.translatable(ModMessages.UI_SHELL_SELECTION)); - this.title = title; - } - - public void setEvents(SelectionScreenRun onSubmit, SelectionScreenRun onCancel) { - this.onSubmit = onSubmit; - this.onCancel = onCancel; - } - - @Override - protected void init() { - super.init(); - list = createSelectionList(); - this.addRenderableWidget(list); - - } - - - public void addSubmitButton(int x, int y) { - if (onSubmit != null) { - SpriteIconButton spriteiconbutton = this.addRenderableWidget(CommonTRWidgets.imageButton(20, Component.translatable("Submit"), (arg) -> { - this.onSubmit.onPress(); - }, true, BUTTON_LOCATION)); - spriteiconbutton.setPosition(x, y); - } - } - - public void addCancelButton(int x, int y) { - if (onCancel != null) { - SpriteIconButton spriteiconbutton = this.addRenderableWidget(CommonTRWidgets.imageButton(20, Component.translatable("Cancel"), (arg) -> { - this.onCancel.onPress(); - }, true, BCK_LOCATION)); - spriteiconbutton.setPosition(x, y); - } - - } - - public ObjectSelectionList createSelectionList() { - return null; - } - - public Component getSelectedDisplayName() { - return null; - } - - - @Override - public boolean isPauseScreen() { - return false; - } - - @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - super.render(guiGraphics, i, j, f); - ScreenHelper.renderWidthScaledText(title.getString(), guiGraphics, Minecraft.getInstance().font, width / 2, height / 2 - 100, Color.LIGHT_GRAY.getRGB(), 300, true); - } - - @Override - public void tick() { - RandomSource random = Minecraft.getInstance().level.random; - super.tick(); - this.age++; - this.noiseX = random.nextInt(736); - this.noiseY = random.nextInt(414); - if (this.age % 3 == 0) this.noiseAlpha = random.nextDouble(); - } - - public interface SelectionScreenRun { - void onPress(); - } -} diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/selections/ShellSelectionScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/selections/ShellSelectionScreen.java deleted file mode 100644 index a12dde41b..000000000 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/selections/ShellSelectionScreen.java +++ /dev/null @@ -1,268 +0,0 @@ -package whocraft.tardis_refined.client.screen.selections; - -import com.mojang.blaze3d.platform.Lighting; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.blaze3d.vertex.VertexSorting; -import com.mojang.brigadier.StringReader; -import com.mojang.math.Axis; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.components.Button; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Holder; -import net.minecraft.core.registries.Registries; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.Level; -import org.joml.Matrix4f; -import whocraft.tardis_refined.TardisRefined; -import whocraft.tardis_refined.client.TardisClientData; -import whocraft.tardis_refined.client.model.blockentity.shell.ShellModel; -import whocraft.tardis_refined.client.model.blockentity.shell.ShellModelCollection; -import whocraft.tardis_refined.client.overlays.VortexOverlay; -import whocraft.tardis_refined.client.screen.components.GenericMonitorSelectionList; -import whocraft.tardis_refined.client.screen.components.SelectionListEntry; -import whocraft.tardis_refined.common.blockentity.shell.GlobalShellBlockEntity; -import whocraft.tardis_refined.common.network.messages.C2SChangeShell; -import whocraft.tardis_refined.common.tardis.themes.ShellTheme; -import whocraft.tardis_refined.constants.ModMessages; -import whocraft.tardis_refined.patterns.ShellPattern; -import whocraft.tardis_refined.patterns.ShellPatterns; -import whocraft.tardis_refined.registry.TRBlockRegistry; - -import java.util.List; -import java.util.UUID; - -public class ShellSelectionScreen extends SelectionScreen { - - public static ResourceLocation MONITOR_TEXTURE = new ResourceLocation(TardisRefined.MODID, "textures/gui/shell.png"); - public static ResourceLocation NOISE = new ResourceLocation(TardisRefined.MODID, "textures/gui/noise.png"); - public static GlobalShellBlockEntity globalShellBlockEntity; - private final List themeList; - protected int imageWidth = 256; - protected int imageHeight = 173; - private ResourceLocation currentShellTheme; - private int leftPos, topPos; - private ShellPattern pattern; - private List patternCollection; - private Button patternButton; - - public ShellSelectionScreen(ResourceLocation currentShellTheme) { - super(Component.translatable(ModMessages.UI_SHELL_SELECTION)); - this.themeList = ShellTheme.SHELL_THEME_REGISTRY.keySet().stream().toList(); - generateDummyGlobalShell(); - this.currentShellTheme = currentShellTheme; - - } - - public static void generateDummyGlobalShell() { - globalShellBlockEntity = new GlobalShellBlockEntity(BlockPos.ZERO, TRBlockRegistry.GLOBAL_SHELL_BLOCK.get().defaultBlockState()); - assert Minecraft.getInstance().level != null; - globalShellBlockEntity.setLevel(Minecraft.getInstance().level); - ResourceKey generatedLevelKey = ResourceKey.create(Registries.DIMENSION, new ResourceLocation(TardisRefined.MODID, UUID.randomUUID().toString())); - globalShellBlockEntity.setTardisId(generatedLevelKey); - globalShellBlockEntity.setShellTheme(ShellTheme.POLICE_BOX.getId()); - globalShellBlockEntity.setPattern(ShellPatterns.DEFAULT); - } - - @Override - public void tick() { - super.tick(); - } - - @Override - protected void init() { - this.setEvents(() -> { - selectShell(this.currentShellTheme); - }, () -> { - Minecraft.getInstance().setScreen(null); - }); - if (currentShellTheme == null) { - this.currentShellTheme = this.themeList.get(0); - } - this.patternCollection = ShellPatterns.getPatternCollectionForTheme(this.currentShellTheme); - this.pattern = this.patternCollection.get(0); - - this.leftPos = (this.width - this.imageWidth) / 2; - this.topPos = (this.height - this.imageHeight) / 2; - - addSubmitButton(width / 2 + 90, (height) / 2 + 34); - addCancelButton(width / 2 - 11, (height) / 2 + 34); - - patternButton = addRenderableWidget(Button.builder(Component.literal(""), button -> { - pattern = ShellPatterns.next(this.patternCollection, this.pattern); - button.setMessage(Component.Serializer.fromJson(new StringReader(this.pattern.name()))); - }).pos(width / 2 + 14, (height) / 2 + 34).size(70, 20).build()); - - patternButton.visible = false; //Hide when initialised. We will only show it when there are more than 1 pattern for a shell (via its {@link PatternCollection} ) - - super.init(); - } - - public void selectShell(ResourceLocation themeId) { - new C2SChangeShell(Minecraft.getInstance().player.level().dimension(), themeId, pattern).send(); - Minecraft.getInstance().setScreen(null); - } - - - @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - PoseStack poseStack = guiGraphics.pose(); - Minecraft mc = Minecraft.getInstance(); - ClientLevel lvl = mc.level; - assert lvl != null; - RandomSource rand = lvl.random; - - boolean isCrashed = TardisClientData.getInstance(lvl.dimension()).isCrashing(); - - if (isCrashed) { - if (rand.nextInt(10) == 1) { - for (int i1 = 0; i1 < 3; i1++) { - poseStack.translate(rand.nextInt(3) / 100F, rand.nextInt(3) / 100.0f, rand.nextInt(3) / 100.0f); - } - } - if (rand.nextInt(20) == 1) { - poseStack.scale(1, 1 + rand.nextInt(5) / 100F, 1); - } - } - - - guiGraphics.enableScissor(leftPos + 3, topPos + 3, width - leftPos - 3, height - topPos - 3); - RenderSystem.backupProjectionMatrix(); - Matrix4f perspective = new Matrix4f(); - perspective.perspective((float) Math.toRadians(mc.options.fov().get()), (float) width / (float) height, 0.01f, 9999, false, perspective); - perspective.translate(0, 0, 11000f); - RenderSystem.setProjectionMatrix(perspective, VertexSorting.DISTANCE_TO_ORIGIN); - poseStack.pushPose(); - poseStack.mulPose(Axis.YP.rotationDegrees(20)); - VortexOverlay.VORTEX.time.speed = 0.3; - VortexOverlay.VORTEX.renderVortex(guiGraphics, 1, false); - RenderSystem.restoreProjectionMatrix(); - poseStack.popPose(); - guiGraphics.disableScissor(); - - guiGraphics.enableScissor(0, 0, width + 3, topPos + 3); - this.renderTransparentBackground(guiGraphics); - guiGraphics.disableScissor(); - guiGraphics.enableScissor(0, topPos + 3, leftPos + 3, height - topPos - 3); - this.renderTransparentBackground(guiGraphics); - guiGraphics.disableScissor(); - guiGraphics.enableScissor(width - leftPos - 3, topPos + 3, width, height - topPos - 3); - this.renderTransparentBackground(guiGraphics); - guiGraphics.disableScissor(); - guiGraphics.enableScissor(0, height - topPos - 3, width, height); - this.renderTransparentBackground(guiGraphics); - guiGraphics.disableScissor(); - - poseStack.pushPose(); - int c = -1072689136; - int l = leftPos + 3, t = topPos + 3, b = height - t, r = width - l; - int l1 = leftPos + imageWidth / 4, l2 = leftPos + imageWidth / 2; - - guiGraphics.fill(l, t, r, b, 0x40000000); - guiGraphics.fill(l2, t, r, b, -1072689136); - - poseStack.mulPose(Axis.ZP.rotationDegrees(-90)); - poseStack.translate(-height, 0, 0); - guiGraphics.fillGradient(t, l1, b, l2, 0x00000000, -1072689136); - poseStack.popPose(); - - /*Render Back drop*/ - //RenderSystem.setShader(GameRenderer::getPositionTexShader); //REDUNDANT - //RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - guiGraphics.blit(MONITOR_TEXTURE, leftPos, topPos, 0, 0, imageWidth, imageHeight); - - /*Model*/ - renderShell(guiGraphics, width / 2 - 75, height / 2 - 20, 25F); - //renderShell(guiGraphics, width / 2, height / 2, 25F); - - double alpha = (100.0D - this.age * 3.0D) / 100.0D; - if (isCrashed) { - RenderSystem.enableBlend(); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, (float) alpha); - guiGraphics.blit(NOISE, leftPos, topPos, this.noiseX, this.noiseY, imageWidth, imageHeight); - RenderSystem.disableBlend(); - } - super.render(guiGraphics, i, j, f); - } - - @Override - public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) { - // super.renderBackground(guiGraphics, i, j, f); - } - - private void renderShell(GuiGraphics guiGraphics, int x, int y, float scale) { - ShellModel model = ShellModelCollection.getInstance().getShellEntry(this.currentShellTheme).getShellModel(pattern); - model.setDoorPosition(false); - Lighting.setupForEntityInInventory(); - PoseStack pose = guiGraphics.pose(); - pose.pushPose(); - pose.translate((float) x, y, 100.0F); - pose.scale(-scale, scale, scale); - pose.mulPose(Axis.XP.rotationDegrees(-15F)); - pose.mulPose(Axis.YP.rotationDegrees((float) (System.currentTimeMillis() % 5400L) / 15L)); - - VertexConsumer vertexConsumer = guiGraphics.bufferSource().getBuffer(model.renderType(model.getShellTexture(pattern, false))); - model.renderShell(globalShellBlockEntity, false, false, pose, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F); - guiGraphics.flush(); - pose.popPose(); - Lighting.setupFor3DItems(); - } - - - @Override - public Component getSelectedDisplayName() { - ShellTheme theme = ShellTheme.SHELL_THEME_REGISTRY.get(this.currentShellTheme); - return theme.getDisplayName(); - } - - @Override - public GenericMonitorSelectionList createSelectionList() { - int leftPos = width / 2 - 5; - GenericMonitorSelectionList selectionList = new GenericMonitorSelectionList<>(this.minecraft, 100, 80, leftPos, this.topPos + 30, this.topPos + this.imageHeight - 60, 12); - - selectionList.setRenderBackground(false); - - for (Holder.Reference shellTheme : ShellTheme.SHELL_THEME_REGISTRY.holders().toList()) { - ShellTheme theme = shellTheme.value(); - ResourceLocation shellThemeId = shellTheme.key().location(); - - SelectionListEntry selectionListEntry = new SelectionListEntry(theme.getDisplayName(), (entry) -> { - this.currentShellTheme = shellThemeId; - - for (Object child : selectionList.children()) { - if (child instanceof SelectionListEntry current) { - current.setChecked(false); - } - } - this.patternCollection = ShellPatterns.getPatternCollectionForTheme(this.currentShellTheme); - this.pattern = this.patternCollection.get(0); - - boolean themeHasPatterns = this.patternCollection.size() > 1; - - //Hide the pattern button if there is only one pattern available for the shell, else show it. (i.e. The default) - patternButton.visible = themeHasPatterns; - - if (themeHasPatterns) //Update the button name now that we have confirmed that there is more than one pattern in the shell - this.patternButton.setMessage(Component.Serializer.fromJson(new StringReader(pattern.name()))); - - age = 0; - entry.setChecked(true); - }, leftPos); - - if (currentShellTheme.toString().equals(shellThemeId.toString())) { - selectionListEntry.setChecked(true); - } - - selectionList.children().add(selectionListEntry); - } - - return selectionList; - } -} diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/selections/VortexSelectionScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/selections/VortexSelectionScreen.java deleted file mode 100644 index 55ed7b2b9..000000000 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/selections/VortexSelectionScreen.java +++ /dev/null @@ -1,202 +0,0 @@ -package whocraft.tardis_refined.client.screen.selections; - -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexSorting; -import com.mojang.math.Axis; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.core.Holder; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.RandomSource; -import org.joml.Matrix4f; -import whocraft.tardis_refined.TardisRefined; -import whocraft.tardis_refined.client.TardisClientData; -import whocraft.tardis_refined.client.renderer.vortex.VortexRenderer; -import whocraft.tardis_refined.client.screen.components.GenericMonitorSelectionList; -import whocraft.tardis_refined.client.screen.components.SelectionListEntry; -import whocraft.tardis_refined.common.VortexRegistry; -import whocraft.tardis_refined.common.network.messages.C2SChangeVortex; -import whocraft.tardis_refined.constants.ModMessages; - -import java.util.List; - -public class VortexSelectionScreen extends SelectionScreen { - - public static ResourceLocation MONITOR_TEXTURE = new ResourceLocation(TardisRefined.MODID, "textures/gui/shell.png"); - public static ResourceLocation NOISE = new ResourceLocation(TardisRefined.MODID, "textures/gui/noise.png"); - private final List vortexList; - protected int imageWidth = 256; - protected int imageHeight = 173; - private ResourceLocation currentVortex; - private int leftPos, topPos; - - public static final VortexRenderer VORTEX = new VortexRenderer(VortexRegistry.CLOUDS.get()); - - - public VortexSelectionScreen(ResourceLocation currentShellTheme) { - super(Component.translatable(ModMessages.UI_MONITOR_VORTEX)); - this.vortexList = VortexRegistry.VORTEX_REGISTRY.keySet().stream().toList(); - this.currentVortex = currentShellTheme; - } - - - @Override - public void tick() { - super.tick(); - } - - @Override - protected void init() { - this.setEvents(() -> { - selectVortex(this.currentVortex); - }, () -> { - Minecraft.getInstance().setScreen(null); - }); - if (currentVortex == null) { - this.currentVortex = this.vortexList.get(0); - } - - this.leftPos = (this.width - this.imageWidth) / 2; - this.topPos = (this.height - this.imageHeight) / 2; - - addSubmitButton(width / 2 + 90, (height) / 2 + 34); - addCancelButton(width / 2 - 11, (height) / 2 + 34); - - super.init(); - } - - public void selectVortex(ResourceLocation themeId) { - new C2SChangeVortex(Minecraft.getInstance().player.level().dimension(), themeId).send(); - Minecraft.getInstance().setScreen(null); - } - - - @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - PoseStack poseStack = guiGraphics.pose(); - Minecraft mc = Minecraft.getInstance(); - ClientLevel lvl = mc.level; - assert lvl != null; - RandomSource rand = lvl.random; - - boolean isCrashed = TardisClientData.getInstance(lvl.dimension()).isCrashing(); - - if (isCrashed) { - if (rand.nextInt(10) == 1) { - for (int i1 = 0; i1 < 3; i1++) { - poseStack.translate(rand.nextInt(3) / 100F, rand.nextInt(3) / 100.0f, rand.nextInt(3) / 100.0f); - } - } - if (rand.nextInt(20) == 1) { - poseStack.scale(1, 1 + rand.nextInt(5) / 100F, 1); - } - } - - - guiGraphics.enableScissor(leftPos + 3, topPos + 3, width - leftPos - 3, height - topPos - 3); - RenderSystem.backupProjectionMatrix(); - Matrix4f perspective = new Matrix4f(); - perspective.perspective((float) Math.toRadians(mc.options.fov().get()), (float) width / (float) height, 0.01f, 9999, false, perspective); - perspective.translate(0, 0, 11000f); - RenderSystem.setProjectionMatrix(perspective, VertexSorting.DISTANCE_TO_ORIGIN); - poseStack.pushPose(); - poseStack.mulPose(Axis.YP.rotationDegrees(20)); - VORTEX.time.speed = 0.3; - VORTEX.vortexType = VortexRegistry.VORTEX_DEFERRED_REGISTRY.get(currentVortex); - VORTEX.renderVortex(guiGraphics, 1, false); - RenderSystem.restoreProjectionMatrix(); - poseStack.popPose(); - guiGraphics.disableScissor(); - - guiGraphics.enableScissor(0, 0, width + 3, topPos + 3); - this.renderTransparentBackground(guiGraphics); - guiGraphics.disableScissor(); - guiGraphics.enableScissor(0, topPos + 3, leftPos + 3, height - topPos - 3); - this.renderTransparentBackground(guiGraphics); - guiGraphics.disableScissor(); - guiGraphics.enableScissor(width - leftPos - 3, topPos + 3, width, height - topPos - 3); - this.renderTransparentBackground(guiGraphics); - guiGraphics.disableScissor(); - guiGraphics.enableScissor(0, height - topPos - 3, width, height); - this.renderTransparentBackground(guiGraphics); - guiGraphics.disableScissor(); - - poseStack.pushPose(); - int c = -1072689136; - int l = leftPos + 3, t = topPos + 3, b = height - t, r = width - l; - int l1 = leftPos + imageWidth / 4, l2 = leftPos + imageWidth / 2; - - guiGraphics.fill(l, t, r, b, 0x40000000); - guiGraphics.fill(l2, t, r, b, -1072689136); - - poseStack.mulPose(Axis.ZP.rotationDegrees(-90)); - poseStack.translate(-height, 0, 0); - guiGraphics.fillGradient(t, l1, b, l2, 0x00000000, -1072689136); - poseStack.popPose(); - - /*Render Back drop*/ - //RenderSystem.setShader(GameRenderer::getPositionTexShader); //REDUNDANT - //RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - guiGraphics.blit(MONITOR_TEXTURE, leftPos, topPos, 0, 0, imageWidth, imageHeight); - - - double alpha = (100.0D - this.age * 3.0D) / 100.0D; - if (isCrashed) { - RenderSystem.enableBlend(); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, (float) alpha); - guiGraphics.blit(NOISE, leftPos, topPos, this.noiseX, this.noiseY, imageWidth, imageHeight); - RenderSystem.disableBlend(); - } - super.render(guiGraphics, i, j, f); - } - - @Override - public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) { - // super.renderBackground(guiGraphics, i, j, f); - } - - - @Override - public Component getSelectedDisplayName() { - VortexRegistry theme = VortexRegistry.VORTEX_DEFERRED_REGISTRY.get(this.currentVortex); - return theme.getDisplayName(); - } - - @Override - public GenericMonitorSelectionList createSelectionList() { - int leftPos = width / 2 - 5; - GenericMonitorSelectionList selectionList = new GenericMonitorSelectionList<>(this.minecraft, 100, 80, leftPos, this.topPos + 30, this.topPos + this.imageHeight - 60, 12); - - selectionList.setRenderBackground(false); - - for (Holder.Reference shellTheme : VortexRegistry.VORTEX_REGISTRY.holders().toList()) { - VortexRegistry theme = shellTheme.value(); - ResourceLocation shellThemeId = shellTheme.key().location(); - - - SelectionListEntry selectionListEntry = new SelectionListEntry(theme.getDisplayName(), (entry) -> { - this.currentVortex = shellThemeId; - - for (Object child : selectionList.children()) { - if (child instanceof SelectionListEntry current) { - current.setChecked(false); - } - } - - age = 0; - entry.setChecked(true); - }, leftPos); - - if (currentVortex.toString().equals(shellThemeId.toString())) { - selectionListEntry.setChecked(true); - } - - selectionList.children().add(selectionListEntry); - } - - return selectionList; - } -} diff --git a/common/src/main/java/whocraft/tardis_refined/common/block/device/AstralManipulatorBlock.java b/common/src/main/java/whocraft/tardis_refined/common/block/device/AstralManipulatorBlock.java index 0a8f5584f..4d34e4d60 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/block/device/AstralManipulatorBlock.java +++ b/common/src/main/java/whocraft/tardis_refined/common/block/device/AstralManipulatorBlock.java @@ -2,6 +2,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; @@ -23,6 +24,7 @@ import org.jetbrains.annotations.NotNull; import whocraft.tardis_refined.common.blockentity.device.AstralManipulatorBlockEntity; import whocraft.tardis_refined.common.items.ScrewdriverItem; +import whocraft.tardis_refined.common.network.messages.screens.S2COpenCraftingScreen; import whocraft.tardis_refined.common.tardis.CorridorGenerator; @@ -55,34 +57,33 @@ public VoxelShape getShape(BlockState blockState, BlockGetter blockGetter, Block @Override public InteractionResult use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult) { + if (!(level instanceof ServerLevel serverLevel) || interactionHand != InteractionHand.MAIN_HAND) { + return super.use(blockState, level, blockPos, player, interactionHand, blockHitResult); + } - if (level instanceof ServerLevel serverLevel && interactionHand == InteractionHand.MAIN_HAND) { - - if (level.getBlockEntity(blockPos) instanceof AstralManipulatorBlockEntity astralManipulatorBlockEntity) { - ItemStack itemStack = player.getItemInHand(interactionHand); - - if (itemStack == ItemStack.EMPTY) { - astralManipulatorBlockEntity.clearDisplay(); - - return InteractionResult.sidedSuccess(false); - } else { - - if (itemStack.getItem() instanceof ScrewdriverItem) { - - astralManipulatorBlockEntity.onRightClick(itemStack, player); - } + if (!(level.getBlockEntity(blockPos) instanceof AstralManipulatorBlockEntity astralManipulatorBlockEntity)) { + return super.use(blockState, level, blockPos, player, interactionHand, blockHitResult); + } - CorridorGenerator.onAttemptToUse(serverLevel, itemStack, blockPos, player); - } + ItemStack itemStack = player.getItemInHand(interactionHand); + if (itemStack.isEmpty()) { + if(player instanceof ServerPlayer serverPlayer) { + new S2COpenCraftingScreen().send(serverPlayer); } + astralManipulatorBlockEntity.clearDisplay(); + return InteractionResult.sidedSuccess(false); + } - + if (itemStack.getItem() instanceof ScrewdriverItem) { + astralManipulatorBlockEntity.onRightClick(itemStack, player); } - return super.use(blockState, level, blockPos, player, interactionHand, blockHitResult); + CorridorGenerator.onAttemptToUse(serverLevel, itemStack, blockPos, player); + return InteractionResult.sidedSuccess(true); } + @Override public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { return new AstralManipulatorBlockEntity(blockPos, blockState); diff --git a/common/src/main/java/whocraft/tardis_refined/common/blockentity/shell/RootedShellBlockEntity.java b/common/src/main/java/whocraft/tardis_refined/common/blockentity/shell/RootedShellBlockEntity.java index d52136327..021debdef 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/blockentity/shell/RootedShellBlockEntity.java +++ b/common/src/main/java/whocraft/tardis_refined/common/blockentity/shell/RootedShellBlockEntity.java @@ -13,12 +13,16 @@ import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; import whocraft.tardis_refined.common.dimension.DimensionHandler; import whocraft.tardis_refined.common.tardis.TardisDesktops; +import whocraft.tardis_refined.common.tardis.TardisNavLocation; +import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager; import whocraft.tardis_refined.common.tardis.themes.DesktopTheme; import whocraft.tardis_refined.common.util.Platform; import whocraft.tardis_refined.registry.TRBlockEntityRegistry; import java.util.UUID; +import static whocraft.tardis_refined.common.block.shell.ShellBaseBlock.FACING; + public class RootedShellBlockEntity extends ShellBaseBlockEntity { public static boolean setUpOnNextTick = false; // used in fabric MinecraftServer:getAllLevels mixin private boolean runSetUpOnNextTick = false; @@ -74,6 +78,11 @@ private void setUpTardis(BlockState blockState, Level level, BlockPos blockPos) tardisLevelOperator.setupInitialCave(serverLevel, blockState, blockPos); tardisLevelOperator.getProgressionManager().addDiscoveredLevel(level.dimension()); } + TardisPilotingManager pilot = tardisLevelOperator.getPilotingManager(); + + pilot.setTargetLocation(new TardisNavLocation(blockPos, blockState.getValue(FACING), level.dimension())); + pilot.setCurrentLocation(new TardisNavLocation(blockPos, blockState.getValue(FACING), level.dimension())); + //After we setup the data and desktop, open the doors. tardisLevelOperator.setDoorClosed(false); serverLevel.playSound(null, blockPos, SoundEvents.SHEEP_SHEAR, SoundSource.BLOCKS, 1, 1); diff --git a/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPlayerInfo.java b/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPlayerInfo.java index 9ae896cbf..1625870cd 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPlayerInfo.java +++ b/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPlayerInfo.java @@ -5,8 +5,10 @@ import net.minecraft.core.Direction; import net.minecraft.core.Vec3i; import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.RelativeMovement; import net.minecraft.world.entity.player.Abilities; import net.minecraft.world.entity.player.Player; import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; diff --git a/common/src/main/java/whocraft/tardis_refined/common/crafting/astral_manipulator/ManipulatorRecipes.java b/common/src/main/java/whocraft/tardis_refined/common/crafting/astral_manipulator/ManipulatorRecipes.java index a3abda96b..96be72b02 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/crafting/astral_manipulator/ManipulatorRecipes.java +++ b/common/src/main/java/whocraft/tardis_refined/common/crafting/astral_manipulator/ManipulatorRecipes.java @@ -8,6 +8,9 @@ import net.minecraft.world.level.block.piston.PistonBaseBlock; import net.minecraft.world.level.block.state.properties.AttachFace; import net.minecraft.world.level.block.state.properties.SlabType; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.DirectionalBlock; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.registry.TRBlockRegistry; diff --git a/common/src/main/java/whocraft/tardis_refined/common/entity/ControlEntity.java b/common/src/main/java/whocraft/tardis_refined/common/entity/ControlEntity.java index 803abfe24..988da9485 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/entity/ControlEntity.java +++ b/common/src/main/java/whocraft/tardis_refined/common/entity/ControlEntity.java @@ -31,7 +31,6 @@ import whocraft.tardis_refined.common.blockentity.console.GlobalConsoleBlockEntity; import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; import whocraft.tardis_refined.common.capability.tardis.upgrades.UpgradeHandler; -import whocraft.tardis_refined.common.tardis.control.Control; import whocraft.tardis_refined.common.tardis.control.ControlSpecification; import whocraft.tardis_refined.common.tardis.control.ship.MonitorControl; import whocraft.tardis_refined.common.tardis.manager.FlightDanceManager; @@ -486,7 +485,7 @@ private boolean handleLeftClick(Player player, ServerLevel serverLevel) { return false; } - Control control = this.controlSpecification.control(); + whocraft.tardis_refined.common.tardis.control.Control control = this.controlSpecification.control(); boolean successfulUse = control.onLeftClick(cap, this.consoleTheme, this, player); ConfiguredSound playedSound = successfulUse ? control.getSuccessSound(cap, this.consoleTheme, true) : control.getFailSound(cap, this.consoleTheme, true); diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/TardisNetwork.java b/common/src/main/java/whocraft/tardis_refined/common/network/TardisNetwork.java index 411d26e6d..b2460553d 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/network/TardisNetwork.java +++ b/common/src/main/java/whocraft/tardis_refined/common/network/TardisNetwork.java @@ -7,6 +7,7 @@ import whocraft.tardis_refined.common.network.messages.player.S2CResetPostShellView; import whocraft.tardis_refined.common.network.messages.player.C2SExitTardisView; import whocraft.tardis_refined.common.network.messages.player.C2SBeginShellView; +import whocraft.tardis_refined.common.network.messages.screens.S2COpenCraftingScreen; import whocraft.tardis_refined.common.network.messages.sync.S2CSyncTardisPlayerView; import whocraft.tardis_refined.common.network.messages.screens.C2SRequestShellSelection; import whocraft.tardis_refined.common.network.messages.screens.S2COpenMonitor; @@ -20,7 +21,7 @@ public class TardisNetwork { public static final NetworkManager NETWORK = NetworkManager.create(new ResourceLocation(TardisRefined.MODID, "channel")); - public static MessageType START_VORTEX_SESSION, END_VORTEX_SESSION, TARDIS_EXIT, OPEN_SHELL_SELECT, SYNC_HUMS, OPEN_WAYPOINTS_DISPLAY, DEL_WAYPOINT, CLIENT_OPEN_COORDS_DISPLAY, SERVER_OPEN_COORDS_DISPLAY, UPGRADE_SCREEN_S2C, + public static MessageType OPEN_CRAFTING_SCREEN, START_VORTEX_SESSION, END_VORTEX_SESSION, TARDIS_EXIT, OPEN_SHELL_SELECT, SYNC_HUMS, OPEN_WAYPOINTS_DISPLAY, DEL_WAYPOINT, CLIENT_OPEN_COORDS_DISPLAY, SERVER_OPEN_COORDS_DISPLAY, UPGRADE_SCREEN_S2C, REQUEST_SHELL_C2S, CLIENT_OPEN_COORDS_SCREEN, SERVER_OPEN_COORDS_SCREEN, CLIENT_OPEN_EDIT_COORDS_SCREEN, SERVER_OPEN_EDIT_COORDS_SCREEN, UPLOAD_WAYPOINT, EDIT_WAYPOINT, SET_WAYPOINT, CHANGE_HUM, REQUEST_WAYPOINTS, SYNC_DESKTOPS, SYNC_CONSOLE_PATTERNS, SYNC_SHELL_PATTERNS, SYNC_LEVELS, INT_REACTION, OPEN_MONITOR, CHANGE_SHELL, CHANGE_DESKTOP, CANCEL_CHANGE_DESKTOP, UNLOCK_UPGRADE, EJECT_PLAYER, TARDIS_PLAYER_INFO, CHANGE_VORTEX; @@ -42,6 +43,7 @@ public static void init() { UPGRADE_SCREEN_S2C = NETWORK.registerS2C("upgrade_screen_s2c", S2CDisplayUpgradeScreen::new); TARDIS_PLAYER_INFO = NETWORK.registerS2C("tardis_player_info", S2CSyncTardisPlayerView::new); END_VORTEX_SESSION = NETWORK.registerS2C("end_vortex_session", S2CResetPostShellView::new); + OPEN_CRAFTING_SCREEN = NETWORK.registerS2C("open_crafting_screen", S2COpenCraftingScreen::new); // C2S Messages CHANGE_SHELL = NETWORK.registerC2S("change_shell", C2SChangeShell::new); diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/C2SChangeShell.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/C2SChangeShell.java index fe7c4ac2f..b3bcc60a6 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/C2SChangeShell.java +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/C2SChangeShell.java @@ -8,6 +8,7 @@ import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; import whocraft.tardis_refined.api.event.ShellChangeSources; +import whocraft.tardis_refined.client.TardisClientData; import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; import whocraft.tardis_refined.registry.TRUpgrades; import whocraft.tardis_refined.common.network.MessageC2S; @@ -19,6 +20,7 @@ import whocraft.tardis_refined.patterns.ShellPattern; import whocraft.tardis_refined.patterns.ShellPatterns; +import java.util.Objects; import java.util.Optional; public class C2SChangeShell extends MessageC2S { @@ -54,11 +56,15 @@ public void toBytes(FriendlyByteBuf buf) { @Override public void handle(MessageContext context) { - Optional level = Optional.ofNullable(context.getPlayer().getServer().levels.get(resourceKey)); + Optional level = Optional.ofNullable(Objects.requireNonNull(context.getPlayer().getServer()).levels.get(resourceKey)); level.flatMap(TardisLevelOperator::get).ifPresent(y -> { if (TRUpgrades.CHAMELEON_CIRCUIT_SYSTEM.get().isUnlocked(y.getUpgradeHandler()) && y.getExteriorManager().hasEnoughFuelForShellChange()) { y.setShellTheme(this.shellTheme, pattern.id(), ShellChangeSources.GENERIC_UPDATE); y.getPilotingManager().removeFuel(y.getExteriorManager().getFuelForShellChange()); + TardisClientData clientData = y.tardisClientData(); + clientData.setShellTheme(this.shellTheme); + clientData.setShellPattern(this.pattern.id()); + clientData.sync(); } else { PlayerUtil.sendMessage(context.getPlayer(), ModMessages.HARDWARE_OFFLINE, true); } diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/EndPlayerVortexSessionMessage.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/EndPlayerVortexSessionMessage.java deleted file mode 100644 index 32da544ed..000000000 --- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/EndPlayerVortexSessionMessage.java +++ /dev/null @@ -1,36 +0,0 @@ -package whocraft.tardis_refined.common.network.messages.player; - -import net.minecraft.network.FriendlyByteBuf; -import org.jetbrains.annotations.NotNull; -import whocraft.tardis_refined.client.TardisClientLogic; -import whocraft.tardis_refined.common.network.MessageContext; -import whocraft.tardis_refined.common.network.MessageS2C; -import whocraft.tardis_refined.common.network.MessageType; -import whocraft.tardis_refined.common.network.TardisNetwork; - -public class EndPlayerVortexSessionMessage extends MessageS2C { - - public EndPlayerVortexSessionMessage() { - } - - public EndPlayerVortexSessionMessage(FriendlyByteBuf friendlyByteBuf) { - } - - - @Override - public @NotNull MessageType getType() { - return TardisNetwork.END_VORTEX_SESSION; - } - - @Override - public void toBytes(FriendlyByteBuf buf) { - - } - - @Override - public void handle(MessageContext context) { - TardisClientLogic.handleClient(); - } - - -} diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/StartVortexSessionMessage.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/StartVortexSessionMessage.java deleted file mode 100644 index 7ead5585c..000000000 --- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/StartVortexSessionMessage.java +++ /dev/null @@ -1,44 +0,0 @@ -package whocraft.tardis_refined.common.network.messages.player; - -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; -import whocraft.tardis_refined.common.capability.player.TardisPlayerInfo; -import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; -import whocraft.tardis_refined.common.network.MessageC2S; -import whocraft.tardis_refined.common.network.MessageContext; -import whocraft.tardis_refined.common.network.MessageType; -import whocraft.tardis_refined.common.network.TardisNetwork; - -public class StartVortexSessionMessage extends MessageC2S { - - public StartVortexSessionMessage() { - } - - public StartVortexSessionMessage(FriendlyByteBuf buf) { - } - - - @Override - public @NotNull MessageType getType() { - return TardisNetwork.START_VORTEX_SESSION; - } - - @Override - public void toBytes(FriendlyByteBuf buf) { - - } - - @Override - public void handle(MessageContext context) { - ServerPlayer player = context.getPlayer(); - Level level = context.getPlayer().level(); - if (level instanceof ServerLevel serverLevel) { - TardisLevelOperator.get(serverLevel).ifPresent(tardisLevelOperator -> TardisPlayerInfo.get(context.getPlayer()).ifPresent(tardisInfo -> - tardisInfo.setupPlayerForInspection(player, tardisLevelOperator, tardisLevelOperator.getPilotingManager().isTakingOff() ? tardisLevelOperator.getPilotingManager().getCurrentLocation() : tardisLevelOperator.getPilotingManager().getTargetLocation(), !tardisLevelOperator.getPilotingManager().isTakingOff()) - )); - } - } -} diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/S2COpenCraftingScreen.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/S2COpenCraftingScreen.java new file mode 100644 index 000000000..37f055f11 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/S2COpenCraftingScreen.java @@ -0,0 +1,34 @@ +package whocraft.tardis_refined.common.network.messages.screens; + +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.server.level.ServerLevel; +import org.jetbrains.annotations.NotNull; +import whocraft.tardis_refined.client.ScreenHandler; +import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; +import whocraft.tardis_refined.common.network.*; + +public class S2COpenCraftingScreen extends MessageS2C { + + public S2COpenCraftingScreen() { + } + + public S2COpenCraftingScreen(FriendlyByteBuf friendlyByteBuf) { + } + + + @NotNull + @Override + public MessageType getType() { + return TardisNetwork.OPEN_CRAFTING_SCREEN; + } + + @Override + public void toBytes(FriendlyByteBuf buf) { + + } + + @Override + public void handle(MessageContext context) { + ScreenHandler.openCraftingScreen(); + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/S2COpenMonitor.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/S2COpenMonitor.java index 2be53341c..204229f69 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/S2COpenMonitor.java +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/S2COpenMonitor.java @@ -4,6 +4,7 @@ import net.fabricmc.api.Environment; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; import whocraft.tardis_refined.client.ScreenHandler; import whocraft.tardis_refined.common.capability.tardis.upgrades.UpgradeHandler; @@ -13,26 +14,32 @@ import whocraft.tardis_refined.common.network.TardisNetwork; import whocraft.tardis_refined.common.tardis.TardisNavLocation; +import java.util.Objects; + public class S2COpenMonitor extends MessageS2C { private final boolean desktopGenerating; - private TardisNavLocation currentLocation, targetLocation; - private CompoundTag upgradeHandlerNbt; + private final TardisNavLocation currentLocation; + private final TardisNavLocation targetLocation; + private final CompoundTag upgradeHandlerNbt; + private final ResourceLocation currentShellTheme; - public S2COpenMonitor(boolean desktopGenerating, TardisNavLocation currentLocation, TardisNavLocation targetLocation, UpgradeHandler upgradeHandler) { + public S2COpenMonitor(boolean desktopGenerating, TardisNavLocation currentLocation, TardisNavLocation targetLocation, UpgradeHandler upgradeHandler, ResourceLocation currentShellTheme) { this.desktopGenerating = desktopGenerating; this.currentLocation = currentLocation; this.targetLocation = targetLocation; this.upgradeHandlerNbt = upgradeHandler.saveData(new CompoundTag()); + this.currentShellTheme = currentShellTheme; } public S2COpenMonitor(FriendlyByteBuf friendlyByteBuf) { this.desktopGenerating = friendlyByteBuf.readBoolean(); - this.currentLocation = TardisNavLocation.deserialize(friendlyByteBuf.readNbt()); - this.targetLocation = TardisNavLocation.deserialize(friendlyByteBuf.readNbt()); + this.currentLocation = TardisNavLocation.deserialize(Objects.requireNonNull(friendlyByteBuf.readNbt())); + this.targetLocation = TardisNavLocation.deserialize(Objects.requireNonNull(friendlyByteBuf.readNbt())); this.upgradeHandlerNbt = friendlyByteBuf.readNbt(); + this.currentShellTheme = friendlyByteBuf.readResourceLocation(); } @NotNull @@ -47,6 +54,7 @@ public void toBytes(FriendlyByteBuf buf) { buf.writeNbt(currentLocation.serialise()); buf.writeNbt(targetLocation.serialise()); buf.writeNbt(upgradeHandlerNbt); + buf.writeResourceLocation(this.currentShellTheme); } @@ -58,7 +66,7 @@ public void handle(MessageContext context) { @Environment(EnvType.CLIENT) private void handleScreens() { // Open the monitor. - ScreenHandler.openMonitorScreen(desktopGenerating, upgradeHandlerNbt, currentLocation, targetLocation); + ScreenHandler.openMonitorScreen(desktopGenerating, upgradeHandlerNbt, currentLocation, targetLocation, currentShellTheme); } } diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/S2COpenShellSelection.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/S2COpenShellSelection.java index 99e9a7aab..f8d9e5ab2 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/S2COpenShellSelection.java +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/S2COpenShellSelection.java @@ -14,7 +14,7 @@ public class S2COpenShellSelection extends MessageS2C { - private ResourceLocation currentShell; + private final ResourceLocation currentShell; public S2COpenShellSelection(ResourceLocation currentShell) { this.currentShell = currentShell; diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/TardisWaypoint.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/TardisWaypoint.java index 5bb8b6575..6a3c49860 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/TardisWaypoint.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/TardisWaypoint.java @@ -33,6 +33,11 @@ public TardisNavLocation getLocation() { return location; } + public String getName() { + return location.getName(); + } + + public void setLocation(TardisNavLocation location) { this.location = location; } diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/CoordinateControl.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/CoordinateControl.java index 1a6a01d23..149997939 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/CoordinateControl.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/CoordinateControl.java @@ -7,13 +7,12 @@ import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; import whocraft.tardis_refined.common.entity.ControlEntity; import whocraft.tardis_refined.common.tardis.TardisNavLocation; -import whocraft.tardis_refined.common.tardis.control.Control; import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager; import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme; import whocraft.tardis_refined.common.util.PlayerUtil; -public class CoordinateControl extends Control { +public class CoordinateControl extends whocraft.tardis_refined.common.tardis.control.Control { private CoordinateButton button; diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/FastReturnControl.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/FastReturnControl.java index 7ebdbd89b..efa982b39 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/FastReturnControl.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/FastReturnControl.java @@ -5,12 +5,11 @@ import net.minecraft.world.entity.player.Player; import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; import whocraft.tardis_refined.common.entity.ControlEntity; -import whocraft.tardis_refined.common.tardis.control.Control; import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager; import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme; import whocraft.tardis_refined.patterns.sound.ConfiguredSound; -public class FastReturnControl extends Control { +public class FastReturnControl extends whocraft.tardis_refined.common.tardis.control.Control { public FastReturnControl(ResourceLocation id) { super(id); } diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/FuelToggleControl.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/FuelToggleControl.java index c9ab02d42..a2f4108a0 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/FuelToggleControl.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/FuelToggleControl.java @@ -5,14 +5,13 @@ import net.minecraft.world.entity.player.Player; import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; import whocraft.tardis_refined.common.entity.ControlEntity; -import whocraft.tardis_refined.common.tardis.control.Control; import whocraft.tardis_refined.common.tardis.control.ControlSpecification; import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager; import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme; import whocraft.tardis_refined.common.util.PlayerUtil; import whocraft.tardis_refined.constants.ModMessages; -public class FuelToggleControl extends Control { +public class FuelToggleControl extends whocraft.tardis_refined.common.tardis.control.Control { public FuelToggleControl(ResourceLocation id) { super(id); diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/GenericControl.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/GenericControl.java index 1f13772d4..984a6b365 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/GenericControl.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/GenericControl.java @@ -4,10 +4,9 @@ import net.minecraft.world.entity.player.Player; import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; import whocraft.tardis_refined.common.entity.ControlEntity; -import whocraft.tardis_refined.common.tardis.control.Control; import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme; -public class GenericControl extends Control { +public class GenericControl extends whocraft.tardis_refined.common.tardis.control.Control { public GenericControl(ResourceLocation id) { super(id); } diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/HandbrakeControl.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/HandbrakeControl.java index 6cd51d502..a343e8700 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/HandbrakeControl.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/HandbrakeControl.java @@ -5,12 +5,11 @@ import net.minecraft.world.entity.player.Player; import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; import whocraft.tardis_refined.common.entity.ControlEntity; -import whocraft.tardis_refined.common.tardis.control.Control; import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme; import whocraft.tardis_refined.common.util.PlayerUtil; import whocraft.tardis_refined.constants.ModMessages; -public class HandbrakeControl extends Control { +public class HandbrakeControl extends whocraft.tardis_refined.common.tardis.control.Control { public HandbrakeControl(ResourceLocation id) { super(id, true); } diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/IncrementControl.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/IncrementControl.java index 3e7017d8e..bace49163 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/IncrementControl.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/IncrementControl.java @@ -5,12 +5,11 @@ import net.minecraft.world.entity.player.Player; import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; import whocraft.tardis_refined.common.entity.ControlEntity; -import whocraft.tardis_refined.common.tardis.control.Control; import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager; import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme; import whocraft.tardis_refined.common.util.PlayerUtil; -public class IncrementControl extends Control { +public class IncrementControl extends whocraft.tardis_refined.common.tardis.control.Control { public IncrementControl(ResourceLocation id) { super(id); } diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/RandomControl.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/RandomControl.java index 043747c31..f6314a2fd 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/RandomControl.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/RandomControl.java @@ -6,12 +6,11 @@ import net.minecraft.world.entity.player.Player; import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; import whocraft.tardis_refined.common.entity.ControlEntity; -import whocraft.tardis_refined.common.tardis.control.Control; import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager; import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme; import whocraft.tardis_refined.common.util.PlayerUtil; -public class RandomControl extends Control { +public class RandomControl extends whocraft.tardis_refined.common.tardis.control.Control { public RandomControl(ResourceLocation id) { super(id); } diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/ReadoutControl.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/ReadoutControl.java index 080fde368..9dce3adfc 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/ReadoutControl.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/ReadoutControl.java @@ -6,12 +6,11 @@ import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; import whocraft.tardis_refined.common.entity.ControlEntity; import whocraft.tardis_refined.common.tardis.TardisNavLocation; -import whocraft.tardis_refined.common.tardis.control.Control; import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme; import whocraft.tardis_refined.common.util.PlayerUtil; import whocraft.tardis_refined.constants.ModMessages; -public class ReadoutControl extends Control { +public class ReadoutControl extends whocraft.tardis_refined.common.tardis.control.Control { public ReadoutControl(ResourceLocation id) { super(id); } diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/RotationControl.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/RotationControl.java index d1229b2ff..a99c71cf7 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/RotationControl.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/RotationControl.java @@ -6,12 +6,11 @@ import net.minecraft.world.entity.player.Player; import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; import whocraft.tardis_refined.common.entity.ControlEntity; -import whocraft.tardis_refined.common.tardis.control.Control; import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager; import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme; import whocraft.tardis_refined.common.util.PlayerUtil; -public class RotationControl extends Control { +public class RotationControl extends whocraft.tardis_refined.common.tardis.control.Control { public RotationControl(ResourceLocation id) { super(id); } diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/ship/MonitorControl.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/ship/MonitorControl.java index b63b2d99d..159023aa3 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/ship/MonitorControl.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/ship/MonitorControl.java @@ -24,6 +24,7 @@ public MonitorControl(ResourceLocation id) { super(id, true); } + public MonitorControl(ResourceLocation id, String langId) { super(id, langId, true); } @@ -56,7 +57,7 @@ public boolean onRightClick(TardisLevelOperator operator, ConsoleTheme theme, Co isSyncingKey = true; } if (!isSyncingKey) - new S2COpenMonitor(operator.getInteriorManager().isWaitingToGenerate(), operator.getPilotingManager().getCurrentLocation(), operator.getPilotingManager().getTargetLocation(), operator.getUpgradeHandler()).send((ServerPlayer) player); + new S2COpenMonitor(operator.getInteriorManager().isWaitingToGenerate(), operator.getPilotingManager().getCurrentLocation(), operator.getPilotingManager().getTargetLocation(), operator.getUpgradeHandler(), operator.getAestheticHandler().getShellTheme()).send((ServerPlayer) player); return true; } return false; diff --git a/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java b/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java index 2cbca550a..e13a55e92 100644 --- a/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java +++ b/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java @@ -14,7 +14,6 @@ public class ModMessages { public static final String UI_LIST_SELECTION = ui("monitor.list.selection"); public static final String UI_DESKTOP_CONFIGURATION = ui("monitor.desktop"); public static final String UI_SHELL_SELECTION = ui("shell_selection"); - public static final String UI_DESKTOP_SELECTION = ui("desktop_selection"); public static final String UI_MONITOR_GPS = ui("monitor.main.gps"); public static final String UI_MONITOR_VORTEX = ui("monitor.main.vortex"); public static final String UI_MONITOR_DESTINATION = ui("monitor.main.destination"); @@ -32,7 +31,6 @@ public class ModMessages { public static final String UI_MONITOR_WAYPOINT_LOAD = ui("monitor.waypoints.load"); public static final String UI_MONITOR_WAYPOINT_EDIT = ui("monitor.waypoints.edit"); public static final String UI_MONITOR_WAYPOINT_DELETE = ui("monitor.waypoints.delete"); - public static final String UI_MONITOR_WAYPOINT_SUBMIT = ui("monitor.waypoints.submit"); public static final String VANILLA_SELECT_WORLD = "selectWorld.search"; public static final String UI_WAYPOINT_NAME_PLACEHOLDER = "monitor.waypoints.name.placeholder"; public static final String UI_WAYPOINT_NEW_WAYPOINT = "monitor.waypoints.new_waypoint"; @@ -111,6 +109,7 @@ public class ModMessages { public static String CANNOT_START_NO_FUEL = message("cannot_start_no_fuel"); public static String CURRENT = message("current"); public static String DESTINATION = message("destination"); + public static String SUBMIT = message("submit"); public static String DIM_NOT_ALLOWED = message("dim_not_allowed"); public static String DIM_ALREADY_SAVED = message("dim_already_saved"); diff --git a/common/src/main/java/whocraft/tardis_refined/mixin/render/buffer/MixinMainTarget.java b/common/src/main/java/whocraft/tardis_refined/mixin/render/buffer/MixinMainTarget.java index 14006bc1a..8cddf2f6d 100644 --- a/common/src/main/java/whocraft/tardis_refined/mixin/render/buffer/MixinMainTarget.java +++ b/common/src/main/java/whocraft/tardis_refined/mixin/render/buffer/MixinMainTarget.java @@ -2,14 +2,20 @@ import com.mojang.blaze3d.pipeline.MainTarget; import com.mojang.blaze3d.pipeline.RenderTarget; +import com.mojang.blaze3d.platform.GlStateManager; import org.lwjgl.opengl.ARBFramebufferObject; import org.lwjgl.opengl.GL30; +import org.lwjgl.opengl.GL30C; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyArgs; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; import whocraft.tardis_refined.client.renderer.vortex.RenderTargetStencil; +import java.nio.IntBuffer; + +import static org.lwjgl.opengl.GL11.GL_DEPTH_COMPONENT; import static org.lwjgl.opengl.GL30.GL_DEPTH32F_STENCIL8; import static org.lwjgl.opengl.GL30.GL_FLOAT_32_UNSIGNED_INT_24_8_REV; @@ -22,26 +28,61 @@ public MixinMainTarget(boolean useDepth) { throw new RuntimeException(); } - @ModifyArgs(method = "allocateDepthAttachment(Lcom/mojang/blaze3d/pipeline/MainTarget$Dimension;)Z", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;_texImage2D(IIIIIIIILjava/nio/IntBuffer;)V", remap = false)) - private void tardisRefined$modifyTexImage2D(Args args) { - boolean isStencilEnabled = ((RenderTargetStencil) this).tr$getisStencilEnabled(); + @Redirect( + method = "allocateDepthAttachment(Lcom/mojang/blaze3d/pipeline/MainTarget$Dimension;)Z", + at = @At( + value = "INVOKE", + target = "Lcom/mojang/blaze3d/platform/GlStateManager;_texImage2D(IIIIIIIILjava/nio/IntBuffer;)V" + ) + ) + private void onTexImage2D( + int target, int level, int internalFormat, + int width, int height, int border, int format, int type, IntBuffer pixels + ) { + boolean isStencilBufferEnabled = ((RenderTargetStencil) this).tr$getisStencilEnabled(); - if (isStencilEnabled) { - args.set(2, GL_DEPTH32F_STENCIL8); - args.set(6, ARBFramebufferObject.GL_DEPTH_STENCIL); - args.set(7, GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + if (internalFormat == GL_DEPTH_COMPONENT && isStencilBufferEnabled) { + GlStateManager._texImage2D( + target, + level, + GL_DEPTH32F_STENCIL8, + width, + height, + border, + ARBFramebufferObject.GL_DEPTH_STENCIL, + GL_FLOAT_32_UNSIGNED_INT_24_8_REV, + pixels + ); + } + else { + GlStateManager._texImage2D( + target, level, internalFormat, width, height, + border, format, type, pixels + ); } } - @ModifyArgs(method = "createFrameBuffer(II)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;_glFramebufferTexture2D(IIIII)V", remap = false)) - private void tardisRefined$modifyFrameBufferTexture2d(Args args) { - boolean isStencilEnabled = ((RenderTargetStencil) this).tr$getisStencilEnabled(); + @Redirect( + method = "createFrameBuffer(II)V", + at = @At( + value = "INVOKE", + target = "Lcom/mojang/blaze3d/platform/GlStateManager;_glFramebufferTexture2D(IIIII)V" + ) + ) + private void redirectFrameBufferTexture2d( + int target, int attachment, int textureTarget, int texture, int level + ) { + boolean isStencilBufferEnabled = ((RenderTargetStencil) this).tr$getisStencilEnabled(); - if (isStencilEnabled) { - if ((int) args.get(1) == GL30.GL_DEPTH_ATTACHMENT) { - args.set(1, GL30.GL_DEPTH_STENCIL_ATTACHMENT); - } + if (attachment == GL30C.GL_DEPTH_ATTACHMENT && isStencilBufferEnabled) { + GlStateManager._glFramebufferTexture2D( + target, GL30.GL_DEPTH_STENCIL_ATTACHMENT, textureTarget, texture, level + ); + } + else { + GlStateManager._glFramebufferTexture2D(target, attachment, textureTarget, texture, level); } } + } \ No newline at end of file diff --git a/common/src/main/java/whocraft/tardis_refined/registry/TRBlockRegistry.java b/common/src/main/java/whocraft/tardis_refined/registry/TRBlockRegistry.java index cdd67ea0c..f3a33613c 100644 --- a/common/src/main/java/whocraft/tardis_refined/registry/TRBlockRegistry.java +++ b/common/src/main/java/whocraft/tardis_refined/registry/TRBlockRegistry.java @@ -52,7 +52,7 @@ public class TRBlockRegistry { /////////////////////////////////////////////////////////////////////////////// public static final RegistrySupplier CONSOLE_CONFIGURATION_BLOCK = register("console_configuration", () -> new ConsoleConfigurationBlock(BlockBehaviour.Properties.of().strength(3, 3).sound(SoundType.ANVIL).noOcclusion()), true, true); public static final RegistrySupplier ASTRAL_MANIPULATOR_BLOCK = register("astral_manipulator", () -> new AstralManipulatorBlock(BlockBehaviour.Properties.of().strength(3, 3).sound(SoundType.ANVIL).noOcclusion().lightLevel((x) -> { - return x.getValue(GlobalConsoleBlock.POWERED) ? 15 : 0; + return x.getValue(AstralManipulatorBlock.POWERED) ? 15 : 0; })), true, true); public static final RegistrySupplier GRAVITY_WELL = register("gravity_well", () -> new AntiGravityBlock(BlockBehaviour.Properties.of().strength(3, 3).sound(SoundType.ANVIL).noOcclusion()), true, true); public static final RegistrySupplier CORRIDOR_TELEPORTER = register("corridor_teleporter", () -> new CorridorTeleporterBlock(BlockBehaviour.Properties.of().strength(3, 3).sound(SoundType.ANVIL).noOcclusion()), true, true); @@ -74,7 +74,7 @@ public class TRBlockRegistry { public static final RegistrySupplier THE_EYE = register("the_eye", () -> new EyeBlock(BlockBehaviour.Properties.copy(Blocks.BEDROCK)), false, false); public static final RegistrySupplier ZEITON_LANTERN = register("zeiton_lantern", () -> new LanternBlock(BlockBehaviour.Properties.copy(Blocks.LANTERN).requiresCorrectToolForDrops()), true, true); public static final RegistrySupplier ARTRON_PILLAR_PORT = register("artron_pillar_port", () -> new Block(BlockBehaviour.Properties.copy(Blocks.BEDROCK)), false, false); - public static final RegistrySupplier ASTRAL_MAP = register("astral_map", () -> new Block(BlockBehaviour.Properties.copy(Blocks.STONE)), true, true); + // public static final RegistrySupplier ASTRAL_MAP = register("astral_map", () -> new Block(BlockBehaviour.Properties.copy(Blocks.STONE)), true, true); private static RegistrySupplier register(String id, Supplier blockSupplier, boolean addToTab, boolean registerItem) { RegistrySupplier registryObject = BLOCKS.register(id, blockSupplier); diff --git a/common/src/main/java/whocraft/tardis_refined/registry/TRPointOfInterestTypes.java b/common/src/main/java/whocraft/tardis_refined/registry/TRPointOfInterestTypes.java index 34cc4c26b..f7ee5a66b 100644 --- a/common/src/main/java/whocraft/tardis_refined/registry/TRPointOfInterestTypes.java +++ b/common/src/main/java/whocraft/tardis_refined/registry/TRPointOfInterestTypes.java @@ -14,12 +14,12 @@ public class TRPointOfInterestTypes { public static final ResourceKey CONSOLE_UNIT = ResourceKey.create(Registries.POINT_OF_INTEREST_TYPE, new ResourceLocation(TardisRefined.MODID, "console_unit")); - public static final ResourceKey ASTRAL_MAP = ResourceKey.create(Registries.POINT_OF_INTEREST_TYPE, new ResourceLocation(TardisRefined.MODID, "astral_map")); +// public static final ResourceKey ASTRAL_MAP = ResourceKey.create(Registries.POINT_OF_INTEREST_TYPE, new ResourceLocation(TardisRefined.MODID, "astral_map")); + - ; public static final DeferredRegistry POIS = DeferredRegistry.create(TardisRefined.MODID, Registries.POINT_OF_INTEREST_TYPE); public static final RegistrySupplier CONSOLE_UNIT_POI = POIS.register("console_unit", () -> registerPointOfInterest(6, 15, TRBlockRegistry.GLOBAL_CONSOLE_BLOCK.get())); - public static final RegistrySupplier ASTRAL_MAP_POI = POIS.register("astral_map", () -> registerPointOfInterest(1, 1, TRBlockRegistry.ASTRAL_MAP.get())); + // public static final RegistrySupplier ASTRAL_MAP_POI = POIS.register("astral_map", () -> registerPointOfInterest(1, 1, TRBlockRegistry.ASTRAL_MAP.get())); private static boolean hasBeenRegistered = false; public static void init() { @@ -40,7 +40,7 @@ private static PoiType registerPointOfInterest(int maxTickets, int validRange, B public static void registerBlockStates() { if (!hasBeenRegistered) { PoiTypes.registerBlockStates(BuiltInRegistries.POINT_OF_INTEREST_TYPE.getHolderOrThrow(CONSOLE_UNIT), CONSOLE_UNIT_POI.get().matchingStates()); - PoiTypes.registerBlockStates(BuiltInRegistries.POINT_OF_INTEREST_TYPE.getHolderOrThrow(ASTRAL_MAP), ASTRAL_MAP_POI.get().matchingStates()); + // PoiTypes.registerBlockStates(BuiltInRegistries.POINT_OF_INTEREST_TYPE.getHolderOrThrow(ASTRAL_MAP), ASTRAL_MAP_POI.get().matchingStates()); hasBeenRegistered = true; } } diff --git a/common/src/main/java/whocraft/tardis_refined/registry/TRVillagerProfession.java b/common/src/main/java/whocraft/tardis_refined/registry/TRVillagerProfession.java index d3b45ade4..89f4003f9 100644 --- a/common/src/main/java/whocraft/tardis_refined/registry/TRVillagerProfession.java +++ b/common/src/main/java/whocraft/tardis_refined/registry/TRVillagerProfession.java @@ -20,7 +20,7 @@ public class TRVillagerProfession { TRPointOfInterestTypes.CONSOLE_UNIT, TRSoundRegistry.DESTINATION_DING )); - public static final RegistrySupplier ASTRONOMER = registerVillagerProfession("astronomer", () -> createVillagerProfession( + /* public static final RegistrySupplier ASTRONOMER = registerVillagerProfession("astronomer", () -> createVillagerProfession( "astronomer", TRPointOfInterestTypes.ASTRAL_MAP, new Supplier() { @@ -29,7 +29,7 @@ public SoundEvent get() { return SoundEvents.BOOK_PAGE_TURN; } } - )); + ));*/ public static RegistrySupplier registerVillagerProfession(String name, Supplier villagerProfessionSupplier) { return PROFESSIONS.register(name, villagerProfessionSupplier); diff --git a/common/src/main/resources/assets/tardis_refined/textures/gui/desktop.png b/common/src/main/resources/assets/tardis_refined/textures/gui/desktop.png deleted file mode 100644 index a0da76a33..000000000 Binary files a/common/src/main/resources/assets/tardis_refined/textures/gui/desktop.png and /dev/null differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/gui/desktop_overlay.png b/common/src/main/resources/assets/tardis_refined/textures/gui/desktop_overlay.png deleted file mode 100644 index 502767c0a..000000000 Binary files a/common/src/main/resources/assets/tardis_refined/textures/gui/desktop_overlay.png and /dev/null differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/gui/external_view.png b/common/src/main/resources/assets/tardis_refined/textures/gui/external_view.png deleted file mode 100644 index 9aebe747b..000000000 Binary files a/common/src/main/resources/assets/tardis_refined/textures/gui/external_view.png and /dev/null differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/gui/gallifreyan_symbols.png b/common/src/main/resources/assets/tardis_refined/textures/gui/gallifreyan_symbols.png deleted file mode 100644 index 2c035d05f..000000000 Binary files a/common/src/main/resources/assets/tardis_refined/textures/gui/gallifreyan_symbols.png and /dev/null differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/gui/gui_black.png b/common/src/main/resources/assets/tardis_refined/textures/gui/gui_black.png deleted file mode 100644 index d8b37648e..000000000 Binary files a/common/src/main/resources/assets/tardis_refined/textures/gui/gui_black.png and /dev/null differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/gui/monitor.png b/common/src/main/resources/assets/tardis_refined/textures/gui/monitor.png deleted file mode 100644 index e5831b06a..000000000 Binary files a/common/src/main/resources/assets/tardis_refined/textures/gui/monitor.png and /dev/null differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/gui/monitor/backdrop.png b/common/src/main/resources/assets/tardis_refined/textures/gui/monitor/backdrop.png new file mode 100644 index 000000000..637fa24fa Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/gui/monitor/backdrop.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/gui/monitor/frame_brass.png b/common/src/main/resources/assets/tardis_refined/textures/gui/monitor/frame_brass.png new file mode 100644 index 000000000..952645b3b Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/gui/monitor/frame_brass.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/gui/monitor/gallifreyan_symbols.png b/common/src/main/resources/assets/tardis_refined/textures/gui/monitor/gallifreyan_symbols.png new file mode 100644 index 000000000..293235b0d Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/gui/monitor/gallifreyan_symbols.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/gui/noise.png b/common/src/main/resources/assets/tardis_refined/textures/gui/monitor/noise.png similarity index 100% rename from common/src/main/resources/assets/tardis_refined/textures/gui/noise.png rename to common/src/main/resources/assets/tardis_refined/textures/gui/monitor/noise.png diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/ItemModelProvider.java b/forge/src/main/java/whocraft/tardis_refined/common/data/ItemModelProvider.java index 727e0958b..fa975ecf0 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/ItemModelProvider.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/ItemModelProvider.java @@ -31,7 +31,7 @@ protected void registerModels() { blockItem(TRBlockRegistry.ZEITON_ORE.getId()); blockItem(TRBlockRegistry.ZEITON_ORE_DEEPSLATE.getId()); blockItem(TRBlockRegistry.ZEITON_BLOCK.getId()); - blockItem(TRBlockRegistry.ASTRAL_MAP.getId()); + //blockItem(TRBlockRegistry.ASTRAL_MAP.getId()); ResourceLocation leavesTexture = new ResourceLocation("tardis_refined:block/ars_leaves"); diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java b/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java index bedb618f5..b6527a18f 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java @@ -51,7 +51,7 @@ protected void addTranslations() { add(VortexRegistry.LESBIAN_FLAG.get().getTranslationKey(), "Lesbian Flag"); add(VortexRegistry.NON_BINARY_FLAG.get().getTranslationKey(), "Non-Binary Flag"); add(VortexRegistry.AGENDER_FLAG.get().getTranslationKey(), "Agender Flag"); - add(VortexRegistry.GAY_FLAG.get().getTranslationKey(), "Agender Flag"); + add(VortexRegistry.GAY_FLAG.get().getTranslationKey(), "Gay Flag"); /*Sounds*/ @@ -185,6 +185,7 @@ protected void addTranslations() { add(ModMessages.DOOR_LOCKED, "Door locked"); add(ModMessages.DOOR_UNLOCKED, "Door unlocked"); add(ModMessages.RECOVERY_PROGRESS, "Recovery Progress: %s"); + add(ModMessages.SUBMIT, "Submit"); /*Command*/ @@ -223,18 +224,15 @@ protected void addTranslations() { add(ModMessages.UI_MONITOR_VORTEX, "VORTEX"); add(ModMessages.UI_MONITOR_DESTINATION, "Destination"); add(ModMessages.UI_LIST_SELECTION, "Currently selected: &s"); - add(ModMessages.UI_EXTERNAL_SHELL, "EXTERNAL SHELL CONFIGURATION"); - add(ModMessages.UI_SHELL_SELECTION, "EXTERNAL SHELL CONFIGURATION"); + add(ModMessages.UI_EXTERNAL_SHELL, "SHELL CONFIGURATION"); add(ModMessages.UI_MONITOR_SHELL_VIEW, "SHELL VIEW"); - add(ModMessages.UI_DESKTOP_SELECTION, "DESKTOP CONFIGURATION"); - add(ModMessages.UI_DESKTOP_CONFIGURATION, "DESKTOP CONFIGURATION"); + add(ModMessages.UI_DESKTOP_CONFIGURATION, "DESKTOP"); add(ModMessages.UI_DESKTOP_CANCEL_TITLE, "OPERATION IN PROGRESS"); add(ModMessages.UI_DESKTOP_CANCEL_DESCRIPTION, "Systems disabled as a Desktop reconfiguration has been scheduled."); add(ModMessages.UI_DESKTOP_CANCEL_DESKTOP, "Would you like to cancel the upcoming reconfiguration?"); add(ModMessages.UI_DESKTOP_CANCEL, "Cancel Desktop Reconfiguration"); add(ModMessages.UI_MONITOR_NO_WAYPOINTS, "No Waypoints Saved!"); add(ModMessages.UI_MONITOR_WAYPOINT_UPLOAD, "Upload"); - add(ModMessages.UI_MONITOR_WAYPOINT_SUBMIT, "Submit"); add(ModMessages.UI_MONITOR_ISSUES, "Issues:"); add(ModMessages.UI_MONITOR_WAYPOINT_ISSUE_NAME, "Invalid waypoint name"); add(ModMessages.UI_MONITOR_WAYPOINT_ISSUE_X, "Invalid X value"); diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/TRBlockModelProvider.java b/forge/src/main/java/whocraft/tardis_refined/common/data/TRBlockModelProvider.java index f7616115b..7f80571fe 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/TRBlockModelProvider.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/TRBlockModelProvider.java @@ -114,7 +114,7 @@ protected void registerStatesAndModels() { customLocation(TRBlockRegistry.AIR_LOCK_GENERATION_BLOCK.get()); customLocation(TRBlockRegistry.FOOLS_STONE.get()); simpleBlock(TRBlockRegistry.ARTRON_PILLAR_PORT.get()); - simpleBlock(TRBlockRegistry.ASTRAL_MAP.get()); + // simpleBlock(TRBlockRegistry.ASTRAL_MAP.get()); customLocation(TRBlockRegistry.ASTRAL_MANIPULATOR_BLOCK.get(), new ResourceLocation(TardisRefined.MODID, "block/astral_manipulator")); customLocation(TRBlockRegistry.CORRIDOR_TELEPORTER.get(), new ResourceLocation(TardisRefined.MODID, "block/corridor_teleporter")); diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/TRPoiTypeTagsProvider.java b/forge/src/main/java/whocraft/tardis_refined/common/data/TRPoiTypeTagsProvider.java index 613fb2aca..3611ef522 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/TRPoiTypeTagsProvider.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/TRPoiTypeTagsProvider.java @@ -21,7 +21,7 @@ public TRPoiTypeTagsProvider(PackOutput arg, CompletableFuture