Compare commits

..
1 Commits
Author SHA1 Message Date
glowredmanandGlease bf5dd5566b Add Localization (#36)
This adds some missing localizations for unlocalized names returned by
the ItemStack-insensitive version of `Item.getUnlocalizedName()`.
Relevant for the Item/Block stats introduced in
https://github.com/GTNewHorizons/Hodgepodge/pull/398.

---------

Co-authored-by: Glease <[email protected]>
2025-01-02 11:40:59 +08:00
5 changed files with 14 additions and 53 deletions

No files matched your search

@@ -25,8 +25,6 @@ import com.gtnewhorizon.structurelib.gui.GuiScrollableList.IGuiScreen;
public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen { public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen {
private static final String I18N_PREFIX = "item.structurelib.constructableTrigger.gui.";
private static final int ADD_BTN = 0; private static final int ADD_BTN = 0;
private static final int UNSET_BTN = 1; private static final int UNSET_BTN = 1;
private static final int WIPE_BTN = 2; private static final int WIPE_BTN = 2;
@@ -224,29 +222,10 @@ public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen
return buttonList; return buttonList;
} }
private boolean isMouseOverValue() {
int mx = Mouse.getEventX() * this.width / this.mc.displayWidth;
int my = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
return mx >= value.xPosition && mx < value.xPosition + value.width
&& my >= value.yPosition
&& my < value.yPosition + value.height;
}
@Override @Override
public void handleMouseInput() { public void handleMouseInput() {
int delta = Mouse.getEventDWheel(); int delta = Mouse.getEventDWheel();
if (delta != 0) { if (delta != 0) list.handleDWheel(delta);
if (isMouseOverValue()) {
if (delta > 0) {
value.setText(String.valueOf(getValue() + 1));
} else {
value.setText(String.valueOf(Math.max(getValue() - 1, 1)));
}
} else {
list.handleDWheel(delta);
}
}
super.handleMouseInput(); super.handleMouseInput();
} }
@@ -294,26 +273,27 @@ public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen
// STACKOVERFLOW! // STACKOVERFLOW!
String keyText = key.getText(); String keyText = key.getText();
boolean existing = !StringUtils.isEmpty(keyText) && ChannelDataAccessor.hasSubChannel(trigger, keyText); boolean existing = !StringUtils.isEmpty(keyText) && ChannelDataAccessor.hasSubChannel(trigger, keyText);
getButtonList().get(ADD_BTN).displayString = existing ? I18n.format(I18N_PREFIX + "set") getButtonList().get(ADD_BTN).displayString = existing
: I18n.format(I18N_PREFIX + "add"); ? I18n.format("item.structurelib.constructableTrigger.gui.set")
getButtonList().get(ADD_BTN).enabled = !StringUtils.isBlank(value.getText()) : I18n.format("item.structurelib.constructableTrigger.gui.add");
&& Integer.parseInt(value.getText()) > 0; getButtonList().get(ADD_BTN).enabled = !StringUtils.isBlank(value.getText());
getButtonList().get(UNSET_BTN).enabled = existing && !StringUtils.isBlank(value.getText()); getButtonList().get(UNSET_BTN).enabled = existing && !StringUtils.isBlank(value.getText());
if (ChannelDataAccessor.hasSubChannel(trigger, SHOW_ERROR_CHANNEL)) { if (ChannelDataAccessor.hasSubChannel(trigger, SHOW_ERROR_CHANNEL)) {
getButtonList().get(SHOW_ERROR_BTN).displayString = I18n.format(I18N_PREFIX + "error.hide"); getButtonList().get(SHOW_ERROR_BTN).displayString = "Hide Errors";
} else { } else {
getButtonList().get(SHOW_ERROR_BTN).displayString = I18n.format(I18N_PREFIX + "error.show"); getButtonList().get(SHOW_ERROR_BTN).displayString = "Show Errors";
} }
// this button only exists if GT is loaded. // this button only exists if GT is loaded.
if (StructureLib.isGTLoaded) { if (StructureLib.isGTLoaded) {
if (ChannelDataAccessor.hasSubChannel(trigger, GT_NO_HATCH_CHANNEL)) { if (ChannelDataAccessor.hasSubChannel(trigger, GT_NO_HATCH_CHANNEL)) {
getButtonList().get(GT_NO_HATCH_BTN).displayString = I18n.format(I18N_PREFIX + "gt_no_hatch.disable"); getButtonList().get(GT_NO_HATCH_BTN).displayString = "Hatches";
} else { } else {
getButtonList().get(GT_NO_HATCH_BTN).displayString = I18n.format(I18N_PREFIX + "gt_no_hatch.enable"); getButtonList().get(GT_NO_HATCH_BTN).displayString = "No Hatch";
} }
} }
} }
private int getValue() { private int getValue() {
@@ -17,9 +17,6 @@ import org.lwjgl.input.Keyboard;
import com.gtnewhorizon.structurelib.StructureLib; import com.gtnewhorizon.structurelib.StructureLib;
import com.gtnewhorizon.structurelib.alignment.constructable.ChannelDataAccessor; import com.gtnewhorizon.structurelib.alignment.constructable.ChannelDataAccessor;
import com.gtnewhorizon.structurelib.alignment.constructable.ConstructableUtility; import com.gtnewhorizon.structurelib.alignment.constructable.ConstructableUtility;
import com.gtnewhorizon.structurelib.gui.GuiScreenConfigureChannels;
import cpw.mods.fml.common.FMLCommonHandler;
public class ItemConstructableTrigger extends Item { public class ItemConstructableTrigger extends Item {
@@ -35,7 +32,7 @@ public class ItemConstructableTrigger extends Item {
if (player.isSneaking()) { if (player.isSneaking()) {
StructureLib.instance().proxy().displayConfigGUI("registries"); StructureLib.instance().proxy().displayConfigGUI("registries");
} else { } else {
FMLCommonHandler.instance().showGuiScreen(new GuiScreenConfigureChannels(stack)); player.openGui(StructureLib.instance(), 0, world, player.inventory.currentItem, 0, 0);
} }
} }
return super.onItemRightClick(stack, world, player); return super.onItemRightClick(stack, world, player);
@@ -1,7 +1,5 @@
package com.gtnewhorizon.structurelib.structure; package com.gtnewhorizon.structurelib.structure;
import static com.gtnewhorizon.structurelib.StructureLib.LOGGER;
import static com.gtnewhorizon.structurelib.StructureLib.PANIC_MODE;
import static java.lang.Integer.MIN_VALUE; import static java.lang.Integer.MIN_VALUE;
import java.util.Arrays; import java.util.Arrays;
@@ -588,7 +586,7 @@ public class StructureUtility {
TIER current = getter.apply(t); TIER current = getter.apply(t);
if (Objects.equals(notSet, current)) { if (Objects.equals(notSet, current)) {
if (Objects.equals(notSet, tier)) { if (Objects.equals(notSet, tier)) {
if (PANIC_MODE) { if (StructureLib.PANIC_MODE) {
throw new AssertionError("tierExtractor should never return notSet: " + notSet); throw new AssertionError("tierExtractor should never return notSet: " + notSet);
} else { } else {
StructureLib.LOGGER.error("#########################################"); StructureLib.LOGGER.error("#########################################");
@@ -1350,14 +1348,6 @@ public class StructureUtility {
if (block == null || defaultBlock == null) { if (block == null || defaultBlock == null) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
if (block == Blocks.air) {
if (PANIC_MODE) {
throw new IllegalArgumentException("ofBlock() does not accept air. use isAir() instead");
} else {
LOGGER.warn("ofBlock() does not accept air. use isAir() instead");
return isAir();
}
}
if (block instanceof ICustomBlockSetting) { if (block instanceof ICustomBlockSetting) {
return new IStructureElement<T>() { return new IStructureElement<T>() {
@@ -1,3 +1,4 @@
tile.structurelib.blockhint.name=Hint
tile.structurelib.blockhint.0.name=Hint 1 dot tile.structurelib.blockhint.0.name=Hint 1 dot
tile.structurelib.blockhint.1.name=Hint 2 dots tile.structurelib.blockhint.1.name=Hint 2 dots
tile.structurelib.blockhint.2.name=Hint 3 dots tile.structurelib.blockhint.2.name=Hint 3 dots
@@ -35,10 +36,6 @@ item.structurelib.constructableTrigger.gui.add=Add
item.structurelib.constructableTrigger.gui.set=Set item.structurelib.constructableTrigger.gui.set=Set
item.structurelib.constructableTrigger.gui.unset=Unset item.structurelib.constructableTrigger.gui.unset=Unset
item.structurelib.constructableTrigger.gui.wipe=§4Wipe item.structurelib.constructableTrigger.gui.wipe=§4Wipe
item.structurelib.constructableTrigger.gui.error.show=Show Errors
item.structurelib.constructableTrigger.gui.error.hide=Hide Errors
item.structurelib.constructableTrigger.gui.gt_no_hatch.enable=No Hatch
item.structurelib.constructableTrigger.gui.gt_no_hatch.disable=Hatches
structurelib.autoplace.built_stat=Built %s blocks structurelib.autoplace.built_stat=Built %s blocks
structurelib.autoplace.complete=§aThis multiblock has completed! structurelib.autoplace.complete=§aThis multiblock has completed!
@@ -1,3 +1,4 @@
tile.structurelib.blockhint.name=提示方块
tile.structurelib.blockhint.0.name=提示方块:1号 tile.structurelib.blockhint.0.name=提示方块:1号
tile.structurelib.blockhint.1.name=提示方块:2号 tile.structurelib.blockhint.1.name=提示方块:2号
tile.structurelib.blockhint.2.name=提示方块:3号 tile.structurelib.blockhint.2.name=提示方块:3号
@@ -35,10 +36,6 @@ item.structurelib.constructableTrigger.gui.add=添加
item.structurelib.constructableTrigger.gui.set=替换 item.structurelib.constructableTrigger.gui.set=替换
item.structurelib.constructableTrigger.gui.unset=删除 item.structurelib.constructableTrigger.gui.unset=删除
item.structurelib.constructableTrigger.gui.wipe=§4全部清空 item.structurelib.constructableTrigger.gui.wipe=§4全部清空
item.structurelib.constructableTrigger.gui.error.show=显示结构错误
item.structurelib.constructableTrigger.gui.error.hide=隐藏结构错误
item.structurelib.constructableTrigger.gui.gt_no_hatch.enable=跳过舱室
item.structurelib.constructableTrigger.gui.gt_no_hatch.disable=放置舱室
structurelib.autoplace.built_stat=已放置 %s 个方块 structurelib.autoplace.built_stat=已放置 %s 个方块
structurelib.autoplace.complete=§a这个多方块结构已经完成自动搭建! structurelib.autoplace.complete=§a这个多方块结构已经完成自动搭建!