Skip to content

Commit

Permalink
Control icons, flight XP, updated Tdis doors and landing pad fixes (#218
Browse files Browse the repository at this point in the history
)
  • Loading branch information
CommandrMoose authored Apr 8, 2024
1 parent 2e0f9c4 commit b610b86
Show file tree
Hide file tree
Showing 14 changed files with 192 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -23,6 +30,12 @@

public class ControlEntityRenderer extends NoopRenderer<ControlEntity> {

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);
}
Expand Down Expand Up @@ -55,6 +68,7 @@ public void render(ControlEntity entity, float f, float g, PoseStack poseStack,
}
}
}

}

@Override
Expand All @@ -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);

Expand All @@ -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();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit b610b86

Please sign in to comment.