diff --git a/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/door/interior/PoliceBoxDoorModel.java b/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/door/interior/PoliceBoxDoorModel.java index 715fad170..a4c540c33 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/door/interior/PoliceBoxDoorModel.java +++ b/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/door/interior/PoliceBoxDoorModel.java @@ -23,44 +23,49 @@ public static LayerDefinition createBodyLayer() { MeshDefinition meshdefinition = new MeshDefinition(); PartDefinition partdefinition = meshdefinition.getRoot(); - PartDefinition root = partdefinition.addOrReplaceChild("root", CubeListBuilder.create().texOffs(19, 41).mirror().addBox(8.5F, -32.0F, 5.5F, 2.0F, 32.0F, 2.0F, new CubeDeformation(0.0F)).mirror(false) - .texOffs(0, 0).addBox(-8.5F, -32.0F, 6.5F, 17.0F, 32.0F, 1.0F, new CubeDeformation(0.0F)) - .texOffs(19, 41).addBox(-10.5F, -32.0F, 5.5F, 2.0F, 32.0F, 2.0F, new CubeDeformation(0.0F)) - .texOffs(0, 34).addBox(-10.5F, -35.25F, 5.5F, 21.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.5F)); - - PartDefinition right_door = root.addOrReplaceChild("right_door", CubeListBuilder.create().texOffs(50, 51).mirror().addBox(-7.0F, -8.0F, -0.5F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) - .texOffs(28, 41).addBox(-9.0F, -31.25F, -0.775F, 1.0F, 31.0F, 2.0F, new CubeDeformation(0.0F)) - .texOffs(56, 27).addBox(-9.0F, -0.75F, -1.025F, 1.0F, 1.0F, 2.0F, new CubeDeformation(0.0F)) - .texOffs(50, 51).addBox(-7.0F, -15.5F, -0.5F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) - .texOffs(35, 41).addBox(-7.0F, -23.0F, -2.475F, 6.0F, 7.0F, 2.0F, new CubeDeformation(0.0F)) - .texOffs(0, 41).addBox(-8.0F, -31.25F, -0.475F, 8.0F, 31.0F, 1.0F, new CubeDeformation(0.0F)) - .texOffs(56, 0).mirror().addBox(-8.0F, -1.0F, -0.475F, 8.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) - .texOffs(52, 42).addBox(-7.0F, -30.75F, -0.5F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) - .texOffs(50, 33).addBox(-7.0F, -8.0F, 0.025F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) - .texOffs(50, 33).mirror().addBox(-7.0F, -15.5F, 0.025F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) - .texOffs(50, 33).mirror().addBox(-7.0F, -23.0F, 0.025F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) - .texOffs(56, 3).addBox(-6.5F, -22.5F, 0.05F, 5.0F, 6.0F, 1.0F, new CubeDeformation(0.0F)) - .texOffs(56, 23).addBox(-6.0F, -28.25F, -0.525F, 4.0F, 2.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offset(8.5F, 0.0F, 6.25F)); - - PartDefinition bone3 = right_door.addOrReplaceChild("bone3", CubeListBuilder.create().texOffs(35, 51).addBox(-3.25F, -6.25F, 18.975F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) - .texOffs(56, 19).addBox(-2.25F, -3.75F, 19.05F, 4.0F, 2.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offset(-3.75F, -24.5F, -19.0F)); - - PartDefinition left_door = root.addOrReplaceChild("left_door", CubeListBuilder.create().texOffs(50, 51).addBox(1.0F, -8.0F, -0.5F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) - .texOffs(50, 51).addBox(1.0F, -15.5F, -0.5F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) - .texOffs(50, 51).addBox(1.0F, -23.0F, -0.5F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) - .texOffs(37, 0).addBox(0.0F, -31.25F, -0.475F, 8.0F, 31.0F, 1.0F, new CubeDeformation(0.0F)) - .texOffs(56, 0).addBox(0.0F, -1.0F, -0.475F, 8.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) - .texOffs(56, 11).addBox(1.5F, -22.5F, 0.05F, 5.0F, 6.0F, 1.0F, new CubeDeformation(0.0F)) - .texOffs(50, 33).addBox(1.0F, -23.0F, 0.025F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) - .texOffs(50, 33).addBox(1.0F, -15.5F, 0.025F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) - .texOffs(50, 33).mirror().addBox(1.0F, -8.0F, 0.025F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) - .texOffs(44, 60).addBox(4.0F, -21.0F, -1.475F, 4.0F, 3.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offset(-8.5F, 0.0F, 6.25F)); - - PartDefinition bone2 = left_door.addOrReplaceChild("bone2", CubeListBuilder.create().texOffs(35, 51).mirror().addBox(-2.75F, -6.25F, 18.975F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) - .texOffs(56, 19).mirror().addBox(-1.75F, -3.75F, 19.05F, 4.0F, 2.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(3.75F, -24.5F, -19.0F)); - - PartDefinition bone5 = left_door.addOrReplaceChild("bone5", CubeListBuilder.create().texOffs(52, 42).mirror().addBox(-3.25F, -8.25F, 1.0F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) - .texOffs(56, 23).mirror().addBox(-2.25F, -5.75F, 0.975F, 4.0F, 2.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(4.25F, -22.5F, -1.5F)); + PartDefinition bone = partdefinition.addOrReplaceChild("bone", CubeListBuilder.create().texOffs(41, 11).addBox(-7.5F, -32.25F, -2.525F, 17.0F, 1.0F, 2.0F, new CubeDeformation(0.0F)) + .texOffs(0, 35).addBox(-10.5F, -37.25F, -2.775F, 23.0F, 5.0F, 3.0F, new CubeDeformation(0.0F)) + .texOffs(41, 5).addBox(-8.5F, -36.25F, -3.775F, 19.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(19, 44).addBox(-10.5F, -33.0F, -2.775F, 2.0F, 33.0F, 3.0F, new CubeDeformation(0.0F)) + .texOffs(41, 0).addBox(-10.5F, 0.0F, -2.775F, 23.0F, 1.0F, 3.0F, new CubeDeformation(0.0F)) + .texOffs(0, 0).addBox(-8.5F, -33.0F, -0.775F, 19.0F, 33.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(19, 44).mirror().addBox(10.5F, -33.0F, -2.775F, 2.0F, 33.0F, 3.0F, new CubeDeformation(0.0F)).mirror(false) + .texOffs(30, 44).addBox(9.5F, -33.0F, -2.525F, 1.0F, 33.0F, 2.0F, new CubeDeformation(0.0F)) + .texOffs(30, 44).mirror().addBox(-8.5F, -33.0F, -2.525F, 1.0F, 33.0F, 2.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(-1.0F, 23.0F, 7.775F)); + + PartDefinition right_door = bone.addOrReplaceChild("right_door", CubeListBuilder.create().texOffs(44, 53).mirror().addBox(-7.0F, -8.0F, -0.5F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) + .texOffs(37, 44).addBox(-9.0F, -31.25F, -1.025F, 1.0F, 31.0F, 2.0F, new CubeDeformation(0.0F)) + .texOffs(53, 62).addBox(-9.0F, -1.0F, -1.025F, 1.0F, 1.0F, 2.0F, new CubeDeformation(0.0F)) + .texOffs(44, 53).addBox(-7.0F, -15.5F, -0.5F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(41, 15).addBox(-7.0F, -23.0F, -2.475F, 6.0F, 7.0F, 2.0F, new CubeDeformation(0.0F)) + .texOffs(0, 44).addBox(-8.0F, -31.25F, -0.475F, 8.0F, 31.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(56, 25).addBox(-8.0F, -1.0F, -0.475F, 8.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(53, 34).addBox(-7.0F, -30.75F, -0.5F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(44, 44).addBox(-7.0F, -8.0F, 0.025F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(44, 44).mirror().addBox(-7.0F, -15.5F, 0.025F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) + .texOffs(44, 44).mirror().addBox(-7.0F, -23.0F, 0.025F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) + .texOffs(59, 43).addBox(-6.5F, -22.5F, 0.05F, 5.0F, 6.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(56, 28).addBox(-6.0F, -28.25F, -0.525F, 4.0F, 2.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offset(9.5F, 0.0F, -1.5F)); + + PartDefinition bone4 = right_door.addOrReplaceChild("bone4", CubeListBuilder.create().texOffs(41, 25).addBox(-3.25F, -6.25F, 18.975F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(59, 51).addBox(-2.25F, -3.75F, 19.05F, 4.0F, 2.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offset(-3.75F, -24.5F, -19.0F)); + + PartDefinition left_door = bone.addOrReplaceChild("left_door", CubeListBuilder.create().texOffs(44, 53).addBox(1.0F, -8.0F, -0.5F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(44, 53).mirror().addBox(1.0F, -15.5F, -0.5F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) + .texOffs(44, 53).mirror().addBox(1.0F, -23.25F, -0.5F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) + .texOffs(44, 62).addBox(5.0F, -19.25F, -1.475F, 3.0F, 3.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(0, 44).mirror().addBox(0.0F, -31.25F, -0.475F, 8.0F, 31.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) + .texOffs(56, 25).mirror().addBox(0.0F, -1.0F, -0.475F, 8.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) + .texOffs(53, 34).mirror().addBox(1.0F, -30.75F, -0.5F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) + .texOffs(44, 44).mirror().addBox(1.0F, -8.0F, 0.025F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) + .texOffs(44, 44).addBox(1.0F, -15.5F, 0.025F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(44, 44).addBox(1.0F, -23.0F, 0.025F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(58, 15).addBox(1.5F, -22.5F, 0.05F, 5.0F, 6.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(59, 55).addBox(7.5F, -21.5F, -0.25F, 1.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)) + .texOffs(56, 28).mirror().addBox(2.0F, -28.25F, -0.525F, 4.0F, 2.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(-7.5F, 0.0F, -1.5F)); + + PartDefinition bone6 = left_door.addOrReplaceChild("bone6", CubeListBuilder.create().texOffs(41, 25).mirror().addBox(-2.75F, -6.25F, 18.975F, 6.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) + .texOffs(59, 51).mirror().addBox(-1.75F, -3.75F, 19.05F, 4.0F, 2.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(3.75F, -24.5F, -19.0F)); return LayerDefinition.create(meshdefinition, 128, 128); } diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/entity/ControlEntityRenderer.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/entity/ControlEntityRenderer.java index 5a81d44bf..3f26d018c 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/entity/ControlEntityRenderer.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/entity/ControlEntityRenderer.java @@ -1,12 +1,18 @@ package whocraft.tardis_refined.client.renderer.entity; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.NoopRenderer; +import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.FormattedCharSequence; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.level.Level; @@ -15,6 +21,7 @@ import org.joml.Matrix4f; import whocraft.tardis_refined.TRConfig; +import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.client.TRParticles; import whocraft.tardis_refined.common.entity.ControlEntity; import whocraft.tardis_refined.common.items.GlassesItem; @@ -23,6 +30,12 @@ public class ControlEntityRenderer extends NoopRenderer { + private static ResourceLocation ICON_GOOD = new ResourceLocation(TardisRefined.MODID, "textures/gui/sprites/control/control_good.png"); + private static ResourceLocation ICON_SLIPPING = new ResourceLocation(TardisRefined.MODID, "textures/gui/sprites/control/control_slipping.png"); + private static ResourceLocation ICON_WARNING = new ResourceLocation(TardisRefined.MODID, "textures/gui/sprites/control/control_warning.png"); + private static ResourceLocation ICON_ALERT = new ResourceLocation(TardisRefined.MODID, "textures/gui/sprites/control/control_alert.png"); + private static ResourceLocation ICON_DANGER = new ResourceLocation(TardisRefined.MODID, "textures/gui/sprites/control/control_danger.png"); + public ControlEntityRenderer(EntityRendererProvider.Context context) { super(context); } @@ -55,6 +68,7 @@ public void render(ControlEntity entity, float f, float g, PoseStack poseStack, } } } + } @Override @@ -66,6 +80,7 @@ protected void renderNameTag(ControlEntity entity, Component component, PoseStac boolean isSolid = !entity.isDiscrete(); float boundingBoxHeight = entity.getNameTagOffsetY() - 0.3f; int verticalTextOffset = 10; + poseStack.pushPose(); poseStack.translate(0.0, boundingBoxHeight, 0.0); @@ -83,16 +98,85 @@ protected void renderNameTag(ControlEntity entity, Component component, PoseStac font.drawInBatch8xOutline(sequence, textHorizontalPosition, (float) verticalTextOffset, 16777215, 0, textMatrix, multiBufferSource, packedLightCoords); - // Damage used for the icon later on. Left for Jeryn. - int entityHealth = entity.getControlHealth(); - if (isSolid) { font.drawInBatch8xOutline(sequence, textHorizontalPosition, (float) verticalTextOffset, 16777215, 0, textMatrix, multiBufferSource, packedLightCoords); } + // Damage used for the icon later on. Left for Jeryn. + int entityHealth = entity.getControlHealth(); + + poseStack.translate(0.0, 5, 0.0); + renderControlIcon(entity, component, getIconByState(entityHealth), poseStack, multiBufferSource, packedLightCoords ); + poseStack.popPose(); + + } } + + public ResourceLocation getIconByState(int entityHealth) { + if (entityHealth == 10) { + return ICON_GOOD; + } + + if (entityHealth == 8 || entityHealth == 9) { + return ICON_SLIPPING; + } + + if (entityHealth > 5) { + return ICON_WARNING; + } + + if (entityHealth > 3) { + return ICON_ALERT; + } + + return ICON_DANGER; + + } + + + private void renderControlIcon(ControlEntity entity, Component component, ResourceLocation texture, PoseStack matrixStackIn, MultiBufferSource buffer, int light) { + + float offset = (float) -(Minecraft.getInstance().font.width(component) / 2 + 18); + VertexConsumer builder = buffer.getBuffer(RenderType.text(texture)); + int alpha = 32; + + if (entity.isDiscrete()) { + vertex(builder, matrixStackIn, offset, 16F, 0F, 0F, 1F, alpha, light); + vertex(builder, matrixStackIn, offset + 16F, 16F, 0F, 1F, 1F, alpha, light); + vertex(builder, matrixStackIn, offset + 16F, 0F, 0F, 1F, 0F, alpha, light); + vertex(builder, matrixStackIn, offset, 0F, 0F, 0F, 0F, alpha, light); + } else { + vertex(builder, matrixStackIn, offset, 16F, 0F, 0F, 1F, light); + vertex(builder, matrixStackIn, offset + 16F, 16F, 0F, 1F, 1F, light); + vertex(builder, matrixStackIn, offset + 16F, 0F, 0F, 1F, 0F, light); + vertex(builder, matrixStackIn, offset, 0F, 0F, 0F, 0F, light); + + VertexConsumer builderSeeThrough = buffer.getBuffer(RenderType.textSeeThrough(texture)); + vertex(builderSeeThrough, matrixStackIn, offset, 16F, 0F, 0F, 1F, alpha, light); + vertex(builderSeeThrough, matrixStackIn, offset + 16F, 16F, 0F, 1F, 1F, alpha, light); + vertex(builderSeeThrough, matrixStackIn, offset + 16F, 0F, 0F, 1F, 0F, alpha, light); + vertex(builderSeeThrough, matrixStackIn, offset, 0F, 0F, 0F, 0F, alpha, light); + } + + } + + private static void vertex(VertexConsumer builder, PoseStack matrixStack, float x, float y, float z, float u, float v, int light) { + vertex(builder, matrixStack, x, y, z, u, v, 255, light); + } + + private static void vertex(VertexConsumer builder, PoseStack matrixStack, float x, float y, float z, float u, float v, int alpha, int light) { + PoseStack.Pose entry = matrixStack.last(); + builder.vertex(entry.pose(), x, y, z) + .color(255, 255, 255, alpha) + .uv(u, v) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(light) + .normal(entry.normal(), 0F, 0F, -1F) + .endVertex(); + } + } diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/upgrades/UpgradesScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/upgrades/UpgradesScreen.java index 43e5d2b85..dd69bb386 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/upgrades/UpgradesScreen.java +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/upgrades/UpgradesScreen.java @@ -17,7 +17,7 @@ import java.util.ArrayList; import java.util.List; -public class UpgradesScreen extends Screen { +public class UpgradesScreen extends Screen { public static final ResourceLocation WINDOW = new ResourceLocation(TardisRefined.MODID, "textures/gui/upgrades/window.png"); public static final ResourceLocation TABS = new ResourceLocation(TardisRefined.MODID, "textures/gui/upgrades/tabs.png"); @@ -137,6 +137,7 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { int i = (this.width - WINDOW_WIDTH) / 2; int j = (this.height - WINDOW_HEIGHT) / 2; + this.renderTransparentBackground(guiGraphics); this.renderBackground(guiGraphics, mouseX, mouseY, partialTick); this.renderWindow(guiGraphics, i, j); this.renderInside(guiGraphics, mouseX, mouseY, i, j); @@ -149,6 +150,8 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia this.selectedTab.fade = Mth.clamp(this.selectedTab.fade + 0.02F, 0, 0.5F); guiGraphics.pose().translate(0, 0, -500); } + + } @Override @@ -196,7 +199,12 @@ public void renderWindow(GuiGraphics guiGraphics, int offsetX, int offsetY) { RenderSystem.disableBlend(); } - guiGraphics.drawString(this.minecraft.font, TITLE.getString() + " - Upgrade Points: " + upgradeHandler.getUpgradePoints(), width / 2 - font.width(TITLE.getString() + " - Upgrade Points: " + upgradeHandler.getUpgradePoints()) / 2, offsetY + 6, ChatFormatting.BLACK.getColor(), false); + if (upgradeHandler.getUpgradePoints() > 0) { + guiGraphics.drawString(this.minecraft.font, "Points: " + upgradeHandler.getUpgradePoints(), width / 2 - font.width("Points: " + upgradeHandler.getUpgradePoints()) / 2, offsetY + WINDOW_HEIGHT - 15, ChatFormatting.BLACK.getColor(), false); + } + + guiGraphics.drawString(this.minecraft.font, "XP: " + upgradeHandler.getUpgradeXP() + " / 100", width / 2 - font.width( "XP: " + upgradeHandler.getUpgradeXP() + " / 100") / 2, offsetY + 6 , ChatFormatting.BLACK.getColor(), false); + // guiGraphics.drawString(this.minecraft.font, "XP: " + upgradeHandler.getUpgradeXP() + "/100 - Upgrade Points: " + upgradeHandler.getUpgradePoints(), width / 2 - font.width("XP: " + upgradeHandler.getUpgradeXP() + "/100 - Upgrade Points: " + upgradeHandler.getUpgradePoints()) / 2, offsetY + 6, ChatFormatting.BLACK.getColor(), false); } private void renderTooltips(GuiGraphics guiGraphics, int mouseX, int mouseY, int offsetX, int offsetY) { diff --git a/common/src/main/java/whocraft/tardis_refined/common/block/device/LandingPad.java b/common/src/main/java/whocraft/tardis_refined/common/block/device/LandingPad.java index 05b33f459..c5f742ad8 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/block/device/LandingPad.java +++ b/common/src/main/java/whocraft/tardis_refined/common/block/device/LandingPad.java @@ -2,6 +2,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvents; @@ -28,6 +29,8 @@ import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager; import whocraft.tardis_refined.common.util.DimensionUtil; import whocraft.tardis_refined.common.util.Platform; +import whocraft.tardis_refined.common.util.PlayerUtil; +import whocraft.tardis_refined.constants.ModMessages; public class LandingPad extends Block { @@ -81,9 +84,18 @@ public InteractionResult use(BlockState blockState, Level level, BlockPos blockP if (Upgrades.LANDING_PAD.get().isUnlocked(upgradeHandler) && pilotManager.beginFlight(true, null) && !pilotManager.isOnCooldown()) { pilotManager.setTargetLocation(new TardisNavLocation(blockPos.above(), player.getDirection().getOpposite(), serverLevel)); serverLevel.playSound(null, blockPos, SoundEvents.PLAYER_LEVELUP, SoundSource.BLOCKS, 1f, 1f); + PlayerUtil.sendMessage(player, Component.translatable(ModMessages.TARDIS_IS_ON_THE_WAY), true); return super.use(blockState, level, blockPos, player, interactionHand, blockHitResult); } else { - serverLevel.playSound(null, blockPos, SoundEvents.FURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1f, 1f); + + if (Upgrades.LANDING_PAD.get().isUnlocked(upgradeHandler)) { + PlayerUtil.sendMessage(player, Component.translatable(ModMessages.LANDING_PAD_TRANSIENT), true); + serverLevel.playSound(null, blockPos, SoundEvents.NOTE_BLOCK_BIT.value(), SoundSource.BLOCKS, 100, (float) (0.1 + (serverLevel.getRandom().nextFloat() * 0.25))); + } else { + serverLevel.playSound(null, blockPos, SoundEvents.FURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1f, 1f); + PlayerUtil.sendMessage(player, Component.translatable(ModMessages.LANDING_PAD_NOT_UNLOCKED), true); + } + return super.use(blockState, level, blockPos, player, interactionHand, blockHitResult); } } diff --git a/common/src/main/java/whocraft/tardis_refined/common/items/KeyItem.java b/common/src/main/java/whocraft/tardis_refined/common/items/KeyItem.java index 8f753cae8..28b03d0cc 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/items/KeyItem.java +++ b/common/src/main/java/whocraft/tardis_refined/common/items/KeyItem.java @@ -23,7 +23,9 @@ import net.minecraft.world.level.Level; import org.jetbrains.annotations.Nullable; import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.client.TardisClientData; import whocraft.tardis_refined.common.capability.TardisLevelOperator; +import whocraft.tardis_refined.common.dimension.DimensionHandler; import whocraft.tardis_refined.common.entity.ControlEntity; import whocraft.tardis_refined.common.tardis.control.ConsoleControl; import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager; @@ -167,6 +169,15 @@ public void appendHoverText(ItemStack itemStack, @Nullable Level level, List> keychain = KeyItem.getKeychain(itemStack); if (!keychain.isEmpty()) { + + ResourceKey mainTardisLevel = keychain.get(0); + + if (TardisClientData.getInstance(mainTardisLevel).isFlying()) { + list.add(Component.translatable("* " + ModMessages.TOOLTIP_IN_FLIGHT + " *")); + } + + + list.add(Component.translatable(ModMessages.TOOLTIP_TARDIS_LIST_TITLE)); for (int i = 0; i < keychain.size(); i++) { @@ -174,6 +185,8 @@ public void appendHoverText(ItemStack itemStack, @Nullable Level level, List (20 * 10) && autoLand) { + if (distanceCovered >= flightDistance && autoLand && !this.isLanding()) { this.endFlight(false); } } @@ -455,7 +455,12 @@ public boolean beginFlight(boolean autoLand, Optional TardisNavLocation lastKnownLocation = this.operator.getExteriorManager().getLastKnownLocation(); this.flightDistance = calculateFlightDistance(lastKnownLocation, targetPosition); - this.operator.getFlightDanceManager().startFlightDance(this.currentConsole); + + if (!autoLand) { + this.operator.getFlightDanceManager().startFlightDance(this.currentConsole); + } + + operator.setDoorClosed(true); operator.getLevel().playSound(null, operator.getInternalDoor().getDoorPosition(), SoundRegistry.TARDIS_TAKEOFF.get(), SoundSource.AMBIENT, 10f, 1f); @@ -532,6 +537,15 @@ public boolean endFlight(boolean forceFlightEnd) { level.playSound(null, TardisArchitectureHandler.DESKTOP_CENTER_POS, SoundRegistry.TARDIS_LAND.get(), SoundSource.AMBIENT, 10f, 1f); } + int totalPoints = distanceCovered / 10; + this.operator.getUpgradeHandler().addUpgradeXP(totalPoints); + + var players = level.players(); + for (var player : players) { + PlayerUtil.sendMessage(player, Component.translatable("+" + totalPoints + "XP."), true); + } + + return true; } 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 067c83e7d..0476ccdf6 100644 --- a/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java +++ b/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java @@ -29,6 +29,10 @@ public class ModMessages { public static String CONSOLE_CONFIGURATION_NOT_IN_FLIGHT = message("console_config_not_in_flight"); public static String CONSOLE_NOT_IN_FLIGHT = message("cannot_switch_console_units_whilst_in_flight"); public static String NO_END_DRAGON_PREVENTS = message("no_end_dragon_prevents"); + public static String TARDIS_IS_ON_THE_WAY = message("tardis_on_the_way"); + public static String LANDING_PAD_NOT_UNLOCKED = message("landing_pad_unlocked"); + public static String LANDING_PAD_TRANSIENT = message("landing_pad_transient"); + public static String TOOLTIP_IN_FLIGHT = message("tooltip_in_flight"); public static String TOOLTIP_TARDIS_LIST_TITLE = tooltip("tardis_list"); diff --git a/common/src/main/resources/assets/tardis_refined/textures/blockentity/shell/police_box/police_box_interior.png b/common/src/main/resources/assets/tardis_refined/textures/blockentity/shell/police_box/police_box_interior.png index 691fcdb18..f1b236140 100644 Binary files a/common/src/main/resources/assets/tardis_refined/textures/blockentity/shell/police_box/police_box_interior.png and b/common/src/main/resources/assets/tardis_refined/textures/blockentity/shell/police_box/police_box_interior.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/gui/sprites/control/control_alert.png b/common/src/main/resources/assets/tardis_refined/textures/gui/sprites/control/control_alert.png new file mode 100644 index 000000000..21b3970d9 Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/gui/sprites/control/control_alert.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/gui/sprites/control/control_danger.png b/common/src/main/resources/assets/tardis_refined/textures/gui/sprites/control/control_danger.png new file mode 100644 index 000000000..dfd81563f Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/gui/sprites/control/control_danger.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/gui/sprites/control/control_good.png b/common/src/main/resources/assets/tardis_refined/textures/gui/sprites/control/control_good.png new file mode 100644 index 000000000..c7636f63c Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/gui/sprites/control/control_good.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/gui/sprites/control/control_slipping.png b/common/src/main/resources/assets/tardis_refined/textures/gui/sprites/control/control_slipping.png new file mode 100644 index 000000000..1bd1d2e79 Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/gui/sprites/control/control_slipping.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/gui/sprites/control/control_warning.png b/common/src/main/resources/assets/tardis_refined/textures/gui/sprites/control/control_warning.png new file mode 100644 index 000000000..de716befd Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/gui/sprites/control/control_warning.png differ 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 150cda0cb..830fce63f 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 @@ -111,6 +111,9 @@ protected void addTranslations() { add(ModMessages.HANDBRAKE_WARNING, "Ship is in flight. Left click the handbrake to engage."); add(ModMessages.CONSOLE_NOT_IN_FLIGHT, "Cannot change consoles whilst in flight."); add(ModMessages.NO_END_DRAGON_PREVENTS, "A dragon prevents you from progressing to The End."); + add(ModMessages.TARDIS_IS_ON_THE_WAY, "TARDIS has been summoned and is on the way."); + add(ModMessages.LANDING_PAD_NOT_UNLOCKED, "Specified TARDIS rejected landing pad signal."); + add(ModMessages.LANDING_PAD_TRANSIENT, "Cannot summon TARDIS at this time."); /*Command*/ add(ModMessages.CMD_DIM_NOT_A_TARDIS, ChatFormatting.RED + "%s is not a TARDIS Dimension!"); @@ -193,6 +196,7 @@ protected void addTranslations() { /*Tool Tips*/ add(ModMessages.TOOLTIP_TARDIS_LIST_TITLE, "Key Set:"); add(ModMessages.CONTROL_DIMENSION_SELECTED, "Selected: %s"); + add(ModMessages.TOOLTIP_IN_FLIGHT, "In flight"); /*Config*/ add(ModMessages.CONFIG_IP_COMPAT, "Immersive Portals Compatibility?");