|
@@ -1,12 +1,21 @@
|
|
|
package me.shedaniel.plugin.blastfurnace;
|
|
|
|
|
|
+import me.shedaniel.api.DisplayCategoryCraftable;
|
|
|
import me.shedaniel.api.IDisplayCategory;
|
|
|
+import me.shedaniel.gui.RecipeGui;
|
|
|
import me.shedaniel.gui.widget.Control;
|
|
|
import me.shedaniel.gui.widget.REISlot;
|
|
|
+import me.shedaniel.gui.widget.SmallButton;
|
|
|
import me.shedaniel.gui.widget.WidgetArrow;
|
|
|
+import me.shedaniel.listenerdefinitions.IMixinRecipeBookGui;
|
|
|
+import me.shedaniel.plugin.smoker.VanillaSmokerRecipe;
|
|
|
import net.minecraft.block.Blocks;
|
|
|
import net.minecraft.block.entity.BlastFurnaceBlockEntity;
|
|
|
import net.minecraft.block.entity.SmokerBlockEntity;
|
|
|
+import net.minecraft.client.MinecraftClient;
|
|
|
+import net.minecraft.client.gui.Gui;
|
|
|
+import net.minecraft.client.gui.container.BlastFurnaceGui;
|
|
|
+import net.minecraft.client.gui.container.SmokerGui;
|
|
|
import net.minecraft.client.resource.language.I18n;
|
|
|
import net.minecraft.item.Item;
|
|
|
import net.minecraft.item.ItemStack;
|
|
@@ -16,7 +25,7 @@ import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-public class VanillaBlastFurnaceCategory implements IDisplayCategory<VanillaBlastFurnaceRecipe> {
|
|
|
+public class VanillaBlastFurnaceCategory implements DisplayCategoryCraftable<VanillaBlastFurnaceRecipe> {
|
|
|
private List<VanillaBlastFurnaceRecipe> recipes;
|
|
|
|
|
|
@Override
|
|
@@ -87,4 +96,31 @@ public class VanillaBlastFurnaceCategory implements IDisplayCategory<VanillaBlas
|
|
|
public ItemStack getCategoryIcon() {
|
|
|
return new ItemStack(Blocks.BLAST_FURNACE.getItem());
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean canAutoCraftHere(Class<? extends Gui> guiClass, VanillaBlastFurnaceRecipe recipe) {
|
|
|
+ return guiClass.isAssignableFrom(BlastFurnaceGui.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean performAutoCraft(Gui gui, VanillaBlastFurnaceRecipe recipe) {
|
|
|
+ if (!gui.getClass().isAssignableFrom(BlastFurnaceGui.class))
|
|
|
+ return false;
|
|
|
+ ((IMixinRecipeBookGui) (((BlastFurnaceGui) gui).getRecipeBookGui())).getGhostSlots().reset();
|
|
|
+ MinecraftClient.getInstance().interactionManager.clickRecipe(MinecraftClient.getInstance().player.container.syncId, recipe.getRecipe(), Gui.isShiftPressed());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void registerAutoCraftButton(List<Control> control, RecipeGui recipeGui, Gui parentGui, VanillaBlastFurnaceRecipe recipe, int number) {
|
|
|
+ SmallButton button = new SmallButton(128, 75 + 6 + 26 + number * 75, 10, 10, "+");
|
|
|
+ button.setOnClick(mouse -> {
|
|
|
+ recipeGui.close();
|
|
|
+ MinecraftClient.getInstance().openGui(parentGui);
|
|
|
+ return canAutoCraftHere(parentGui.getClass(), recipe) && performAutoCraft(parentGui, recipe);
|
|
|
+ });
|
|
|
+ button.setEnabled(canAutoCraftHere(parentGui.getClass(), recipe));
|
|
|
+ control.add(button);
|
|
|
+ }
|
|
|
+
|
|
|
}
|