WIP
This commit is contained in:
parent
7d311ca3d7
commit
43993d13bc
5 changed files with 86 additions and 18 deletions
|
@ -1,21 +1,64 @@
|
|||
package ru.betterend.client.gui;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.recipebook.AbstractFurnaceRecipeBookScreen;
|
||||
import net.minecraft.client.gui.screen.recipebook.BlastFurnaceRecipeBookScreen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
|
||||
public class EndStoneSmelterRecipeBookScreen extends BlastFurnaceRecipeBookScreen {
|
||||
private static final Text TITLE = new TranslatableText("gui.recipebook.toggleRecipes.blastable");
|
||||
|
||||
protected Text getToggleCraftableButtonText() {
|
||||
return TITLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Item> getAllowedFuels() {
|
||||
return EndStoneSmelterBlockEntity.availableFuels().keySet();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void showGhostRecipe(Recipe<?> recipe, List<Slot> slots) {
|
||||
ItemStack result = recipe.getOutput();
|
||||
this.ghostSlots.setRecipe(recipe);
|
||||
this.ghostSlots.addSlot(Ingredient.ofStacks(result), (slots.get(3)).x, (slots.get(3)).y);
|
||||
DefaultedList<Ingredient> inputs = recipe.getPreviewInputs();
|
||||
try {
|
||||
Field outputSlot = super.getClass().getDeclaredField("outputSlot");
|
||||
outputSlot.setAccessible(true);
|
||||
outputSlot.set(Slot.class, slots.get(3));
|
||||
Field fuels = super.getClass().getDeclaredField("fuels");
|
||||
fuels.setAccessible(true);
|
||||
if (fuels.get(Set.class) == null) {
|
||||
fuels.set(Set.class, this.getAllowedFuels());
|
||||
}
|
||||
|
||||
Field fuelIterator = super.getClass().getDeclaredField("fuelIterator");
|
||||
fuelIterator.setAccessible(true);
|
||||
fuelIterator.set(Iterator.class, ((Set<Item>) fuels.get(Set.class)).iterator());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
Iterator<Ingredient> iterator = inputs.iterator();
|
||||
for(int i = 0; i < 2; i++) {
|
||||
if (!iterator.hasNext()) {
|
||||
return;
|
||||
}
|
||||
Ingredient ingredient = iterator.next();
|
||||
if (!ingredient.isEmpty()) {
|
||||
Slot slot = slots.get(i);
|
||||
this.ghostSlots.addSlot(ingredient, slot.x, slot.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue