Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/main/java/cn/qiuye/gtmoremachine/api/item/ModularHUD.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.qiuye.gtmoremachine.api.item

import cn.qiuye.gtmoremachine.config.GTMMConfig
import cn.qiuye.gtmoremachine.config.HUDLocation

import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiGraphics
Expand Down Expand Up @@ -50,39 +51,39 @@ class ModularHUD {
val windowWidth = mc.window.guiScaledWidth
val stringWidth = this.stringWidth
return when (GTMMConfig.INSTANCE.hud.hudLocation) {
1 -> {
HUDLocation.LeftUpper -> {
val posX = 1 + hudOffsetX
val posY = 1 + hudOffsetY + (fontHeight * index)
IntIntPair.of(posX, posY)
}

2 -> {
HUDLocation.RightUpper -> {
val posX = windowWidth - stringWidth + (1 + hudOffsetX)
val posY = 1 + hudOffsetY + (fontHeight * index)
IntIntPair.of(posX, posY)
}

3 -> {
HUDLocation.LeftLower -> {
val posX = 1 + hudOffsetX
val posY = windowHeight - fontHeight * (stringAmount - index) - 1 -
hudOffsetY
IntIntPair.of(posX, posY)
}

4 -> {
HUDLocation.RightLower -> {
val posX = windowWidth - stringWidth + (1 + hudOffsetX)
val posY = windowHeight - fontHeight * (stringAmount - index) - 1 -
hudOffsetY
IntIntPair.of(posX, posY)
}

5 -> {
HUDLocation.MiddleUpper -> {
val posX = windowWidth / 2 - stringWidth / 2 + (1 + hudOffsetX)
val posY = 1 + hudOffsetY + (fontHeight * index)
IntIntPair.of(posX, posY)
}

6 -> {
HUDLocation.MiddleLower -> {
val posX = windowWidth / 2 - stringWidth / 2 + (1 + hudOffsetX)
val posY = windowHeight - fontHeight * (stringAmount - index) - 1 -
hudOffsetY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import cn.qiuye.gtmoremachine.common.block.EnergyCommunicationUnitBlock;
import cn.qiuye.gtmoremachine.common.block.EnergyCommunicationUnitBlock.EnergyCommunicationUnitPartType;
import cn.qiuye.gtmoremachine.common.data.models.GTMMModels;
import cn.qiuye.gtmoremachine.config.GTMMConfig;

import com.gregtechceu.gtceu.api.GTValues;
import com.gregtechceu.gtceu.common.data.GTMachines;
Expand Down Expand Up @@ -82,7 +81,7 @@ private static BlockEntry<EnergyCommunicationUnitBlock> createEnergyCommunicatio
public static final BlockEntry<CapacityComponentBlock> CAPACITYCOMPONENT_MAX = createCapacityComponentBlock(CapacityComponentBlockPartType.MAX);

private static BlockEntry<CapacityComponentBlock> createCapacityComponentBlock(ICapacityComponentData CapacityComponentData) {
var CapacityComponentBlock = GTMMConfig.getINSTANCE().isWirelessCapacitylimitEnable ? GTMMREGISTRATE
var CapacityComponentBlock = GTMMREGISTRATE
.block("%s_capacity_component".formatted(CapacityComponentData.getCapacityComponentName()),
p -> new CapacityComponentBlock(p, CapacityComponentData))
.lang("%s Wireless Energy Capacity Component".formatted(CapacityComponentData.getTier() == -1 ? "Empty tier" : GTValues.VNF[CapacityComponentData.getTier()]))
Expand All @@ -92,10 +91,8 @@ private static BlockEntry<CapacityComponentBlock> createCapacityComponentBlock(I
.tag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH)
.item(BlockItem::new)
.build()
.register() : null;
if (CapacityComponentBlock != null) {
GTMMAPI.WECC.put(CapacityComponentData, CapacityComponentBlock);
}
.register();
GTMMAPI.WECC.put(CapacityComponentData, CapacityComponentBlock);
return CapacityComponentBlock;
}

Expand Down
18 changes: 9 additions & 9 deletions src/main/java/cn/qiuye/gtmoremachine/config/GTMMConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ class GTMMConfig {
@Configurable.Comment(
"设置HUD显示位置",
"Sets HUD location",
"1 - 左上角 (left-upper corner)",
"2 - 右上角 (right-upper corner)",
"3 - 左下角 (left-bottom corner)",
"4 - 右下角 (right-bottom corner)",
"5 - 中上 (middle-upper corner)",
"6 - 中下 (middle-bottom corner)",
"默认值: 1",
"Default: 1",
"左上角 (left-upper corner)",
"右上角 (right-upper corner)",
"左下角 (left-bottom corner)",
"右下角 (right-bottom corner)",
"中上 (middle-upper corner)",
"中下 (middle-bottom corner)",
"默认值: left-upper",
"Default: left-upper",
)
@Configurable.Range(min = 1, max = 6)
@JvmField
var hudLocation: Int = 1
var hudLocation: HUDLocation = HUDLocation.LeftUpper

@Configurable
@Configurable.Comment(
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/cn/qiuye/gtmoremachine/config/HUDLocation.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cn.qiuye.gtmoremachine.config

enum class HUDLocation {

LeftUpper,
RightUpper,
LeftLower,
RightLower,
MiddleUpper,
MiddleLower,
}