mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-16 18:44:44 +00:00
Fix orechid ignem JEI not working, reuse basic code for both orechids
This commit is contained in:
1 parent
5d3ff952ea
commit
2dd96b87ce
3 files changed
+135
-154
No files matched your search
+6
-61
@@ -8,37 +8,23 @@
|
||||
*/
|
||||
package vazkii.botania.client.integration.jei.orechid;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.drawable.IDrawableStatic;
|
||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.common.block.ModSubtiles;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Map;
|
||||
|
||||
public class OrechidIgnemRecipeCategory implements IRecipeCategory<OrechidIgnemRecipeWrapper> {
|
||||
public class OrechidIgnemRecipeCategory extends OrechidRecipeCategoryBase<OrechidIgnemRecipeWrapper> {
|
||||
|
||||
public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "orechid_ignem");
|
||||
private final IDrawableStatic background;
|
||||
private final String localizedName;
|
||||
private final IDrawableStatic overlay;
|
||||
private final IDrawable icon;
|
||||
|
||||
public OrechidIgnemRecipeCategory(IGuiHelper guiHelper) {
|
||||
background = guiHelper.createBlankDrawable(168, 64);
|
||||
localizedName = I18n.format("botania.nei.orechidIgnem");
|
||||
overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pure_daisy_overlay.png"),
|
||||
0, 0, 64, 46);
|
||||
icon = guiHelper.createDrawableIngredient(new ItemStack(ModSubtiles.orechidIgnem));
|
||||
super(guiHelper, new ItemStack(ModSubtiles.orechidIgnem), I18n.format("botania.nei.orechidIgnem"));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -53,50 +39,9 @@ public class OrechidIgnemRecipeCategory implements IRecipeCategory<OrechidIgnemR
|
||||
return OrechidIgnemRecipeWrapper.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return localizedName;
|
||||
protected Map<ResourceLocation, Integer> getOreWeights() {
|
||||
return BotaniaAPI.oreWeightsNether;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(OrechidIgnemRecipeWrapper recipe, IIngredients ingredients) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull OrechidIgnemRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
|
||||
final IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
itemStacks.init(0, true, 40, 12);
|
||||
itemStacks.set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0));
|
||||
|
||||
itemStacks.init(1, true, 70, 12);
|
||||
itemStacks.set(1, new ItemStack(ModSubtiles.orechidIgnem));
|
||||
|
||||
itemStacks.init(2, true, 99, 12);
|
||||
itemStacks.set(2, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(OrechidIgnemRecipeWrapper recipe, double mouseX, double mouseY) {
|
||||
GlStateManager.enableAlphaTest();
|
||||
GlStateManager.enableBlend();
|
||||
overlay.draw(48, 0);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.disableAlphaTest();
|
||||
}
|
||||
}
|
||||
+5
-93
@@ -8,46 +8,22 @@
|
||||
*/
|
||||
package vazkii.botania.client.integration.jei.orechid;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.drawable.IDrawableStatic;
|
||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.client.integration.jei.JEIBotaniaPlugin;
|
||||
import vazkii.botania.common.block.ModSubtiles;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class OrechidRecipeCategory implements IRecipeCategory<OrechidRecipeWrapper> {
|
||||
|
||||
public class OrechidRecipeCategory extends OrechidRecipeCategoryBase<OrechidRecipeWrapper> {
|
||||
public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "orechid");
|
||||
private final IDrawableStatic background;
|
||||
private final String localizedName;
|
||||
private final IDrawableStatic overlay;
|
||||
private final IDrawable icon;
|
||||
|
||||
|
||||
public OrechidRecipeCategory(IGuiHelper guiHelper) {
|
||||
background = guiHelper.createBlankDrawable(168, 64);
|
||||
localizedName = I18n.format("botania.nei.orechid");
|
||||
overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pure_daisy_overlay.png"),
|
||||
0, 0, 64, 46);
|
||||
icon = guiHelper.createDrawableIngredient(new ItemStack(ModSubtiles.orechid));
|
||||
super(guiHelper, new ItemStack(ModSubtiles.orechid), I18n.format("botania.nei.orechid"));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -62,72 +38,8 @@ public class OrechidRecipeCategory implements IRecipeCategory<OrechidRecipeWrapp
|
||||
return OrechidRecipeWrapper.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return localizedName;
|
||||
protected Map<ResourceLocation, Integer> getOreWeights() {
|
||||
return BotaniaAPI.oreWeights;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(OrechidRecipeWrapper recipe, IIngredients ingredients) {
|
||||
ingredients.setInput(VanillaTypes.ITEM, new ItemStack(Blocks.STONE, 64));
|
||||
|
||||
final int myWeight = recipe.entry.getValue();
|
||||
final int amount = Math.max(1, Math.round((float) myWeight * 64 / getTotalOreWeight(BotaniaAPI.oreWeights, myWeight)));
|
||||
|
||||
// Shouldn't ever return an empty list since the ore weight
|
||||
// list is filtered to only have ores with ItemBlocks
|
||||
List<ItemStack> stackList = BlockTags.getCollection().getOrCreate(recipe.entry.getKey())
|
||||
.getAllElements()
|
||||
.stream()
|
||||
.filter(s -> s.asItem() != Items.AIR)
|
||||
.map(ItemStack::new)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
stackList.forEach(s -> s.setCount(amount));
|
||||
ingredients.setOutputLists(VanillaTypes.ITEM, Collections.singletonList(stackList));
|
||||
}
|
||||
|
||||
public static float getTotalOreWeight(Map<ResourceLocation, Integer> weights, int myWeight) {
|
||||
return (weights.entrySet().stream()
|
||||
.filter(e -> JEIBotaniaPlugin.doesOreExist(e.getKey()))
|
||||
.map(Map.Entry::getValue)
|
||||
.reduce(Integer::sum)).orElse(myWeight * 64 * 64);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull OrechidRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
|
||||
final IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
itemStacks.init(0, true, 40, 12);
|
||||
itemStacks.set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0));
|
||||
|
||||
itemStacks.init(1, true, 70, 12);
|
||||
itemStacks.set(1, new ItemStack(ModSubtiles.orechid));
|
||||
|
||||
itemStacks.init(2, true, 99, 12);
|
||||
itemStacks.set(2, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(OrechidRecipeWrapper recipe, double mouseX, double mouseY) {
|
||||
GlStateManager.enableAlphaTest();
|
||||
GlStateManager.enableBlend();
|
||||
overlay.draw(48, 0);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.disableAlphaTest();
|
||||
}
|
||||
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* This class was created by <codewarrior0>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
* <p/>
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*/
|
||||
package vazkii.botania.client.integration.jei.orechid;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.drawable.IDrawableStatic;
|
||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import vazkii.botania.client.integration.jei.JEIBotaniaPlugin;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class OrechidRecipeCategoryBase<T extends OrechidRecipeWrapper> implements IRecipeCategory<T> {
|
||||
|
||||
private final IDrawableStatic background;
|
||||
private final String localizedName;
|
||||
private final IDrawableStatic overlay;
|
||||
private final IDrawable icon;
|
||||
private final ItemStack iconStack;
|
||||
|
||||
public OrechidRecipeCategoryBase(IGuiHelper guiHelper, ItemStack iconStack, String localizedName) {
|
||||
overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pure_daisy_overlay.png"),
|
||||
0, 0, 64, 46);
|
||||
background = guiHelper.createBlankDrawable(168, 64);
|
||||
this.localizedName = localizedName;
|
||||
this.icon = guiHelper.createDrawableIngredient(iconStack);
|
||||
this.iconStack = iconStack;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public abstract Class<? extends T> getRecipeClass();
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return localizedName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(T recipe, IIngredients ingredients) {
|
||||
ingredients.setInput(VanillaTypes.ITEM, new ItemStack(Blocks.STONE, 64));
|
||||
|
||||
final int myWeight = recipe.entry.getValue();
|
||||
final int amount = Math.max(1, Math.round((float) myWeight * 64 / getTotalOreWeight(getOreWeights(), myWeight)));
|
||||
|
||||
// Shouldn't ever return an empty list since the ore weight
|
||||
// list is filtered to only have ores with ItemBlocks
|
||||
List<ItemStack> stackList = BlockTags.getCollection().getOrCreate(recipe.entry.getKey())
|
||||
.getAllElements()
|
||||
.stream()
|
||||
.filter(s -> s.asItem() != Items.AIR)
|
||||
.map(ItemStack::new)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
stackList.forEach(s -> s.setCount(amount));
|
||||
ingredients.setOutputLists(VanillaTypes.ITEM, Collections.singletonList(stackList));
|
||||
}
|
||||
|
||||
public static float getTotalOreWeight(Map<ResourceLocation, Integer> weights, int myWeight) {
|
||||
return (weights.entrySet().stream()
|
||||
.filter(e -> JEIBotaniaPlugin.doesOreExist(e.getKey()))
|
||||
.map(Map.Entry::getValue)
|
||||
.reduce(Integer::sum)).orElse(myWeight * 64 * 64);
|
||||
}
|
||||
|
||||
protected abstract Map<ResourceLocation, Integer> getOreWeights();
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull T recipeWrapper, @Nonnull IIngredients ingredients) {
|
||||
final IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
itemStacks.init(0, true, 40, 12);
|
||||
itemStacks.set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0));
|
||||
|
||||
itemStacks.init(1, true, 70, 12);
|
||||
itemStacks.set(1, iconStack);
|
||||
|
||||
itemStacks.init(2, true, 99, 12);
|
||||
itemStacks.set(2, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(T recipe, double mouseX, double mouseY) {
|
||||
GlStateManager.enableAlphaTest();
|
||||
GlStateManager.enableBlend();
|
||||
overlay.draw(48, 0);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.disableAlphaTest();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user