Added the ability for the Lexica Botania to swap between various items that a recipe can match based on time. Finally. Closes #2372

This commit is contained in:
Vasco Lavos committed 2017-09-30 13:22:00 +01:00
1 parent 75a30f27b5
commit ef82d0325c
2 files changed
+32 -22

No files matched your search

@@ -54,7 +54,7 @@ public class PageCraftingRecipe extends PageRecipe {
public PageCraftingRecipe(String unlocalizedName, List<ResourceLocation> recipes) {
super(unlocalizedName);
this.recipes = recipes;
for(ResourceLocation res : recipes)
if(res == null)
throw new IllegalArgumentException("Null recipes arent allowed");
@@ -136,23 +136,25 @@ public class PageCraftingRecipe extends PageRecipe {
public void renderCraftingRecipe(IGuiLexiconEntry gui, IRecipe recipe) {
if(recipe == null)
return;
if(recipe instanceof ShapedRecipes || recipe instanceof ShapedOreRecipe) {
oreDictRecipe = recipe instanceof ShapedOreRecipe;
int width = oreDictRecipe
? ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, (ShapedOreRecipe) recipe, "width")
: ((ShapedRecipes) recipe).getWidth();
int height = oreDictRecipe
? ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, (ShapedOreRecipe) recipe, "height")
: ((ShapedRecipes) recipe).getHeight();
: ((ShapedRecipes) recipe).getWidth();
int height = oreDictRecipe
? ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, (ShapedOreRecipe) recipe, "height")
: ((ShapedRecipes) recipe).getHeight();
for(int y = 0; y < height; y++)
for(int x = 0; x < width; x++) {
Ingredient input = recipe.getIngredients().get(y * width + x);
if(input != Ingredient.EMPTY)
renderItemAtGridPos(gui, 1 + x, 1 + y, input.getMatchingStacks()[0], true); // TODO 1.12 this isn't just used for OD anymore. need to cycle through all matching stacks
}
for(int y = 0; y < height; y++)
for(int x = 0; x < width; x++) {
Ingredient input = recipe.getIngredients().get(y * width + x);
if(input != Ingredient.EMPTY) {
ItemStack[] stacks = input.getMatchingStacks();
renderItemAtGridPos(gui, 1 + x, 1 + y, stacks[(ticksElapsed / 40) % stacks.length], true);
}
}
} else if(recipe instanceof ShapelessRecipes || recipe instanceof ShapelessOreRecipe) {
shapelessRecipe = true;
oreDictRecipe = recipe instanceof ShapelessOreRecipe;
@@ -166,8 +168,10 @@ public class PageCraftingRecipe extends PageRecipe {
break drawGrid;
Ingredient input = recipe.getIngredients().get(index);
if(input != Ingredient.EMPTY)
renderItemAtGridPos(gui, 1 + x, 1 + y, input.getMatchingStacks()[0], true); // TODO 1.12 this isn't just used for OD anymore. need to cycle through all matching stacks
if(input != Ingredient.EMPTY) {
ItemStack[] stacks = input.getMatchingStacks();
renderItemAtGridPos(gui, 1 + x, 1 + y, stacks[(ticksElapsed / 40) % stacks.length], true);
}
}
}
}
@@ -10,6 +10,12 @@
*/
package vazkii.botania.common.lexicon.page;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
@@ -17,11 +23,11 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.internal.IGuiLexiconEntry;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.lexicon.LexiconRecipeMappings;
@@ -31,10 +37,6 @@ import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.core.handler.ConfigHandler;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class PagePetalRecipe<T extends RecipePetals> extends PageRecipe {
private static final ResourceLocation petalOverlay = new ResourceLocation(LibResources.GUI_PETAL_OVERLAY);
@@ -70,11 +72,15 @@ public class PagePetalRecipe<T extends RecipePetals> extends PageRecipe {
List<Object> inputs = recipe.getInputs();
int degreePerInput = (int) (360F / inputs.size());
float currentDegree = ConfigHandler.lexiconRotatingItems ? GuiScreen.isShiftKeyDown() ? ticksElapsed : ticksElapsed + ClientTickHandler.partialTicks : 0;
float baseDegree = currentDegree;
for(Object obj : inputs) {
Object input = obj;
if(input instanceof String)
input = OreDictionary.getOres((String) input).get(0);
if(input instanceof String) {
NonNullList<ItemStack> list = OreDictionary.getOres((String) input);
int size = list.size();
input = list.get(size - (int) (baseDegree / 40) % size - 1);
}
renderItemAtAngle(gui, currentDegree, (ItemStack) input);