-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- You can now view your TARDIS exterior via the Monitor
- Holographic exteriors on consoles now spin according to throttle - Improved UI for Gravity Shaft
- Loading branch information
Showing
20 changed files
with
313 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 0 additions & 54 deletions
54
common/src/main/java/whocraft/tardis_refined/client/GravityOverlay.java
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
common/src/main/java/whocraft/tardis_refined/client/TRKeybinds.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
|
||
|
||
} |
66 changes: 66 additions & 0 deletions
66
common/src/main/java/whocraft/tardis_refined/client/overlays/ExteriorViewOverlay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
common/src/main/java/whocraft/tardis_refined/client/overlays/GravityOverlay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.