Skip to content

Commit

Permalink
Merge pull request #76
Browse files Browse the repository at this point in the history
Fancier and Unified Button Names & Lore
  • Loading branch information
WolfyScript authored Feb 26, 2022
2 parents 91bd635 + 4c03733 commit 2709275
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class ClusterRecipeBook extends CCCluster {
public static final NamespacedKey ITEM_CATEGORY = new NamespacedKey(KEY, "item_category");
public static final NamespacedKey PERMISSION = new NamespacedKey(KEY, "permission");

public static final NamespacedKey COOKING_ICON = new NamespacedKey(ClusterRecipeBook.KEY, "cooking.icon");
public static final NamespacedKey STONECUTTER = new NamespacedKey(ClusterRecipeBook.KEY, "stonecutter");
public static final NamespacedKey FURNACE = new NamespacedKey(ClusterRecipeBook.KEY, "furnace");
public static final NamespacedKey BLAST_FURNACE = new NamespacedKey(ClusterRecipeBook.KEY, "blast_furnace");
Expand Down Expand Up @@ -133,12 +134,12 @@ private void registerRecipeIcons() {
}));
registerButton(new DummyButton<>("anvil.result", Material.ANVIL));
registerButton(new DummyButton<>("anvil.none", Material.ANVIL));
registerButton(new DummyButton<>("cooking.icon", Material.FURNACE, (hashMap, cache, guiHandler, player, inventory, itemStack, slot, help) -> {
registerButton(new DummyButton<>(COOKING_ICON.getKey(), Material.FURNACE, (hashMap, cache, guiHandler, player, inventory, itemStack, slot, help) -> {
var knowledgeBook = cache.getKnowledgeBook();
RecipeType<?> recipeType = knowledgeBook.getCurrentRecipe().getRecipeType();
CustomRecipeCooking<?, ?> cookingRecipe = ((CustomRecipeCooking<?, ?>) knowledgeBook.getCurrentRecipe());
itemStack.setType(Material.matchMaterial(recipeType.name()));
hashMap.put("%type%", "&7" + StringUtils.capitalize(recipeType.getId().replace("_", " ")));
hashMap.put("%type%", StringUtils.capitalize(recipeType.getId().replace("_", " ")));
hashMap.put("%time%", cookingRecipe.getCookingTime());
hashMap.put("%xp%", cookingRecipe.getExp());
return itemStack;
Expand All @@ -154,11 +155,12 @@ private void registerRecipeIcons() {
registerButton(new DummyButton<>("cauldron.water.disabled", Material.CAULDRON));
registerButton(new DummyButton<>("cauldron.water.enabled", new ButtonState<>("cauldron.water.enabled", PlayerHeadUtils.getViaURL("848a19cdf42d748b41b72fb4376ae3f63c1165d2dce0651733df263446c77ba6"), (hashMap, cache, guiHandler, player, inventory, itemStack, slot, help) -> {
var knowledgeBook = cache.getKnowledgeBook();
hashMap.put("%time%", ((CustomRecipeCauldron) knowledgeBook.getCurrentRecipe()).getCookingTime());
hashMap.put("%lvl%", ((CustomRecipeCauldron) knowledgeBook.getCurrentRecipe()).getWaterLevel());
return itemStack;
})));
registerButton(new DummyButton<>("cauldron.fire.disabled", Material.FLINT));
registerButton(new DummyButton<>("cauldron.fire.enabled", Material.FLINT_AND_STEEL));
registerButton(new DummyButton<>("cauldron.fire.disabled", Material.CAMPFIRE));
registerButton(new DummyButton<>("cauldron.fire.enabled", Material.CAMPFIRE));
registerButton(new DummyButton<>("brewing.icon", Material.BREWING_STAND, (hashMap, cache, guiHandler, player, inventory, itemStack, slot, help) -> {
CustomRecipeBrewing cookingRecipe = (CustomRecipeBrewing) (guiHandler.getCustomCache().getKnowledgeBook()).getCurrentRecipe();
hashMap.put("%time%", cookingRecipe.getBrewTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public void onInit() {
setEntry(RECIPE_SINGLE);

//We change the behaviour of the buttons without a new language entry. Instead, it uses the lang keys from the recipe book cluster.
registerButton(new DummyButton<>("cooking.icon", new ButtonState<>(new NamespacedKey(ClusterRecipeBook.KEY, "cooking.icon"), Material.FURNACE, (hashMap, cache, guiHandler, player, inventory, itemStack, slot, help) -> {
registerButton(new DummyButton<>(ClusterRecipeBook.COOKING_ICON.getKey(), new ButtonState<>(ClusterRecipeBook.COOKING_ICON, Material.FURNACE, (hashMap, cache, guiHandler, player, inventory, itemStack, slot, help) -> {
cache.getCacheRecipeView().getRecipe().ifPresent(customRecipe -> {
RecipeType<?> recipeType = customRecipe.getRecipeType();
itemStack.setType(Material.matchMaterial(recipeType.name()));
hashMap.put("%type%", "&7" + StringUtils.capitalize(recipeType.getId().replace("_", " ")));
hashMap.put("%type%", StringUtils.capitalize(recipeType.getId().replace("_", " ")));
if (customRecipe instanceof CustomRecipeCooking<?,?> cookingRecipe) {
hashMap.put("%time%", cookingRecipe.getCookingTime());
hashMap.put("%xp%", cookingRecipe.getExp());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void renderMenu(GuiWindow<CCCache> guiWindow, GuiUpdate<CCCache> event) {
event.setButton(36 + startSlot + slot, new NamespacedKey(ClusterRecipeBook.KEY, "conditions." + condition.getNamespacedKey().toString("_")));
slot += 2;
}
event.setButton(13, new NamespacedKey(cluster.getId(), "cooking.icon"));
event.setButton(22, cluster.getButton(ClusterRecipeBook.COOKING_ICON.getKey()));
event.setButton(20, data.getLightBackground());
event.setButton(11, ButtonContainerIngredient.key(cluster, 11));
event.setButton(24, ButtonContainerIngredient.key(cluster, 24));
Expand Down
Loading

0 comments on commit 2709275

Please sign in to comment.