linear cost first gui iteration

This commit is contained in:
alexcrea 2025-07-04 16:19:42 +02:00
parent 8f3c721820
commit 8914369d38
Signed by: alexcrea
GPG key ID: E346CD16413450E3

View file

@ -43,6 +43,7 @@ public class CustomRecipeSubSettingGui extends MappedToListSubSettingGui {
Pattern pattern = new Pattern( Pattern pattern = new Pattern(
GuiSharedConstant.EMPTY_GUI_FULL_LINE, GuiSharedConstant.EMPTY_GUI_FULL_LINE,
"01203450D", "01203450D",
"0ab000000",
"B00000000" "B00000000"
); );
this.pane = new PatternPane(0, 0, 9, 3, pattern); this.pane = new PatternPane(0, 0, 9, 3, pattern);
@ -51,11 +52,16 @@ public class CustomRecipeSubSettingGui extends MappedToListSubSettingGui {
prepareStaticValues(); prepareStaticValues();
} }
BoolSettingsGui.BoolSettingFactory exactCountFactory; private BoolSettingsGui.BoolSettingFactory exactCountFactory;
IntSettingsGui.IntSettingFactory xpCostFactory; private BoolSettingsGui.BoolSettingFactory removeExactLinearXpFactory;
ItemSettingGui.ItemSettingFactory leftItemFactory; private GuiItem noRemoveExactLinearXp;
ItemSettingGui.ItemSettingFactory rightItemFactory;
ItemSettingGui.ItemSettingFactory resultItemFactory; private IntSettingsGui.IntSettingFactory levelCostFactory;
private IntSettingsGui.IntSettingFactory linearXpCostFactory;
private ItemSettingGui.ItemSettingFactory leftItemFactory;
private ItemSettingGui.ItemSettingFactory rightItemFactory;
private ItemSettingGui.ItemSettingFactory resultItemFactory;
private void prepareStaticValues() { private void prepareStaticValues() {
@ -74,19 +80,38 @@ public class CustomRecipeSubSettingGui extends MappedToListSubSettingGui {
this.pane.bindItem('D', new GuiItem(deleteItem, GuiGlobalActions.openGuiAction(createDeleteGui()), CustomAnvil.instance)); this.pane.bindItem('D', new GuiItem(deleteItem, GuiGlobalActions.openGuiAction(createDeleteGui()), CustomAnvil.instance));
// Displayed item will be updated later // Displayed item will be updated later
IntRange costRange = AnvilCustomRecipe.Companion.getXP_COST_CONFIG_RANGE(); IntRange costRange = AnvilCustomRecipe.Companion.getXP_COST_CONFIG_RANGE();
this.exactCountFactory = new BoolSettingsGui.BoolSettingFactory("§8Exact count ?", this, this.exactCountFactory = new BoolSettingsGui.BoolSettingFactory("§8Exact count ?", this,
ConfigHolder.CUSTOM_RECIPE_HOLDER, ConfigHolder.CUSTOM_RECIPE_HOLDER,
this.anvilRecipe + "." + AnvilCustomRecipe.EXACT_COUNT_CONFIG, AnvilCustomRecipe.DEFAULT_EXACT_COUNT_CONFIG); this.anvilRecipe + "." + AnvilCustomRecipe.EXACT_COUNT_CONFIG, AnvilCustomRecipe.DEFAULT_EXACT_COUNT_CONFIG);
this.xpCostFactory = new IntSettingsGui.IntSettingFactory("§8Recipe Xp Cost", this, this.removeExactLinearXpFactory = new BoolSettingsGui.BoolSettingFactory("§8Remove exact linear xp ?", this,
this.anvilRecipe +"."+AnvilCustomRecipe.XP_LEVEL_COST_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER,
this.anvilRecipe + "." + AnvilCustomRecipe.REMOVE_EXACT_XP_CONFIG, AnvilCustomRecipe.DEFAULT_REMOVE_EXACT_XP_CONFIG);
ItemStack item = new ItemStack(Material.BARRIER);
ItemMeta meta = item.getItemMeta();
assert meta != null;
meta.setDisplayName("§cRemove exact linear xp ?");
meta.setLore(Collections.singletonList("§7Not usable if linear cost is 0"));
item.setItemMeta(meta);
this.noRemoveExactLinearXp = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
this.levelCostFactory = new IntSettingsGui.IntSettingFactory("§8Recipe Level Cost", this,
this.anvilRecipe + "." + AnvilCustomRecipe.XP_LEVEL_COST_CONFIG,
ConfigHolder.CUSTOM_RECIPE_HOLDER, ConfigHolder.CUSTOM_RECIPE_HOLDER,
null, null,
costRange.getFirst(), costRange.getLast(), AnvilCustomRecipe.DEFAULT_XP_LEVEL_COST_CONFIG, 1, 5, 10); costRange.getFirst(), costRange.getLast(), AnvilCustomRecipe.DEFAULT_XP_LEVEL_COST_CONFIG, 1, 5, 10);
this.linearXpCostFactory = new IntSettingsGui.IntSettingFactory("§8Recipe Linear Xp Cost", this,
this.anvilRecipe + "." + AnvilCustomRecipe.LINEAR_XP_COST_CONFIG,
ConfigHolder.CUSTOM_RECIPE_HOLDER,
null,
0, Integer.MAX_VALUE, AnvilCustomRecipe.DEFAULT_LINEAR_XP_COST_CONFIG, 1, 10, 100, 1000, 10000);
// Right part of the gui
this.leftItemFactory = new ItemSettingGui.ItemSettingFactory("§eRecipe Left §8Item", this, this.leftItemFactory = new ItemSettingGui.ItemSettingFactory("§eRecipe Left §8Item", this,
this.anvilRecipe + "." + AnvilCustomRecipe.LEFT_ITEM_CONFIG, this.anvilRecipe + "." + AnvilCustomRecipe.LEFT_ITEM_CONFIG,
ConfigHolder.CUSTOM_RECIPE_HOLDER, ConfigHolder.CUSTOM_RECIPE_HOLDER,
@ -158,8 +183,18 @@ public class CustomRecipeSubSettingGui extends MappedToListSubSettingGui {
GuiItem exactCountItem = this.exactCountFactory.getItem(); GuiItem exactCountItem = this.exactCountFactory.getItem();
this.pane.bindItem('1', exactCountItem); this.pane.bindItem('1', exactCountItem);
GuiItem xpCostItem = this.xpCostFactory.getItem(Material.EXPERIENCE_BOTTLE); if (anvilRecipe.getXpCostPerCraft() != 0) {
this.pane.bindItem('2', xpCostItem); this.pane.bindItem('a', noRemoveExactLinearXp);
} else {
this.pane.bindItem('a', removeExactLinearXpFactory.getItem());
}
GuiItem levelCostItem = this.levelCostFactory.getItem(Material.EXPERIENCE_BOTTLE);
this.pane.bindItem('2', levelCostItem);
GuiItem xpCostItem = this.linearXpCostFactory.getItem(Material.EXPERIENCE_BOTTLE);
this.pane.bindItem('b', xpCostItem);
GuiItem leftGuiItem = this.leftItemFactory.getItem(); GuiItem leftGuiItem = this.leftItemFactory.getItem();
this.pane.bindItem('3', leftGuiItem); this.pane.bindItem('3', leftGuiItem);
@ -169,7 +204,7 @@ public class CustomRecipeSubSettingGui extends MappedToListSubSettingGui {
GuiItem resultGuiItem = this.resultItemFactory.getItem(); GuiItem resultGuiItem = this.resultItemFactory.getItem();
this.pane.bindItem('5', resultGuiItem); this.pane.bindItem('5', resultGuiItem);
update(); update();
} }