From aaa031a36408b96b6eef5351fd60e979112f0cea Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 31 Dec 2018 13:28:08 +0800 Subject: added blast furnace recipes --- README.md | 2 + .../java/me/shedaniel/plugin/VanillaPlugin.java | 18 ++--- .../blastfurnace/VanillaBlastFurnaceCategory.java | 90 ++++++++++++++++++++++ .../blastfurnace/VanillaBlastFurnaceRecipe.java | 44 +++++++++++ .../assets/roughlyenoughitems/lang/en_us.json | 1 + 5 files changed, 146 insertions(+), 9 deletions(-) create mode 100755 src/main/java/me/shedaniel/plugin/blastfurnace/VanillaBlastFurnaceCategory.java create mode 100755 src/main/java/me/shedaniel/plugin/blastfurnace/VanillaBlastFurnaceRecipe.java diff --git a/README.md b/README.md index 922c40d9d..d540802df 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ A project to make (AEI) [https://minecraft.curseforge.com/projects/almost-enough ### 1.14 Port - Not Called Listeners - PacketAdder +- Cheating is buggy +- Using like 100 billion mixins ### Features that I will work on in the future - Hide Gui with Control / Command + O diff --git a/src/main/java/me/shedaniel/plugin/VanillaPlugin.java b/src/main/java/me/shedaniel/plugin/VanillaPlugin.java index 1766f7239..940d9c779 100755 --- a/src/main/java/me/shedaniel/plugin/VanillaPlugin.java +++ b/src/main/java/me/shedaniel/plugin/VanillaPlugin.java @@ -3,6 +3,8 @@ package me.shedaniel.plugin; import me.shedaniel.api.IREIPlugin; import me.shedaniel.impl.REIRecipeManager; import me.shedaniel.listenerdefinitions.PotionCraftingAdder; +import me.shedaniel.plugin.blastfurnace.VanillaBlastFurnaceCategory; +import me.shedaniel.plugin.blastfurnace.VanillaBlastFurnaceRecipe; import me.shedaniel.plugin.crafting.VanillaCraftingCategory; import me.shedaniel.plugin.crafting.VanillaCraftingRecipe; import me.shedaniel.plugin.crafting.VanillaShapedCraftingRecipe; @@ -23,6 +25,7 @@ import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.Recipe; import net.minecraft.recipe.crafting.ShapedRecipe; import net.minecraft.recipe.crafting.ShapelessRecipe; +import net.minecraft.recipe.smelting.BlastingRecipe; import net.minecraft.recipe.smelting.SmeltingRecipe; import net.minecraft.recipe.smelting.SmokingRecipe; import net.minecraft.util.registry.Registry; @@ -40,10 +43,12 @@ public class VanillaPlugin implements IREIPlugin, PotionCraftingAdder { List recipes = new LinkedList<>(); List furnaceRecipes = new LinkedList<>(); List smokerRecipes = new LinkedList<>(); + List blastFurnaceRecipes = new LinkedList<>(); REIRecipeManager.instance().addDisplayAdapter(new VanillaCraftingCategory()); REIRecipeManager.instance().addDisplayAdapter(new VanillaFurnaceCategory()); REIRecipeManager.instance().addDisplayAdapter(new VanillaPotionCategory()); REIRecipeManager.instance().addDisplayAdapter(new VanillaSmokerCategory()); + REIRecipeManager.instance().addDisplayAdapter(new VanillaBlastFurnaceCategory()); // REIRecipeManager.instance().addDisplayAdapter(new TestRandomCategory("a", new ItemStack(Blocks.ACACIA_BUTTON.asItem()))); // REIRecipeManager.instance().addDisplayAdapter(new TestRandomCategory("b", new ItemStack(Blocks.ACACIA_LOG.asItem()))); // REIRecipeManager.instance().addDisplayAdapter(new TestRandomCategory("c", new ItemStack(Blocks.ACACIA_LOG.asItem()))); @@ -63,6 +68,9 @@ public class VanillaPlugin implements IREIPlugin, PotionCraftingAdder { if (recipe instanceof SmokingRecipe) { smokerRecipes.add(new VanillaSmokerRecipe((SmokingRecipe) recipe)); } + if (recipe instanceof BlastingRecipe) { + blastFurnaceRecipes.add(new VanillaBlastFurnaceRecipe((BlastingRecipe) recipe)); + } } Registry.POTION.stream().filter(potion -> !potion.equals(Potions.EMPTY)).forEach(potion -> { ItemStack basePotion = PotionUtil.setPotion(new ItemStack(Items.POTION), potion), @@ -73,20 +81,12 @@ public class VanillaPlugin implements IREIPlugin, PotionCraftingAdder { potionRecipes.add(new VanillaPotionRecipe(new ItemStack[]{splashPotion}, Ingredient.ofItems(Items.DRAGON_BREATH).getStackArray(), new ItemStack[]{lingeringPotion})); }); - /*PotionType.REGISTRY.stream().filter(potionType -> !potionType.equals(PotionTypes.EMPTY)).forEach(potionType -> { - ItemStack basePotion = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), potionType), - splashPotion = PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potionType), - lingeringPotion = PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION), potionType); - potionRecipes.add(new VanillaPotionRecipe(new ItemStack[]{basePotion}, Ingredient.ofItems(Items.GUNPOWDER).getStackArray(), - new ItemStack[]{splashPotion})); - potionRecipes.add(new VanillaPotionRecipe(new ItemStack[]{splashPotion}, Ingredient.ofItems(Items.DRAGON_BREATH).getStackArray(), - new ItemStack[]{lingeringPotion})); - });*/ REIRecipeManager.instance().addRecipe("vanilla", recipes); REIRecipeManager.instance().addRecipe("furnace", furnaceRecipes); REIRecipeManager.instance().addRecipe("smoker", smokerRecipes); REIRecipeManager.instance().addRecipe("potion", potionRecipes.stream().distinct().collect(Collectors.toList())); + REIRecipeManager.instance().addRecipe("blastingfurnace", blastFurnaceRecipes); // REIRecipeManager.instance().addPotionRecipe("a", new RandomRecipe("a")); // REIRecipeManager.instance().addPotionRecipe("b", new RandomRecipe("b")); // REIRecipeManager.instance().addPotionRecipe("c", new RandomRecipe("c")); diff --git a/src/main/java/me/shedaniel/plugin/blastfurnace/VanillaBlastFurnaceCategory.java b/src/main/java/me/shedaniel/plugin/blastfurnace/VanillaBlastFurnaceCategory.java new file mode 100755 index 000000000..4ef67cbf9 --- /dev/null +++ b/src/main/java/me/shedaniel/plugin/blastfurnace/VanillaBlastFurnaceCategory.java @@ -0,0 +1,90 @@ +package me.shedaniel.plugin.blastfurnace; + +import me.shedaniel.api.IDisplayCategory; +import me.shedaniel.gui.widget.Control; +import me.shedaniel.gui.widget.REISlot; +import me.shedaniel.gui.widget.WidgetArrow; +import net.minecraft.block.Blocks; +import net.minecraft.block.entity.BlastFurnaceBlockEntity; +import net.minecraft.block.entity.SmokerBlockEntity; +import net.minecraft.client.resource.language.I18n; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +public class VanillaBlastFurnaceCategory implements IDisplayCategory { + private List recipes; + + @Override + public String getId() { + return "blastingfurnace"; + } + + @Override + public String getDisplayName() { + return I18n.translate("category.rei.blasting"); + } + + @Override + public void addRecipe(VanillaBlastFurnaceRecipe recipe) { + if (this.recipes == null) + this.recipes = new ArrayList<>(); + this.recipes.add(recipe); + } + + @Override + public void resetRecipes() { + this.recipes = new ArrayList<>(); + } + + @Override + public List setupDisplay(int number) { + List slots = new LinkedList<>(); + REISlot inputSlot = new REISlot(50, 70 + number * 75); + inputSlot.setStackList(recipes.get(number).getInput().get(0)); + inputSlot.setDrawBackground(true); + + REISlot outputSlot = new REISlot(110, 70 + number * 75); + outputSlot.setStackList(recipes.get(number).getOutput()); + outputSlot.setDrawBackground(true); + + REISlot fuelSlot = new REISlot(80, 100 + number * 75); + fuelSlot.setStackList(getFuel()); + fuelSlot.setDrawBackground(true); + fuelSlot.setExtraTooltip(I18n.translate("category.rei.smelting.fuel")); + + slots.add(inputSlot); + slots.add(outputSlot); + slots.add(fuelSlot); + return slots; + } + + @Override + public boolean canDisplay(VanillaBlastFurnaceRecipe recipe) { + return false; + } + + @Override + public void drawExtras() { + + } + + @Override + public void addWidget(List controls, int number) { + WidgetArrow wa = new WidgetArrow(75, 70 + number * 75, true, 10); + controls.add(wa); + } + + private List getFuel() { + return BlastFurnaceBlockEntity.getBurnTimeMap().keySet().stream().map(Item::getDefaultStack).collect(Collectors.toList()); + } + + @Override + public ItemStack getCategoryIcon() { + return new ItemStack(Blocks.BLAST_FURNACE.getItem()); + } +} diff --git a/src/main/java/me/shedaniel/plugin/blastfurnace/VanillaBlastFurnaceRecipe.java b/src/main/java/me/shedaniel/plugin/blastfurnace/VanillaBlastFurnaceRecipe.java new file mode 100755 index 000000000..3032c2401 --- /dev/null +++ b/src/main/java/me/shedaniel/plugin/blastfurnace/VanillaBlastFurnaceRecipe.java @@ -0,0 +1,44 @@ +package me.shedaniel.plugin.blastfurnace; + +import me.shedaniel.api.IRecipe; +import net.minecraft.block.BlastFurnaceBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.recipe.Ingredient; +import net.minecraft.recipe.smelting.BlastingRecipe; +import net.minecraft.recipe.smelting.SmokingRecipe; + +import java.util.LinkedList; +import java.util.List; + +public class VanillaBlastFurnaceRecipe implements IRecipe { + private final BlastingRecipe recipe; + + @Override + public String getId() { + return "blastingfurnace"; + } + + public VanillaBlastFurnaceRecipe(BlastingRecipe recipe) { + this.recipe = recipe; + } + + @Override + public List getOutput() { + List output = new LinkedList<>(); + output.add(recipe.getOutput().copy()); + return output; + } + + @Override + public List> getInput() { + List> input = new LinkedList<>(); + for(Ingredient ingredient : recipe.getPreviewInputs()) { + List ingredients = new LinkedList<>(); + for(ItemStack matchingStack : ingredient.getStackArray()) { + ingredients.add(matchingStack); + } + input.add(ingredients); + } + return input; + } +} diff --git a/src/main/resources/assets/roughlyenoughitems/lang/en_us.json b/src/main/resources/assets/roughlyenoughitems/lang/en_us.json index f8a93e3c2..93a19790d 100755 --- a/src/main/resources/assets/roughlyenoughitems/lang/en_us.json +++ b/src/main/resources/assets/roughlyenoughitems/lang/en_us.json @@ -10,6 +10,7 @@ "category.rei.smelting": "Smelting", "category.rei.smelting.fuel": "§eFuel", "category.rei.smoking": "Smoking", + "category.rei.blasting": "Blasting", "category.rei.brewing": "Brewing", "category.rei.brewing.input": "§eOriginal Potion", "category.rei.brewing.reactant": "§eIngredient", -- cgit