Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/channel-configure' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Dec 14, 2024
2 parents b9d0143 + 2bde67b commit ece891f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

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 UNSET_BTN = 1;
private static final int WIPE_BTN = 2;
Expand Down Expand Up @@ -222,10 +224,29 @@ private List<GuiButton> getButtonList() {
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
public void handleMouseInput() {
int delta = Mouse.getEventDWheel();
if (delta != 0) list.handleDWheel(delta);
if (delta != 0) {
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();
}

Expand Down Expand Up @@ -273,27 +294,26 @@ private void updateButtons() {
// STACKOVERFLOW!
String keyText = key.getText();
boolean existing = !StringUtils.isEmpty(keyText) && ChannelDataAccessor.hasSubChannel(trigger, keyText);
getButtonList().get(ADD_BTN).displayString = existing
? I18n.format("item.structurelib.constructableTrigger.gui.set")
: I18n.format("item.structurelib.constructableTrigger.gui.add");
getButtonList().get(ADD_BTN).enabled = !StringUtils.isBlank(value.getText());
getButtonList().get(ADD_BTN).displayString = existing ? I18n.format(I18N_PREFIX + "set")
: I18n.format(I18N_PREFIX + "add");
getButtonList().get(ADD_BTN).enabled = !StringUtils.isBlank(value.getText())
&& Integer.parseInt(value.getText()) > 0;
getButtonList().get(UNSET_BTN).enabled = existing && !StringUtils.isBlank(value.getText());

if (ChannelDataAccessor.hasSubChannel(trigger, SHOW_ERROR_CHANNEL)) {
getButtonList().get(SHOW_ERROR_BTN).displayString = "Hide Errors";
getButtonList().get(SHOW_ERROR_BTN).displayString = I18n.format(I18N_PREFIX + "error.hide");
} else {
getButtonList().get(SHOW_ERROR_BTN).displayString = "Show Errors";
getButtonList().get(SHOW_ERROR_BTN).displayString = I18n.format(I18N_PREFIX + "error.show");
}

// this button only exists if GT is loaded.
if (StructureLib.isGTLoaded) {
if (ChannelDataAccessor.hasSubChannel(trigger, GT_NO_HATCH_CHANNEL)) {
getButtonList().get(GT_NO_HATCH_BTN).displayString = "Hatches";
getButtonList().get(GT_NO_HATCH_BTN).displayString = I18n.format(I18N_PREFIX + "gt_no_hatch.disable");
} else {
getButtonList().get(GT_NO_HATCH_BTN).displayString = "No Hatch";
getButtonList().get(GT_NO_HATCH_BTN).displayString = I18n.format(I18N_PREFIX + "gt_no_hatch.enable");
}
}

}

private int getValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
import com.gtnewhorizon.structurelib.StructureLib;
import com.gtnewhorizon.structurelib.alignment.constructable.ChannelDataAccessor;
import com.gtnewhorizon.structurelib.alignment.constructable.ConstructableUtility;
import com.gtnewhorizon.structurelib.gui.GuiScreenConfigureChannels;

import cpw.mods.fml.common.FMLCommonHandler;

public class ItemConstructableTrigger extends Item {

Expand All @@ -32,7 +35,7 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla
if (player.isSneaking()) {
StructureLib.instance().proxy().displayConfigGUI("registries");
} else {
player.openGui(StructureLib.instance(), 0, world, player.inventory.currentItem, 0, 0);
FMLCommonHandler.instance().showGuiScreen(new GuiScreenConfigureChannels(stack));
}
}
return super.onItemRightClick(stack, world, player);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
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 java.util.Arrays;
Expand Down Expand Up @@ -586,7 +588,7 @@ public static <T, TIER> IStructureElementCheckOnly<T> ofBlocksTiered(ITierConver
TIER current = getter.apply(t);
if (Objects.equals(notSet, current)) {
if (Objects.equals(notSet, tier)) {
if (StructureLib.PANIC_MODE) {
if (PANIC_MODE) {
throw new AssertionError("tierExtractor should never return notSet: " + notSet);
} else {
StructureLib.LOGGER.error("#########################################");
Expand Down Expand Up @@ -1348,6 +1350,14 @@ public static <T> IStructureElement<T> ofBlock(Block block, int meta, Block defa
if (block == null || defaultBlock == null) {
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) {
return new IStructureElement<T>() {

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/structurelib/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ item.structurelib.constructableTrigger.gui.add=Add
item.structurelib.constructableTrigger.gui.set=Set
item.structurelib.constructableTrigger.gui.unset=Unset
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.complete=§aThis multiblock has completed!
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/structurelib/lang/zh_CN.lang
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ item.structurelib.constructableTrigger.gui.add=添加
item.structurelib.constructableTrigger.gui.set=替换
item.structurelib.constructableTrigger.gui.unset=删除
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.complete=§a这个多方块结构已经完成自动搭建!
Expand Down

0 comments on commit ece891f

Please sign in to comment.