Skip to content

Commit

Permalink
try to improve robustness of channels gui
Browse files Browse the repository at this point in the history
Signed-off-by: Glease <[email protected]>
  • Loading branch information
Glease committed Dec 14, 2024
1 parent 43fc39c commit 27be10d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private void updateButtons() {
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).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)) {
Expand All @@ -293,7 +293,6 @@ private void updateButtons() {
getButtonList().get(GT_NO_HATCH_BTN).displayString = "No Hatch";
}
}

}

private int getValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import java.util.List;

import com.gtnewhorizon.structurelib.gui.GuiScreenConfigureChannels;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
Expand All @@ -32,7 +34,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

0 comments on commit 27be10d

Please sign in to comment.