Skip to content

Commit

Permalink
Shell selection screen
Browse files Browse the repository at this point in the history
  • Loading branch information
EdusgprNetwork authored and Jeryn99 committed Dec 3, 2024
1 parent bc0706d commit 115c86a
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public static void update(GuiGraphics gg) {
}

public static void renderOverlay(GuiGraphics gg) {

TardisPlayerInfo.get(Minecraft.getInstance().player).ifPresent(tardisPlayerInfo -> {
/*Activation Logic*/
TardisClientData tardisClientData = TardisClientData.getInstance(tardisPlayerInfo.getPlayerPreviousPos().getDimensionKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,19 @@ public class VortexRenderer {
public VortexTypes vortexType;

public final RenderHelper.DynamicTimeKeep time = new RenderHelper.DynamicTimeKeep(2);

public VortexRenderer(VortexTypes type) {
this.vortexType = type;
}

private final List<VortexQuad> vortex_quads = new ArrayList<>();
public float opacity = 1;
public float lightning_strike = 0;

/**
* Renders the Time Vortex
*/
public void renderVortex(PoseStack pose, float opacity) {
public void renderVortex(PoseStack pose, float opacity, boolean half) {
this.opacity = Math.min(opacity, 1);
if (vortexType.movingGradient) this.vortexType.gradient.offset = time.getFloat() * 2;
this.time.update();
Expand All @@ -75,7 +77,7 @@ public void renderVortex(PoseStack pose, float opacity) {
RenderHelper.rotateZYX(pose, 90.0f, 180, 0.0f);
pose.scale(1, this.vortexType.rows, 1);

for (int row = -this.vortexType.rows; row < this.vortexType.rows; row++) {
for (int row = half ? 0 : -this.vortexType.rows; row < this.vortexType.rows; row++) {
Tesselator tesselator = beginTextureColor(Mode.TRIANGLE_STRIP);
pose.pushPose();
pose.translate(0, o(row), 0);
Expand Down Expand Up @@ -106,9 +108,13 @@ public void renderVortex(PoseStack pose, float opacity) {
pose.popPose();
}

public void renderVortex(GuiGraphics guiGraphics, float opacity) {
public void renderVortex(GuiGraphics guiGraphics, float opacity, boolean half) {
PoseStack pose = guiGraphics.pose();
renderVortex(pose, opacity);
renderVortex(pose, opacity, half);
}

public void renderVortex(GuiGraphics guiGraphics, float opacity) {
renderVortex(guiGraphics, opacity, false);
}

private void renderCylinder(PoseStack poseStack, int row) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;
Expand All @@ -19,10 +20,13 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.Level;
import org.joml.Matrix4f;
import org.lwjgl.opengl.GL11;
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;
Expand Down Expand Up @@ -89,8 +93,8 @@ protected void init() {
this.leftPos = (this.width - this.imageWidth) / 2;
this.topPos = (this.height - this.imageHeight) / 2;

addSubmitButton(width / 2 + 90, (height) / 2 + 35);
addCancelButton(width / 2 - 11, (height) / 2 + 35);
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);
Expand All @@ -112,7 +116,9 @@ public void selectShell(ResourceLocation themeId) {
public void render(GuiGraphics guiGraphics, int i, int j, float f) {
renderBackground(guiGraphics);
PoseStack poseStack = guiGraphics.pose();
ClientLevel lvl = Minecraft.getInstance().level;
Minecraft mc = Minecraft.getInstance();
ClientLevel lvl = mc.level;
assert lvl != null;
RandomSource rand = lvl.random;

boolean isCrashed = TardisClientData.getInstance(lvl.dimension()).isCrashing();
Expand All @@ -129,16 +135,54 @@ public void render(GuiGraphics guiGraphics, int i, int j, float f) {
}


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.75;
VortexOverlay.VORTEX.renderVortex(guiGraphics, 1, false);
RenderSystem.restoreProjectionMatrix();
poseStack.popPose();
guiGraphics.disableScissor();

guiGraphics.enableScissor(0, 0, width + 3, topPos + 3);
this.renderBackground(guiGraphics);
guiGraphics.disableScissor();
guiGraphics.enableScissor(0, topPos + 3, leftPos + 3, height - topPos - 3);
this.renderBackground(guiGraphics);
guiGraphics.disableScissor();
guiGraphics.enableScissor(width - leftPos - 3, topPos + 3, width, height - topPos - 3);
this.renderBackground(guiGraphics);
guiGraphics.disableScissor();
guiGraphics.enableScissor(0, height - topPos - 3, width, height);
this.renderBackground(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(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);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
//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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,24 +214,7 @@ public void tick(ServerLevel level) {
tardisClientData.setIsTakingOff(exteriorManager.isTakingOff());
tardisClientData.setThrottleStage(pilotingManager.getThrottleStage());
tardisClientData.setHandbrakeEngaged(pilotingManager.isHandbrakeOn());

CompoundTag oldData = tardisClientData.serializeNBT();
tardisClientData.setIsOnCooldown(pilotingManager.isInRecovery());
tardisClientData.setShellTheme(aestheticHandler.getShellTheme());
tardisClientData.setShellPattern(aestheticHandler.shellPattern().id());
tardisClientData.setHumEntry(interiorManager.getHumEntry());
tardisClientData.setFuel(pilotingManager.getFuel());
tardisClientData.setMaximumFuel(pilotingManager.getMaximumFuel());
tardisClientData.setTardisState(tardisState);
tardisClientData.setFlying(pilotingManager.isInFlight());
tardisClientData.setIsLanding(exteriorManager.isLanding());
tardisClientData.setIsTakingOff(exteriorManager.isTakingOff());
tardisClientData.setThrottleStage(pilotingManager.getThrottleStage());
tardisClientData.setHandbrakeEngaged(pilotingManager.isHandbrakeOn());
CompoundTag newData = tardisClientData.serializeNBT();
if (!oldData.equals(newData)) {
tardisClientData.sync();
}
tardisClientData.sync();
}

Iterator<ServerPlayer> updatingMonitorsIterator = updatingMonitors.iterator();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 115c86a

Please sign in to comment.