diff --git a/changelog.md b/changelog.md index d02e71038..2ab5bdd5d 100644 --- a/changelog.md +++ b/changelog.md @@ -14,4 +14,7 @@ ## Gameplay changes - Standing in a Crashed smoke of a crashed TARDIS will cause 0.5 damage to the player for the duration their standing in it - Recovery Progress of crashed TARDIS now displayed on controls until repair is complete -- Recovery Progress of crashed TARDIS is now displayed on Key tooltip \ No newline at end of file +- Recovery Progress of crashed TARDIS is now displayed on Key tooltip +- You can now view your TARDIS exterior via the Monitor +- Holographic exteriors on consoles now spin according to throttle +- Improved UI for Gravity Shaft \ No newline at end of file diff --git a/common/src/main/java/whocraft/tardis_refined/client/GravityOverlay.java b/common/src/main/java/whocraft/tardis_refined/client/GravityOverlay.java deleted file mode 100644 index 8f013880a..000000000 --- a/common/src/main/java/whocraft/tardis_refined/client/GravityOverlay.java +++ /dev/null @@ -1,54 +0,0 @@ -package whocraft.tardis_refined.client; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.Tesselator; -import com.mojang.math.Transformation; -import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.client.player.LocalPlayer; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; -import net.minecraft.world.entity.player.Player; -import whocraft.tardis_refined.common.GravityUtil; -import whocraft.tardis_refined.constants.ModMessages; - -public class GravityOverlay { - - private static boolean isInShaft = false; - - private static void checkOverlay(Player player){ - isInShaft = GravityUtil.isInGravityShaft(player); - } - - public static void renderOverlay(PoseStack poseStack) { - Minecraft mc = Minecraft.getInstance(); - Font fontRenderer = mc.font; - LocalPlayer player = mc.player; - - if(player.tickCount % 100 == 0){ - checkOverlay(player); - } - - if (isInShaft && !mc.getDebugOverlay().showDebugScreen()) { - poseStack.pushPose(); - poseStack.scale(1.2f, 1.2f, 1.2f); - - - int x = 5; - int y = 5; - - MutableComponent ascendKey = Component.translatable(mc.options.keyJump.getDefaultKey().getName()); - MutableComponent descendKey = Component.translatable(mc.options.keyShift.getDefaultKey().getName()); - - MultiBufferSource.BufferSource renderImpl = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); - fontRenderer.drawInBatch(Component.translatable(ModMessages.ASCEND_KEY, ascendKey).getString(), x, y, ChatFormatting.WHITE.getColor(), true, Transformation.identity().getMatrix(), renderImpl, Font.DisplayMode.NORMAL, 0, 15728880); - fontRenderer.drawInBatch(Component.translatable(Component.translatable(ModMessages.DESCEND_KEY, descendKey).getString()), x, y + fontRenderer.lineHeight, ChatFormatting.WHITE.getColor(), true, Transformation.identity().getMatrix(), renderImpl, Font.DisplayMode.NORMAL, 0, 15728880); - renderImpl.endBatch(); - - poseStack.popPose(); - } - } - -} diff --git a/common/src/main/java/whocraft/tardis_refined/client/TRKeybinds.java b/common/src/main/java/whocraft/tardis_refined/client/TRKeybinds.java new file mode 100644 index 000000000..be81402b6 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/client/TRKeybinds.java @@ -0,0 +1,12 @@ +package whocraft.tardis_refined.client; + +import net.minecraft.client.KeyMapping; +import org.lwjgl.glfw.GLFW; +import whocraft.tardis_refined.TardisRefined; + +public class TRKeybinds { + + public static KeyMapping EXIT_EXTERIOR_VIEW = new KeyMapping("exit_exterior_view", GLFW.GLFW_KEY_TAB, TardisRefined.NAME); + + +} 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 new file mode 100644 index 000000000..b8edc5734 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/client/overlays/ExteriorViewOverlay.java @@ -0,0 +1,66 @@ +package whocraft.tardis_refined.client.overlays; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.math.Transformation; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.resources.ResourceLocation; +import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.client.TRKeybinds; +import whocraft.tardis_refined.common.capability.player.TardisPlayerInfo; +import whocraft.tardis_refined.constants.ModMessages; + +public class ExteriorViewOverlay { + + public static ResourceLocation IMAGE = new ResourceLocation(TardisRefined.MODID, "textures/gui/external_view.png"); + + + public static void renderOverlay(GuiGraphics guiGraphics) { + Minecraft mc = Minecraft.getInstance(); + + TardisPlayerInfo.get(mc.player).ifPresent(tardisPlayerInfo -> { + PoseStack poseStack = guiGraphics.pose(); + poseStack.pushPose(); + + if(!tardisPlayerInfo.isViewingTardis()) return; + if(mc.getDebugOverlay().showDebugScreen()) return; + + Font fontRenderer = mc.font; + int x = 10; + int y = 10; + + // Create the message with a keybind + MutableComponent ascendKey = Component.translatable(TRKeybinds.EXIT_EXTERIOR_VIEW.getDefaultKey().getName()); + MutableComponent message = Component.translatable(ModMessages.EXIT_EXTERNAL_VIEW, ascendKey) + .withStyle(ChatFormatting.BOLD, ChatFormatting.AQUA); + + // Render a semi-transparent background for better text readability + guiGraphics.fill(x - 5, y - 5, x + fontRenderer.width(message.getString()) + 5, y + 15, 0x88000000); + + // Render the text with a shadow + MultiBufferSource.BufferSource renderImpl = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); + fontRenderer.drawInBatch( + message.getString(), + x, + y, + ChatFormatting.WHITE.getColor(), + false, + Transformation.identity().getMatrix(), + renderImpl, + Font.DisplayMode.NORMAL, + 0, + 15728880 + ); + renderImpl.endBatch(); + + // Pop pose to reset transformations + poseStack.popPose(); + }); + } +} \ No newline at end of file diff --git a/common/src/main/java/whocraft/tardis_refined/client/overlays/GravityOverlay.java b/common/src/main/java/whocraft/tardis_refined/client/overlays/GravityOverlay.java new file mode 100644 index 000000000..9b9407af1 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/client/overlays/GravityOverlay.java @@ -0,0 +1,100 @@ +package whocraft.tardis_refined.client.overlays; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.math.Transformation; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.entity.player.Player; +import whocraft.tardis_refined.common.GravityUtil; +import whocraft.tardis_refined.constants.ModMessages; + +public class GravityOverlay { + + private static boolean isInShaft = false; + + private static void checkOverlay(Player player){ + isInShaft = GravityUtil.isInGravityShaft(player); + } + + public static void renderOverlay(GuiGraphics guiGraphics) { + Minecraft mc = Minecraft.getInstance(); + Font fontRenderer = mc.font; + LocalPlayer player = mc.player; + PoseStack poseStack = guiGraphics.pose(); + + // Perform overlay checks periodically + if (player.tickCount % 100 == 0) { + checkOverlay(player); + } + + if (isInShaft && !mc.getDebugOverlay().showDebugScreen()) { + poseStack.pushPose(); + poseStack.scale(1.2f, 1.2f, 1.2f); + + // Padding for better positioning + int padding = 15; // Amount of padding from the screen edges + int x = padding; + int y = padding; + + MutableComponent ascendKey = Component.translatable(mc.options.keyJump.getDefaultKey().getName()); + MutableComponent descendKey = Component.translatable(mc.options.keyShift.getDefaultKey().getName()); + + // Get the translated strings for both keys + String ascendKeyText = Component.translatable(ModMessages.ASCEND_KEY, ascendKey).getString(); + String descendKeyText = Component.translatable(ModMessages.DESCEND_KEY, descendKey).getString(); + + // Calculate the longest key text width + int maxWidth = Math.max(fontRenderer.width(ascendKeyText), fontRenderer.width(descendKeyText)); + + MultiBufferSource.BufferSource renderImpl = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); + + // Render both key texts + fontRenderer.drawInBatch( + ascendKeyText, + x, + y, + ChatFormatting.WHITE.getColor(), + true, + Transformation.identity().getMatrix(), + renderImpl, + Font.DisplayMode.NORMAL, + 0, + 15728880 + ); + + fontRenderer.drawInBatch( + descendKeyText, + x, + y + fontRenderer.lineHeight, + ChatFormatting.WHITE.getColor(), + true, + Transformation.identity().getMatrix(), + renderImpl, + Font.DisplayMode.NORMAL, + 0, + 15728880 + ); + + renderImpl.endBatch(); + + guiGraphics.fill( + x - 5, + y - 5, + x + maxWidth, + y + fontRenderer.lineHeight * 2, + 0x88000000 + ); + + poseStack.popPose(); + } + } + + +} 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 78c4b9595..c56702ebf 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 @@ -2,19 +2,13 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Axis; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.FormattedCharSequence; import net.minecraft.world.phys.Vec3; -import org.joml.Matrix4f; import whocraft.tardis_refined.client.TardisClientData; import whocraft.tardis_refined.client.model.blockentity.console.ConsoleModelCollection; import whocraft.tardis_refined.client.model.blockentity.console.ConsoleUnit; @@ -23,7 +17,6 @@ import whocraft.tardis_refined.common.block.console.GlobalConsoleBlock; import whocraft.tardis_refined.common.blockentity.console.GlobalConsoleBlockEntity; import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme; -import whocraft.tardis_refined.common.tardis.themes.ShellTheme; import whocraft.tardis_refined.patterns.ShellPattern; import whocraft.tardis_refined.patterns.ShellPatterns; @@ -74,6 +67,8 @@ public void render(GlobalConsoleBlockEntity blockEntity, float partialTick, Pose private void renderHoloShell(Vec3 offset, int rotation, GlobalConsoleBlockEntity blockEntity, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, Vec3 color) { if (blockEntity.getLevel().random.nextInt(20) != 0) { poseStack.pushPose(); + + // Fetch shell data TardisClientData reactions = TardisClientData.getInstance(blockEntity.getLevel().dimension()); ResourceLocation shellTheme = reactions.getShellTheme(); ResourceLocation shellPattern = reactions.getShellPattern(); @@ -82,12 +77,29 @@ private void renderHoloShell(Vec3 offset, int rotation, GlobalConsoleBlockEntity var model = ShellModelCollection.getInstance().getShellEntry(shellTheme).getShellModel(pattern); model.setDoorPosition(false); + // Base rotation and positioning poseStack.mulPose(Axis.ZP.rotationDegrees(180F)); poseStack.translate(offset.x, offset.y, offset.z); - poseStack.translate(0, blockEntity.getLevel().random.nextFloat() * 0.01, 0); - poseStack.scale(0.1f, 0.1f, 0.1f); + + // Add subtle floating animation if (reactions.isFlying()) { - poseStack.mulPose(Axis.YP.rotationDegrees(((blockEntity.getLevel().getGameTime() % 360)) * 25f)); + float floatingOffset = (float) Math.sin(blockEntity.getLevel().getGameTime() / 15.0) * 0.05f; + poseStack.translate(0, floatingOffset, 0); + } + + // Random subtle jitter + poseStack.translate( + blockEntity.getLevel().random.nextFloat() * 0.005f - 0.0025f, + blockEntity.getLevel().random.nextFloat() * 0.005f - 0.0025f, + blockEntity.getLevel().random.nextFloat() * 0.005f - 0.0025f + ); + + float scaleModifier = 0.1f + (float) Math.sin(blockEntity.getLevel().getGameTime() / 20.0) * 0.005f; + poseStack.scale(scaleModifier, scaleModifier, scaleModifier); + + // Add rotation effect + if (reactions.isFlying()) { + poseStack.mulPose(Axis.YP.rotationDegrees((blockEntity.getLevel().getGameTime() % 360) * (reactions.getThrottleStage() * 5L))); } else { poseStack.mulPose(Axis.YP.rotationDegrees(rotation % 360)); } @@ -96,11 +108,33 @@ private void renderHoloShell(Vec3 offset, int rotation, GlobalConsoleBlockEntity ShellSelectionScreen.generateDummyGlobalShell(); } - model.renderShell(ShellSelectionScreen.globalShellBlockEntity, false, true, poseStack, bufferSource.getBuffer(RenderType.entityTranslucent(pattern.exteriorDoorTexture().texture())), packedLight, OverlayTexture.NO_OVERLAY, (float) color.x, (float) color.y, (float) color.z, 0.25f); + // Dynamic flickering alpha for a hologram effect + float flickerAlpha = 0.2f + blockEntity.getLevel().random.nextFloat() * 0.1f; + + boolean recoveryOrCrashing = reactions.isCrashing() || reactions.isInRecovery(); + + float time = blockEntity.getLevel().getGameTime() / 100.0f; + float red = recoveryOrCrashing ? 0.5f + (float) Math.sin(time) * 0.5f : (float) color.x; + float green = recoveryOrCrashing ? 0.5f + (float) Math.sin(time + Math.PI / 2) * 0.5f : (float) color.y; + float blue = recoveryOrCrashing ? 0.5f + (float) Math.sin(time + Math.PI) * 0.5f : (float) color.z; + + model.renderShell( + ShellSelectionScreen.globalShellBlockEntity, + false, + true, + poseStack, + bufferSource.getBuffer(RenderType.entityTranslucent(pattern.exteriorDoorTexture().texture())), + packedLight, + OverlayTexture.NO_OVERLAY, + red, + green, + blue, + flickerAlpha + ); poseStack.popPose(); - } + } @Override diff --git a/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPilot.java b/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPilot.java index 2d9b217f2..1b25e30bd 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPilot.java +++ b/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPilot.java @@ -2,6 +2,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.player.Abilities; import net.minecraft.world.entity.player.Player; import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; import whocraft.tardis_refined.common.tardis.TardisNavLocation; @@ -11,6 +12,8 @@ public interface TardisPilot { + void updatePlayerAbilities(ServerPlayer player, Abilities abilities, boolean isWatcher); + void setupPlayerForInspection(ServerPlayer serverPlayer, TardisLevelOperator tardisLevelOperator, TardisNavLocation spectateTarget); void endPlayerForInspection(ServerPlayer serverPlayer, TardisLevelOperator tardisLevelOperator); 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 c02cc4829..ab82a63c9 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 @@ -7,6 +7,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Abilities; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.GameType; import whocraft.tardis_refined.common.blockentity.door.TardisInternalDoor; @@ -24,20 +25,12 @@ public class TardisPlayerInfo implements TardisPilot { private Player player; private UUID viewedTardis; - private GameType gameTypeBackup; private TardisNavLocation observationPosition; public TardisPlayerInfo(Player player) { this.player = player; } - public GameType getGameTypeBackup() { - return gameTypeBackup; - } - - public void setGameTypeBackup(GameType gameTypeBackup) { - this.gameTypeBackup = gameTypeBackup; - } public void setPlayer(Player player) { this.player = player; @@ -57,6 +50,22 @@ public static Optional get(LivingEntity player) { } + @Override + public void updatePlayerAbilities(ServerPlayer player, Abilities abilities, boolean isWatcher) { + + if(isWatcher) { + abilities.mayfly = false; + abilities.instabuild = false; + abilities.invulnerable = true; + abilities.flying = true; + + player.setNoGravity(true); + } else { + player.gameMode.getGameModeForPlayer().updatePlayerAbilities(abilities); + player.setNoGravity(false); + } + } + @Override public void setupPlayerForInspection(ServerPlayer serverPlayer, TardisLevelOperator tardisLevelOperator, TardisNavLocation spectateTarget) { @@ -64,15 +73,13 @@ public void setupPlayerForInspection(ServerPlayer serverPlayer, TardisLevelOpera UUID uuid = UUID.fromString(tardisLevelOperator.getLevelKey().location().getPath()); setViewedTardis(uuid); - // Switch the player to spectator mode and teleport them to the TARDIS - setGameTypeBackup(serverPlayer.gameMode.getGameModeForPlayer()); - if (tardisLevelOperator.getPilotingManager().getCurrentLocation() != null) { TardisNavLocation sourceLocation = tardisLevelOperator.getPilotingManager().getCurrentLocation(); TardisHelper.teleportEntityTardis(tardisLevelOperator, player, sourceLocation, spectateTarget, false); - serverPlayer.setGameMode(GameType.SPECTATOR); + updatePlayerAbilities(serverPlayer, serverPlayer.getAbilities(), true); + serverPlayer.onUpdateAbilities(); syncToClients(null); } @@ -94,8 +101,9 @@ public void endPlayerForInspection(ServerPlayer serverPlayer, TardisLevelOperato TardisHelper.teleportEntityTardis(tardisLevelOperator, serverPlayer, sourceLocation, targetLocation, true); - // Reset the player's game mode to their default (e.g., survival) - serverPlayer.setGameMode(gameTypeBackup); + updatePlayerAbilities(serverPlayer, serverPlayer.getAbilities(), false); + serverPlayer.onUpdateAbilities(); + // Clear the viewed TARDIS UUID setViewedTardis(null); @@ -125,10 +133,6 @@ public CompoundTag saveData() { tag.putUUID("ViewedTardis", viewedTardis); } - if(gameTypeBackup != null) { - tag.putInt("playerGameType", gameTypeBackup.getId()); - } - return tag; } @@ -141,8 +145,6 @@ public void loadData(CompoundTag tag) { this.viewedTardis = null; } - gameTypeBackup = GameType.byId(tag.getInt("playerGameType")); - } @Override diff --git a/common/src/main/java/whocraft/tardis_refined/common/capability/tardis/TardisLevelOperator.java b/common/src/main/java/whocraft/tardis_refined/common/capability/tardis/TardisLevelOperator.java index 6694645a6..960b34c09 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/capability/tardis/TardisLevelOperator.java +++ b/common/src/main/java/whocraft/tardis_refined/common/capability/tardis/TardisLevelOperator.java @@ -24,6 +24,7 @@ import whocraft.tardis_refined.common.blockentity.door.RootShellDoorBlockEntity; import whocraft.tardis_refined.common.blockentity.door.TardisInternalDoor; import whocraft.tardis_refined.common.blockentity.shell.GlobalShellBlockEntity; +import whocraft.tardis_refined.common.capability.player.TardisPlayerInfo; import whocraft.tardis_refined.common.capability.tardis.upgrades.UpgradeHandler; import whocraft.tardis_refined.common.hum.TardisHums; import whocraft.tardis_refined.common.blockentity.shell.ExteriorShell; @@ -200,24 +201,34 @@ public void setInitiallyGenerated(boolean hasInitiallyGenerated) { * Moves the entity into the TARDIS. If the TARDIS has no door established, the entity is sent to 0,100,0. **/ public boolean enterTardis(Entity entity, BlockPos externalShellPos, ServerLevel shellLevel, Direction shellDirection) { + if (!(this.level instanceof ServerLevel targetServerLevel)) { + return false; + } - if (this.level instanceof ServerLevel targetServerLevel) { - - BlockPos targetPosition = internalDoor != null ? internalDoor.getTeleportPosition() : TardisArchitectureHandler.DESKTOP_CENTER_POS.above(); - Direction doorDirection = internalDoor != null ? internalDoor.getTeleportRotation() : entity.getDirection(); + // Determine target position and direction + BlockPos targetPosition = internalDoor != null ? internalDoor.getTeleportPosition() : TardisArchitectureHandler.DESKTOP_CENTER_POS.above(); + Direction targetDirection = internalDoor != null ? internalDoor.getTeleportRotation() : entity.getDirection(); - TardisNavLocation sourceLocation = new TardisNavLocation(externalShellPos, shellDirection, shellLevel); - TardisNavLocation targetLocation = new TardisNavLocation(targetPosition, doorDirection, targetServerLevel); + // Define source and target locations + TardisNavLocation sourceLocation = new TardisNavLocation(externalShellPos, shellDirection, shellLevel); + TardisNavLocation targetLocation = new TardisNavLocation(targetPosition, targetDirection, targetServerLevel); - this.pilotingManager.setCurrentLocation(new TardisNavLocation(externalShellPos, shellDirection.getOpposite(), shellLevel)); + // Update current location + this.pilotingManager.setCurrentLocation(new TardisNavLocation(externalShellPos, shellDirection.getOpposite(), shellLevel)); + // Handle teleportation + if (entity instanceof ServerPlayer serverPlayer) { + TardisPlayerInfo.get(serverPlayer).ifPresent(tardisPlayerInfo -> { + if (!tardisPlayerInfo.isViewingTardis()) { + TardisHelper.teleportEntityTardis(this, entity, sourceLocation, targetLocation, true); + } + }); + } else { TardisHelper.teleportEntityTardis(this, entity, sourceLocation, targetLocation, true); - return true; } - - return false; - + return true; } + public boolean isTardisReady() { return !this.getInteriorManager().isGeneratingDesktop(); } diff --git a/common/src/main/java/whocraft/tardis_refined/common/mixin/LocalPlayerMixin.java b/common/src/main/java/whocraft/tardis_refined/common/mixin/LocalPlayerMixin.java index c152c7aff..189cca8cf 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/mixin/LocalPlayerMixin.java +++ b/common/src/main/java/whocraft/tardis_refined/common/mixin/LocalPlayerMixin.java @@ -7,6 +7,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import whocraft.tardis_refined.client.TRKeybinds; import whocraft.tardis_refined.common.capability.player.TardisPlayerInfo; import whocraft.tardis_refined.common.network.messages.player.ExitTardisViewMessage; @@ -35,7 +36,7 @@ private void handleInput(LocalPlayer localPlayer, Input input) { private static void blockMovement(Input moveType) { // Set all movement-related fields to false or 0.0F to block movement - if(moveType.jumping){ + if(TRKeybinds.EXIT_EXTERIOR_VIEW.isDown()){ new ExitTardisViewMessage().send(); return; } diff --git a/common/src/main/java/whocraft/tardis_refined/common/mixin/PlayerRenderMixin.java b/common/src/main/java/whocraft/tardis_refined/common/mixin/PlayerRenderMixin.java index 9f7de3a71..e98606e32 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/mixin/PlayerRenderMixin.java +++ b/common/src/main/java/whocraft/tardis_refined/common/mixin/PlayerRenderMixin.java @@ -1,6 +1,9 @@ package whocraft.tardis_refined.common.mixin; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; +import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.player.PlayerRenderer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -14,10 +17,10 @@ public class PlayerRenderMixin { @Inject(method = "render(Lnet/minecraft/client/player/AbstractClientPlayer;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At("HEAD"), cancellable = true) - private void tick(CallbackInfo ci) { + private void render(AbstractClientPlayer abstractClientPlayer, float f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) { - TardisPlayerInfo.get(Minecraft.getInstance().player).ifPresent(tardisPlayerInfo -> { - if (tardisPlayerInfo.isViewingTardis() && Objects.equals(Minecraft.getInstance().player.getStringUUID(), tardisPlayerInfo.getPlayer().getStringUUID())) { + TardisPlayerInfo.get(abstractClientPlayer).ifPresent(tardisPlayerInfo -> { + if (tardisPlayerInfo.isViewingTardis()) { ci.cancel(); } }); diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisPilotingManager.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisPilotingManager.java index 88b57d76e..ced2b2de7 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisPilotingManager.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisPilotingManager.java @@ -748,7 +748,6 @@ public void enterTimeVortex() { Platform.getServer().getPlayerList().getPlayers().forEach(serverPlayer -> { TardisPlayerInfo.get(serverPlayer).ifPresent(tardisPlayerInfo -> { if (tardisPlayerInfo.isViewingTardis()) { - System.out.println(UUID.fromString(operator.getLevelKey().location().getPath())); if (Objects.equals(tardisPlayerInfo.getViewedTardis().toString(), UUID.fromString(operator.getLevelKey().location().getPath()).toString())) { tardisPlayerInfo.setupPlayerForInspection(serverPlayer, operator, operator.getPilotingManager().isInFlight() ? operator.getPilotingManager().getTargetLocation() : operator.getPilotingManager().getCurrentLocation()); 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 0561d2907..ba251a5af 100644 --- a/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java +++ b/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java @@ -20,6 +20,7 @@ public class ModMessages { public static String HARDWARE_OFFLINE = message("hardware_offline"); public static String ASCEND_KEY = message("ascend_key"); public static String DESCEND_KEY = message("descend_key"); + public static String EXIT_EXTERNAL_VIEW = message("exit_external_view"); public static String NO_FLIGHT_TRANSITIVE = message("no_flight_transitive"); public static String HANDBRAKE_ENGAGED = message("handbrake_engaged"); 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 new file mode 100644 index 000000000..9aebe747b Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/gui/external_view.png differ diff --git a/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabricClient.java b/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabricClient.java index a536088f8..e51b37521 100644 --- a/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabricClient.java +++ b/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabricClient.java @@ -2,6 +2,7 @@ import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; +import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry; import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; @@ -10,6 +11,7 @@ import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.client.ModelRegistry; import whocraft.tardis_refined.client.ParticleGallifrey; +import whocraft.tardis_refined.client.TRKeybinds; import whocraft.tardis_refined.client.TRParticles; import whocraft.tardis_refined.client.renderer.blockentity.RootPlantRenderer; import whocraft.tardis_refined.client.renderer.blockentity.console.GlobalConsoleRenderer; @@ -40,6 +42,9 @@ public void onInitializeClient() { ModEvents.addClientEvents(); particles(); registerEntityRenderers(); + + KeyBindingHelper.registerKeyBinding(TRKeybinds.EXIT_EXTERIOR_VIEW); + } private void particles() { diff --git a/fabric/src/main/java/whocraft/tardis_refined/fabric/events/ModEvents.java b/fabric/src/main/java/whocraft/tardis_refined/fabric/events/ModEvents.java index 322fc875a..02133f384 100644 --- a/fabric/src/main/java/whocraft/tardis_refined/fabric/events/ModEvents.java +++ b/fabric/src/main/java/whocraft/tardis_refined/fabric/events/ModEvents.java @@ -10,11 +10,14 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.Level; import whocraft.tardis_refined.ControlGroupCheckers; -import whocraft.tardis_refined.client.GravityOverlay; +import whocraft.tardis_refined.client.overlays.ExteriorViewOverlay; +import whocraft.tardis_refined.client.overlays.GravityOverlay; import whocraft.tardis_refined.client.TRItemColouring; import whocraft.tardis_refined.client.TardisClientLogic; import whocraft.tardis_refined.command.TardisRefinedCommand; @@ -30,6 +33,8 @@ import whocraft.tardis_refined.registry.TRItemRegistry; import whocraft.tardis_refined.registry.TRPointOfInterestTypes; +import java.util.function.Supplier; + import static net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents.START_WORLD_TICK; public class ModEvents { @@ -90,7 +95,12 @@ public static void addCommonEvents() { public static void addClientEvents() { ClientTickEvents.START_CLIENT_TICK.register(TardisClientLogic::tickClientData); ColorProviderRegistry.ITEM.register(TRItemColouring.SCREWDRIVER_COLORS, TRItemRegistry.SCREWDRIVER.get()); - HudRenderCallback.EVENT.register((matrixStack, tickDelta) -> GravityOverlay.renderOverlay(matrixStack.pose())); + + Supplier guiGraphics = () -> new GuiGraphics(Minecraft.getInstance(), Minecraft.getInstance().renderBuffers().bufferSource()); + + HudRenderCallback.EVENT.register((matrixStack, tickDelta) -> ExteriorViewOverlay.renderOverlay(guiGraphics.get())); + HudRenderCallback.EVENT.register((matrixStack, tickDelta) -> GravityOverlay.renderOverlay(guiGraphics.get())); + } 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 485760786..acb9f13b6 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 @@ -258,6 +258,7 @@ protected void addTranslations() { /*Overlay Messages*/ add(ModMessages.ASCEND_KEY, "Ascend: %s"); add(ModMessages.DESCEND_KEY, "Descend: %s"); + add(ModMessages.EXIT_EXTERNAL_VIEW, "Exit External View: %s"); /*Upgrades*/ addUpgrade(TRUpgrades.CHAMELEON_CIRCUIT_SYSTEM.get(), "Chameleon Circuit", "Allows the TARDIS to change it's shape"); diff --git a/forge/src/main/java/whocraft/tardis_refined/neoforge/ClientForgeBus.java b/forge/src/main/java/whocraft/tardis_refined/neoforge/ClientForgeBus.java index 45417bf5f..7dbc68c1f 100644 --- a/forge/src/main/java/whocraft/tardis_refined/neoforge/ClientForgeBus.java +++ b/forge/src/main/java/whocraft/tardis_refined/neoforge/ClientForgeBus.java @@ -7,7 +7,8 @@ import net.neoforged.neoforge.client.event.RenderGuiOverlayEvent; import net.neoforged.neoforge.event.TickEvent; import whocraft.tardis_refined.TardisRefined; -import whocraft.tardis_refined.client.GravityOverlay; +import whocraft.tardis_refined.client.overlays.ExteriorViewOverlay; +import whocraft.tardis_refined.client.overlays.GravityOverlay; import whocraft.tardis_refined.client.TardisClientLogic; @Mod.EventBusSubscriber(modid = TardisRefined.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) @@ -24,6 +25,7 @@ public static void tickTARDIS(TickEvent.ClientTickEvent event) { @SubscribeEvent public static void onRenderOverlay(RenderGuiOverlayEvent.Post guiOverlayEvent) { - GravityOverlay.renderOverlay(guiOverlayEvent.getGuiGraphics().pose()); + GravityOverlay.renderOverlay(guiOverlayEvent.getGuiGraphics()); + ExteriorViewOverlay.renderOverlay(guiOverlayEvent.getGuiGraphics()); } } diff --git a/forge/src/main/java/whocraft/tardis_refined/neoforge/ClientModBus.java b/forge/src/main/java/whocraft/tardis_refined/neoforge/ClientModBus.java index 4ac36a1d0..0802a292f 100644 --- a/forge/src/main/java/whocraft/tardis_refined/neoforge/ClientModBus.java +++ b/forge/src/main/java/whocraft/tardis_refined/neoforge/ClientModBus.java @@ -11,13 +11,11 @@ import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; import net.neoforged.neoforge.client.event.EntityRenderersEvent; import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent; +import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; import net.neoforged.neoforge.client.event.RegisterParticleProvidersEvent; import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent; import whocraft.tardis_refined.TardisRefined; -import whocraft.tardis_refined.client.ModelRegistry; -import whocraft.tardis_refined.client.ParticleGallifrey; -import whocraft.tardis_refined.client.TRItemColouring; -import whocraft.tardis_refined.client.TRParticles; +import whocraft.tardis_refined.client.*; import whocraft.tardis_refined.client.neoforge.ModelRegistryImpl; import whocraft.tardis_refined.client.renderer.blockentity.RootPlantRenderer; import whocraft.tardis_refined.client.renderer.blockentity.console.GlobalConsoleRenderer; @@ -45,6 +43,10 @@ public static void onItemColors(RegisterColorHandlersEvent.Item item) { item.register(TRItemColouring.SCREWDRIVER_COLORS, TRItemRegistry.SCREWDRIVER.get()); } + @SubscribeEvent + public static void keyMapping(RegisterKeyMappingsEvent event) { + event.register(TRKeybinds.EXIT_EXTERIOR_VIEW); + } @SubscribeEvent public static void onBuildTabsContent(BuildCreativeModeTabContentsEvent event) { diff --git a/forge/src/main/java/whocraft/tardis_refined/neoforge/CommonBus.java b/forge/src/main/java/whocraft/tardis_refined/neoforge/CommonBus.java index c7d4b6fa3..8857239cd 100644 --- a/forge/src/main/java/whocraft/tardis_refined/neoforge/CommonBus.java +++ b/forge/src/main/java/whocraft/tardis_refined/neoforge/CommonBus.java @@ -3,6 +3,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.Mod; import net.neoforged.neoforge.event.AddReloadListenerEvent;