Skip to content

Commit

Permalink
Merge branch '1.20' of https://github.com/TeamMoegMC/FrostedHeart int…
Browse files Browse the repository at this point in the history
…o 1.20
  • Loading branch information
khjxiaogu committed Jan 14, 2025
2 parents 1f33592 + 9b8431d commit 1a1d665
Show file tree
Hide file tree
Showing 103 changed files with 3,083 additions and 997 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"block.frostedheart.copper_gravel": "ןǝʌɐɹ⅁ ɹǝddoƆ",
"block.frostedheart.copper_sludge": "ǝbpnןS ɹǝddoƆ",
"block.frostedheart.copper_sludge_block": "ʞɔoןᗺ ǝbpnןS ɹǝddoƆ",
"block.frostedheart.creative_heater": "ɹǝʇɐǝH ǝʌıʇɐǝɹƆ",
"block.frostedheart.debug_heater": "ɹǝʇɐǝH bnqǝᗡ",
"block.frostedheart.deepslate_halite_ore": "ǝɹO ǝʇıןɐH ǝʇɐןsdǝǝᗡ",
"block.frostedheart.deepslate_lead_ore": "ǝɹO pɐǝꞀ ǝʇɐןsdǝǝᗡ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"block.frostedheart.copper_gravel": "Copper Gravel",
"block.frostedheart.copper_sludge": "Copper Sludge",
"block.frostedheart.copper_sludge_block": "Copper Sludge Block",
"block.frostedheart.creative_heater": "Creative Heater",
"block.frostedheart.debug_heater": "Debug Heater",
"block.frostedheart.deepslate_halite_ore": "Deepslate Halite Ore",
"block.frostedheart.deepslate_lead_ore": "Deepslate Lead Ore",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"frostedheart:relic_chest",
"frostedheart:heat_incubator",
"frostedheart:debug_heater",
"frostedheart:creative_heater",
"frostedheart:charger",
"frostedheart:oil_burner",
"frostedheart:gas_vent",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"values": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"values": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"values": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"values": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"values": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"minecraft:copper_ingot"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"minecraft:iron_ingot"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"values": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"values": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"values": [
"minecraft:cobblestone",
"minecraft:stone",
"minecraft:bedrock"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"values": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"values": []
}
1 change: 1 addition & 0 deletions src/main/java/com/teammoeg/frostedheart/FHMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public FHMain() {
FHItems.init();
FHProps.init();
FHBlocks.init();
FHBlockEntityTypes.init();
FHBiomes.init();
FHMultiblocks.Multiblock.init();
FHPredicates.init();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.teammoeg.frostedheart.base.client.gui.widget;

import com.mojang.blaze3d.vertex.PoseStack;
import com.teammoeg.frostedheart.util.client.FHColorHelper;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.NotNull;

public class ColorEditbox extends EditBox {
private static final String PREFIX = "0x";
private static final String PREFIX_WITH_ALPHA = "0xFF";
protected final Font font;
protected final boolean withAlpha;

public ColorEditbox(Font font, int x, int y, int width, int height, Component message) {
this(font, x, y, width, height, message, true, 0);
}

public ColorEditbox(Font font, int x, int y, int width, int height, Component message, boolean withAlpha, int colorValue) {
super(font, x, y, width, height, message);
this.font = font;
this.withAlpha = withAlpha;
setValue(colorValue);
setMaxLength(withAlpha ? 6 : 8);
setResponder(s -> {
try {
setTextColor(FHColorHelper.WHITE);
Integer.parseUnsignedInt(s, 16);
} catch (NumberFormatException e) {
setTextColor(FHColorHelper.RED);
}
});
}

@Override
public void renderWidget(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
super.renderWidget(graphics, mouseX, mouseY, partialTick);
graphics.drawString(font, getPrefix(), getX()-2-font.width(getPrefix()), getY()+(getHeight()/2)-4, 0xFFFFFFFF);

PoseStack pose = graphics.pose();
pose.pushPose();
pose.translate(1, 1, 0);
graphics.fill(getX()+getWidth()+2, getY(), getX()+getWidth()+getHeight()+2, getY()+getHeight(), FHColorHelper.makeDark(getColorValue(), 0.25F));
pose.translate(-1, -1, 0);
graphics.fill(getX()+getWidth()+2, getY(), getX()+getWidth()+getHeight()+2, getY()+getHeight(), getColorValue());
pose.popPose();
}

public int getColorValue() {
try {
return withAlpha ? FHColorHelper.setAlpha(Integer.parseUnsignedInt(getValue(), 16), 1F) : Integer.parseUnsignedInt(getValue(), 16);
} catch (NumberFormatException e) {
return FHColorHelper.RED;
}
}

public void setValue(int value) {
if (withAlpha) {
setValue(FHColorHelper.toHexString(value).substring(2).toUpperCase());
} else {
setValue(FHColorHelper.toHexString(value).toUpperCase());
}
}

private String getPrefix() {
return withAlpha ? PREFIX_WITH_ALPHA : PREFIX;
}

@Override
public @NotNull String getValue() {
return (withAlpha ? "FF" : "") + super.getValue();
}
}
Original file line number Diff line number Diff line change
@@ -1,82 +1,78 @@
package com.teammoeg.frostedheart.content.tips.client.gui.widget;
package com.teammoeg.frostedheart.base.client.gui.widget;

import com.mojang.blaze3d.vertex.PoseStack;
import com.teammoeg.frostedheart.FHMain;
import com.teammoeg.frostedheart.util.client.ClientUtils;
import com.teammoeg.frostedheart.util.client.FHColorHelper;
import com.teammoeg.frostedheart.util.client.FHGuiHelper;
import com.teammoeg.frostedheart.util.client.RawMouseHelper;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraftforge.common.util.Size2i;
import org.jetbrains.annotations.NotNull;

public class IconButton extends Button {
public static final ResourceLocation ICON_LOCATION = new ResourceLocation(FHMain.MODID, "textures/gui/hud_icon.png");
public static final ResourceLocation ICON_LOCATION = FHMain.rl("textures/gui/hud/flat_icon.png");
public static final int TEXTURE_HEIGHT = 80;
public static final int TEXTURE_WIDTH = 80;
public static final int ICON_SIZE = 10;

public Icon currentIcon;
public final Icon icon;
public int color;
// 为什么是int? 混素达咩(
private int scale;

/**
* @param icon 按钮的图标 {@link Icon}
*/
public IconButton(int x, int y, Icon icon, int color, Component title, OnPress pressedAction) {
super(x, y, 10, 10, title, pressedAction, Button.DEFAULT_NARRATION);
this(x, y, icon, color, 1, title, pressedAction);
}

public IconButton(int x, int y, Icon icon, int color, int scale, Component title, OnPress pressedAction) {
super(x, y, icon.size.width, icon.size.height, title, pressedAction, Button.DEFAULT_NARRATION);
this.scale = Mth.clamp(scale, 1, Integer.MAX_VALUE);
width *= scale;
height *= scale;
this.color = color;
this.currentIcon = icon;
this.icon = icon;
}

@Override
public void renderWidget(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
if (isHoveredOrFocused()) {
graphics.fill(getX(), getY(), getX()+width, getY()+height, FHColorHelper.setAlpha(color, 50));
if (!getMessage().getString().isEmpty() && isHovered()) {
graphics.fill(getX(), getY(), getX()+getWidth(), getY()+getHeight(), FHColorHelper.setAlpha(color, 50));
if (!getMessage().getString().isBlank() && isHovered()) {
int textWidth = ClientUtils.font().width(getMessage());
int renderX = getX()-textWidth+8;
if (renderX < 0) {
graphics.fill(getX(), getY()-12, getX()+2 + textWidth, getY(), FHColorHelper.setAlpha(color, 50));
graphics.fill(getX(),
getY()-12,
getX()+2 + textWidth,
getY(),
FHColorHelper.setAlpha(color, 50));
graphics.drawString(ClientUtils.font(), getMessage(), getX()+2, getY()-10, color);
} else {
graphics.fill(getX()+8 - textWidth, getY()-12, getX()+10, getY(), FHColorHelper.setAlpha(color, 50));
graphics.drawString(ClientUtils.font(), getMessage(), getX()-textWidth+width, getY()-10, color);
graphics.fill(getX()-textWidth+getWidth()-1,
getY()-12,
getX()+getWidth(),
getY(),
FHColorHelper.setAlpha(color, 50));
graphics.drawString(ClientUtils.font(), getMessage(), getX()-textWidth+getWidth(), getY()-10, color);
}
}
}

FHGuiHelper.bindTexture(ICON_LOCATION);
FHGuiHelper.blitColored(graphics.pose(), getX(), getY(), ICON_SIZE, ICON_SIZE, currentIcon.x, currentIcon.y, ICON_SIZE, ICON_SIZE, TEXTURE_WIDTH, TEXTURE_HEIGHT, color, alpha);
}

/**
* 渲染一个图标
* @param icon {@link IconButton.Icon}
* @param color 图标的颜色
*/
public static void renderIcon(PoseStack pose, Icon icon, int x, int y, int color) {
FHGuiHelper.bindTexture(ICON_LOCATION);
FHGuiHelper.blitColored(pose, x, y, ICON_SIZE, ICON_SIZE, icon.x, icon.y, ICON_SIZE, ICON_SIZE, TEXTURE_WIDTH, TEXTURE_HEIGHT, color);
FHGuiHelper.blitColored(graphics.pose(), getX(), getY(), getWidth(), getHeight(), icon.x*scale, icon.y*scale, getWidth(), getHeight(), TEXTURE_WIDTH*scale, TEXTURE_HEIGHT*scale, color, alpha);
}

/**
* 直接在屏幕中渲染一个图标按钮
* @param icon {@link IconButton.Icon}
* @param color 图标的颜色
* @param BGColor 未被选中时的背景颜色,为 0 时不显示
* @return 是否被按下
*/
public static boolean renderIconButton(GuiGraphics graphics, Icon icon, double mouseX, double mouseY, int x, int y, int color, int BGColor) {
boolean mouseIn = RawMouseHelper.isMouseIn(mouseX, mouseY, x, y, ICON_SIZE, ICON_SIZE);
if (color != 0 && mouseIn) {
graphics.fill(x, y, x+ICON_SIZE, y+ICON_SIZE, 50 << 24 | color & 0x00FFFFFF);
} else if (BGColor != 0) {
graphics.fill(x, y, x+ICON_SIZE, y+ICON_SIZE, BGColor);
}
renderIcon(graphics.pose(), icon, x, y, color);
return mouseIn && RawMouseHelper.isLeftClicked();
public void setScale(int scale) {
int w = this.width / this.scale;
int h = this.height / this.scale;
this.scale = scale;
this.width = w * scale;
this.height = h * scale;
}

public enum Icon {
Expand Down Expand Up @@ -108,12 +104,20 @@ public enum Icon {
RIGHT_SLIDE (0 ,50),
WRENCH (0 ,70);

final int x;
final int y;
public final int x;
public final int y;
public final Size2i size;

Icon(int x, int y, Size2i size) {
this.x = x;
this.y = y;
this.size = size;
}

Icon(int x, int y) {
this.x = x;
this.y = y;
this.size = new Size2i(10, 10);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.teammoeg.frostedheart.base.client.gui.widget;

import com.mojang.blaze3d.systems.RenderSystem;
import com.teammoeg.frostedheart.util.client.FHColorHelper;
import com.teammoeg.frostedheart.util.client.FHGuiHelper;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Checkbox;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
import org.jetbrains.annotations.NotNull;

public class IconCheckbox extends Checkbox {
private static final IconButton.Icon SELECTED_ICON = IconButton.Icon.CHECK;
private int scale;

public IconCheckbox(int pX, int pY, Component pMessage, boolean pSelected) {
this(pX, pY, 1, pMessage, pSelected);
}

public IconCheckbox(int pX, int pY, int scale, Component pMessage, boolean pSelected) {
super(pX, pY, SELECTED_ICON.size.width, SELECTED_ICON.size.height, pMessage, pSelected, false);
this.scale = Mth.clamp(scale, 1, Integer.MAX_VALUE);
width *= scale;
height *= scale;
}

public void setScale(int scale) {
int w = this.width / this.scale;
int h = this.height / this.scale;
this.scale = scale;
this.width = w * scale;
this.height = h * scale;
}

@Override
public void renderWidget(@NotNull GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) {
IconButton.Icon icon = selected() ? SELECTED_ICON : IconButton.Icon.CROSS;
RenderSystem.enableDepthTest();
pGuiGraphics.setColor(1.0F, 1.0F, 1.0F, this.alpha);
RenderSystem.enableBlend();
FHGuiHelper.bindTexture(IconButton.ICON_LOCATION);
FHGuiHelper.blitColored(pGuiGraphics.pose(), getX(), getY(), getWidth(), getHeight(), icon.x*scale, icon.y*scale, getWidth(), getHeight(), IconButton.TEXTURE_WIDTH*scale, IconButton.TEXTURE_HEIGHT*scale, FHColorHelper.CYAN, alpha);
pGuiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.teammoeg.frostedheart.content.research.blocks.MechCalcTileEntity;
import com.teammoeg.frostedheart.content.steamenergy.HeatPipeTileEntity;
import com.teammoeg.frostedheart.content.steamenergy.charger.ChargerTileEntity;
import com.teammoeg.frostedheart.content.steamenergy.creative.CreativeHeaterBlockEntity;
import com.teammoeg.frostedheart.content.steamenergy.debug.DebugHeaterTileEntity;
import com.teammoeg.frostedheart.content.steamenergy.fountain.FountainTileEntity;
import com.teammoeg.frostedheart.content.steamenergy.sauna.SaunaTileEntity;
Expand All @@ -60,6 +61,11 @@
import net.minecraftforge.registries.RegistryObject;

public class FHBlockEntityTypes {
public static final BlockEntityEntry<CreativeHeaterBlockEntity> CREATIVE_HEATER = REGISTRATE
.blockEntity("creative_heater", CreativeHeaterBlockEntity::new)
.validBlocks(FHBlocks.CREATIVE_HEATER)
.register();

public static final DeferredRegister<BlockEntityType<?>> REGISTER = DeferredRegister.create(
ForgeRegistries.BLOCK_ENTITY_TYPES, FHMain.MODID);
public static final RegistryObject<BlockEntityType<HeatPipeTileEntity>> HEATPIPE = REGISTER.register(
Expand Down Expand Up @@ -143,4 +149,6 @@ private static <T extends BlockEntity> Supplier<BlockEntityType<T>> makeTypeMult
return () -> new BlockEntityType<>(create, ImmutableSet.copyOf(valid.get()), null);
}

public static void init() {}

}
Loading

0 comments on commit 1a1d665

Please sign in to comment.