294 lines
11 KiB
Java
294 lines
11 KiB
Java
package com.dairymoose.modernlife.renderer.tileentity;
|
|
|
|
import com.dairymoose.modernlife.blocks.CanvasBlock;
|
|
import com.dairymoose.modernlife.core.ModernLifeConfig;
|
|
import com.dairymoose.modernlife.tileentities.AlarmClockBlockEntity;
|
|
import com.mojang.blaze3d.systems.RenderSystem;
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
import com.mojang.math.Vector3f;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.gui.GuiComponent;
|
|
import net.minecraft.client.renderer.MultiBufferSource;
|
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/renderer/tileentity/AlarmClockBlockEntityRenderer.class */
|
|
public class AlarmClockBlockEntityRenderer implements BlockEntityRenderer<AlarmClockBlockEntity> {
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
int currentPos = 0;
|
|
private PoseStack currentStack = null;
|
|
private static final int X_START = 44;
|
|
private static final int X_INCREMENT = -13;
|
|
private static final int Y_START = 13;
|
|
private static final int MID_X_ADJUST = 2;
|
|
private static final int MID_Y_ADJUST = -1;
|
|
private static final int COLON_GAP = -4;
|
|
private static final int COLON_X = 27;
|
|
private static final int COLON_Y = 13;
|
|
private static final int MOON_X = 54;
|
|
private static final int MOON_Y = 3;
|
|
private static final int PM_X = 51;
|
|
private static final int PM_Y = 20;
|
|
private static final long TIME_DIFFERENCE = 6000;
|
|
private static final long TIME_FULL_DAY = 24000;
|
|
private static final int TIME_UNITS_PER_MINUTE = 1000;
|
|
|
|
public AlarmClockBlockEntityRenderer(BlockEntityRendererProvider.Context ctx) {
|
|
}
|
|
|
|
private void resetCurrentPos() {
|
|
this.currentPos = 0;
|
|
}
|
|
|
|
private void renderRect(PoseStack matrixStack, int x, int y, int width, int height) {
|
|
int r = 249;
|
|
int g = 8;
|
|
int b = 40;
|
|
Integer alarmClockTextColorR = (Integer) ModernLifeConfig.CLIENT.alarmClockTextColorR.get();
|
|
Integer alarmClockTextColorG = (Integer) ModernLifeConfig.CLIENT.alarmClockTextColorG.get();
|
|
Integer alarmClockTextColorB = (Integer) ModernLifeConfig.CLIENT.alarmClockTextColorB.get();
|
|
if (alarmClockTextColorR != null) {
|
|
r = alarmClockTextColorR.intValue();
|
|
}
|
|
if (alarmClockTextColorG != null) {
|
|
g = alarmClockTextColorG.intValue();
|
|
}
|
|
if (alarmClockTextColorB != null) {
|
|
b = alarmClockTextColorB.intValue();
|
|
}
|
|
int combinedColor = (255 << 24) | (r << 16) | (g << 8) | b;
|
|
RenderSystem.setShaderColor(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f);
|
|
GuiComponent.fill(matrixStack, x + width, y + height, x, y, combinedColor);
|
|
}
|
|
|
|
private int getNewX() {
|
|
int newX = X_START + (this.currentPos * X_INCREMENT);
|
|
if (this.currentPos >= MID_X_ADJUST) {
|
|
newX += COLON_GAP;
|
|
}
|
|
return newX;
|
|
}
|
|
|
|
private int getNewY() {
|
|
return 13;
|
|
}
|
|
|
|
private void renderTopRight() {
|
|
int newX = getNewX();
|
|
int newY = getNewY();
|
|
renderRect(this.currentStack, newX, newY, MID_X_ADJUST, 8);
|
|
}
|
|
|
|
private void renderTop() {
|
|
int newX = getNewX();
|
|
int newY = getNewY();
|
|
renderRect(this.currentStack, newX + MID_X_ADJUST, newY + 9 + MID_Y_ADJUST, 7, MID_X_ADJUST);
|
|
}
|
|
|
|
private void renderTopLeft() {
|
|
int newX = getNewX();
|
|
int newY = getNewY();
|
|
renderRect(this.currentStack, newX + 9, newY, MID_X_ADJUST, 8);
|
|
}
|
|
|
|
private void renderMid() {
|
|
int newX = getNewX();
|
|
int newY = getNewY();
|
|
renderRect(this.currentStack, newX + MID_X_ADJUST, newY + MID_Y_ADJUST, 7, MID_X_ADJUST);
|
|
}
|
|
|
|
private void renderBottomRight() {
|
|
int newX = getNewX();
|
|
int newY = getNewY();
|
|
renderRect(this.currentStack, newX, newY - 9, MID_X_ADJUST, 8);
|
|
}
|
|
|
|
private void renderBottom() {
|
|
int newX = getNewX();
|
|
int newY = getNewY();
|
|
renderRect(this.currentStack, newX + MID_X_ADJUST, (newY - 9) + MID_Y_ADJUST, 7, MID_X_ADJUST);
|
|
}
|
|
|
|
private void renderBottomLeft() {
|
|
int newX = getNewX();
|
|
int newY = getNewY();
|
|
renderRect(this.currentStack, newX + 9, newY - 9, MID_X_ADJUST, 8);
|
|
}
|
|
|
|
private void renderColon() {
|
|
renderRect(this.currentStack, 27, 13, MID_X_ADJUST, MID_X_ADJUST);
|
|
renderRect(this.currentStack, 27, 9, MID_X_ADJUST, MID_X_ADJUST);
|
|
}
|
|
|
|
private void renderMoon() {
|
|
renderRect(this.currentStack, MOON_X, 3, 1, 1);
|
|
renderRect(this.currentStack, 53, 3, 1, 1);
|
|
renderRect(this.currentStack, 55, MID_X_ADJUST, 1, 1);
|
|
renderRect(this.currentStack, 55, 1, 1, 1);
|
|
renderRect(this.currentStack, 52, MID_X_ADJUST, 1, 1);
|
|
renderRect(this.currentStack, 52, 1, 1, 1);
|
|
renderRect(this.currentStack, MOON_X, 0, 1, 1);
|
|
renderRect(this.currentStack, 53, 0, 1, 1);
|
|
}
|
|
|
|
private void renderPmDot() {
|
|
renderRect(this.currentStack, 51, 20, 4, 4);
|
|
}
|
|
|
|
private void renderNumber(int no) {
|
|
if (no == 1) {
|
|
renderTopRight();
|
|
renderBottomRight();
|
|
} else if (no == MID_X_ADJUST) {
|
|
renderTop();
|
|
renderTopRight();
|
|
renderMid();
|
|
renderBottomLeft();
|
|
renderBottom();
|
|
} else if (no == 3) {
|
|
renderTop();
|
|
renderTopRight();
|
|
renderMid();
|
|
renderBottomRight();
|
|
renderBottom();
|
|
} else if (no == 4) {
|
|
renderTopLeft();
|
|
renderTopRight();
|
|
renderMid();
|
|
renderBottomRight();
|
|
} else if (no == 5) {
|
|
renderTop();
|
|
renderTopLeft();
|
|
renderMid();
|
|
renderBottomRight();
|
|
renderBottom();
|
|
} else if (no == 6) {
|
|
renderTop();
|
|
renderTopLeft();
|
|
renderMid();
|
|
renderBottomRight();
|
|
renderBottom();
|
|
renderBottomLeft();
|
|
} else if (no == 7) {
|
|
renderTop();
|
|
renderTopRight();
|
|
renderBottomRight();
|
|
} else if (no == 8) {
|
|
renderTopLeft();
|
|
renderTop();
|
|
renderTopRight();
|
|
renderMid();
|
|
renderBottom();
|
|
renderBottomLeft();
|
|
renderBottomRight();
|
|
} else if (no == 9) {
|
|
renderTopLeft();
|
|
renderTop();
|
|
renderTopRight();
|
|
renderMid();
|
|
renderBottom();
|
|
renderBottomRight();
|
|
} else if (no == 0) {
|
|
renderTopLeft();
|
|
renderTop();
|
|
renderTopRight();
|
|
renderBottom();
|
|
renderBottomLeft();
|
|
renderBottomRight();
|
|
}
|
|
this.currentPos++;
|
|
}
|
|
|
|
private void renderTime(int hour, int minute) {
|
|
int hourLeftDigit = hour / 10;
|
|
int hourRightDigit = hour % 10;
|
|
if (hourLeftDigit > 0) {
|
|
renderNumber(hourLeftDigit);
|
|
} else {
|
|
this.currentPos++;
|
|
}
|
|
renderNumber(hourRightDigit);
|
|
int minuteLeftDigit = minute / 10;
|
|
int minuteRightDigit = minute % 10;
|
|
renderNumber(minuteLeftDigit);
|
|
renderNumber(minuteRightDigit);
|
|
renderColon();
|
|
}
|
|
|
|
/* renamed from: com.dairymoose.modernlife.renderer.tileentity.AlarmClockBlockEntityRenderer$1 */
|
|
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/renderer/tileentity/AlarmClockBlockEntityRenderer$1.class */
|
|
public static /* synthetic */ class C01411 {
|
|
static final /* synthetic */ int[] $SwitchMap$net$minecraft$core$Direction = new int[Direction.values().length];
|
|
|
|
static {
|
|
try {
|
|
$SwitchMap$net$minecraft$core$Direction[Direction.EAST.ordinal()] = 1;
|
|
} catch (NoSuchFieldError e) {
|
|
}
|
|
try {
|
|
$SwitchMap$net$minecraft$core$Direction[Direction.WEST.ordinal()] = AlarmClockBlockEntityRenderer.MID_X_ADJUST;
|
|
} catch (NoSuchFieldError e2) {
|
|
}
|
|
try {
|
|
$SwitchMap$net$minecraft$core$Direction[Direction.NORTH.ordinal()] = 3;
|
|
} catch (NoSuchFieldError e3) {
|
|
}
|
|
try {
|
|
$SwitchMap$net$minecraft$core$Direction[Direction.SOUTH.ordinal()] = 4;
|
|
} catch (NoSuchFieldError e4) {
|
|
}
|
|
}
|
|
}
|
|
|
|
public void render(AlarmClockBlockEntity tileEntity, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int lightmap, int i1) {
|
|
switch (C01411.$SwitchMap$net$minecraft$core$Direction[tileEntity.getBlockState().getValue(CanvasBlock.FACING).ordinal()]) {
|
|
case 1:
|
|
matrixStack.mulPose(Vector3f.YP.rotationDegrees(270.0f));
|
|
break;
|
|
case MID_X_ADJUST /* 2 */:
|
|
matrixStack.mulPose(Vector3f.YP.rotationDegrees(90.0f));
|
|
matrixStack.translate(-1.0d, 0.0d, 1.0d);
|
|
break;
|
|
case 3:
|
|
matrixStack.mulPose(Vector3f.YP.rotationDegrees(0.0f));
|
|
matrixStack.translate(0.0d, 0.0d, 1.0d);
|
|
break;
|
|
case 4:
|
|
matrixStack.mulPose(Vector3f.YP.rotationDegrees(180.0f));
|
|
matrixStack.translate(-1.0d, 0.0d, 0.0d);
|
|
break;
|
|
}
|
|
matrixStack.translate(0.0d, 0.0d, -0.8149999976158142d);
|
|
matrixStack.scale(0.01f, 0.01f, 0.01f);
|
|
matrixStack.translate(10.0d, 0.0d, 0.0d);
|
|
matrixStack.translate(11.800000190734863d, 3.200000047683716d, 0.0d);
|
|
RenderSystem.enableDepthTest();
|
|
this.currentStack = matrixStack;
|
|
resetCurrentPos();
|
|
long dayTime = Minecraft.getInstance().level.getDayTime();
|
|
long currentTime = (dayTime + TIME_DIFFERENCE) % TIME_FULL_DAY;
|
|
long displayTime = currentTime;
|
|
Boolean config24Hours = (Boolean) ModernLifeConfig.CLIENT.clock24HoursMode.get();
|
|
if ((config24Hours == null || !config24Hours.booleanValue()) && currentTime >= 12000) {
|
|
renderPmDot();
|
|
displayTime = currentTime - 12000;
|
|
}
|
|
Boolean configMoonIndicator = (Boolean) ModernLifeConfig.CLIENT.moonIndicator.get();
|
|
if (configMoonIndicator != null && configMoonIndicator.booleanValue() && (currentTime >= 18542 || currentTime < 5460)) {
|
|
renderMoon();
|
|
}
|
|
int hour = ((int) displayTime) / TIME_UNITS_PER_MINUTE;
|
|
if (hour == 0) {
|
|
hour = 12;
|
|
}
|
|
int minute = (60 * (((int) displayTime) % TIME_UNITS_PER_MINUTE)) / TIME_UNITS_PER_MINUTE;
|
|
renderTime(hour, minute);
|
|
}
|
|
}
|