mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 19:29:31 +00:00
Brewery recipe support
This commit is contained in:
1 parent
75ab210227
commit
b10a642297
5 files changed
+248
No files matched your search
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* This class was created by <williewillus>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Jan 3, 2016, 2:32:39 AM (GMT)]
|
||||
*/
|
||||
|
||||
package vazkii.botania.client.integration.jei;
|
||||
|
||||
import mezz.jei.api.IItemRegistry;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.IRecipeRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.client.integration.jei.brewery.BreweryRecipeCategory;
|
||||
import vazkii.botania.client.integration.jei.brewery.BreweryRecipeHandler;
|
||||
|
||||
@JEIPlugin
|
||||
public class JEIBotaniaPlugin implements IModPlugin {
|
||||
|
||||
private IJeiHelpers jeiHelpers;
|
||||
private IItemRegistry itemRegistry;
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJeiHelpersAvailable(IJeiHelpers jeiHelpers) {
|
||||
this.jeiHelpers = jeiHelpers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemRegistryAvailable(IItemRegistry itemRegistry) {
|
||||
this.itemRegistry = itemRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(IModRegistry registry) {
|
||||
registry.addRecipeCategories(
|
||||
new BreweryRecipeCategory(jeiHelpers.getGuiHelper())
|
||||
);
|
||||
|
||||
registry.addRecipeHandlers(
|
||||
new BreweryRecipeHandler()
|
||||
);
|
||||
|
||||
registry.addRecipes(BotaniaAPI.brewRecipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecipeRegistryAvailable(IRecipeRegistry recipeRegistry) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package vazkii.botania.client.integration.jei.brewery;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IDrawableStatic;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class BreweryRecipeCategory implements IRecipeCategory {
|
||||
|
||||
private final IDrawableStatic background;
|
||||
private final String localizedName;
|
||||
|
||||
private static final int slotContainerInput = 0;
|
||||
private static final int slotIngredient1 = 1;
|
||||
private static final int slotIngredient2 = 2;
|
||||
private static final int slotIngredient3 = 3;
|
||||
private static final int slotIngredient4 = 4;
|
||||
private static final int slotIngredient5 = 5;
|
||||
private static final int slotIngredient6 = 6;
|
||||
private static final int slotOutput = 7;
|
||||
|
||||
public BreweryRecipeCategory(IGuiHelper guiHelper) {
|
||||
ResourceLocation location = new ResourceLocation("botania", "textures/gui/neiBrewery.png");
|
||||
background = guiHelper.createDrawable(location, 0, 0, 166, 65, 0, 0, 0, 0);
|
||||
localizedName = StatCollector.translateToLocal("botania.nei.brewery");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUid() {
|
||||
return "botania.brewery";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return localizedName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(Minecraft minecraft) {}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
recipeLayout.getItemStacks().init(slotContainerInput, true, 39, 41);
|
||||
recipeLayout.getItemStacks().init(slotIngredient1, true, 64, 6);
|
||||
recipeLayout.getItemStacks().init(slotIngredient2, true, 80, 6);
|
||||
recipeLayout.getItemStacks().init(slotIngredient3, true, 96, 6);
|
||||
recipeLayout.getItemStacks().init(slotIngredient4, true, 112, 6);
|
||||
recipeLayout.getItemStacks().init(slotIngredient5, true, 128, 6);
|
||||
recipeLayout.getItemStacks().init(slotIngredient6, true, 144, 6);
|
||||
recipeLayout.getItemStacks().init(slotOutput, false, 87, 41); // todo coords
|
||||
|
||||
BreweryRecipeWrapper wrapper = ((BreweryRecipeWrapper) recipeWrapper);
|
||||
List inputs = wrapper.getInputs();
|
||||
for (int i = 0; i < inputs.size(); i++) {
|
||||
if (i > slotOutput) {
|
||||
break;
|
||||
}
|
||||
if (inputs.get(i) instanceof ItemStack) {
|
||||
recipeLayout.getItemStacks().set(i, ((ItemStack) inputs.get(i)));
|
||||
} else if (inputs.get(i) instanceof Collection) {
|
||||
recipeLayout.getItemStacks().set(i, ((Collection<ItemStack>) inputs.get(i)));
|
||||
}
|
||||
}
|
||||
recipeLayout.getItemStacks().set(slotOutput, wrapper.getOutputs().get(0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package vazkii.botania.client.integration.jei.brewery;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import vazkii.botania.api.recipe.RecipeBrew;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BreweryRecipeHandler implements IRecipeHandler<RecipeBrew> {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<RecipeBrew> getRecipeClass() {
|
||||
return RecipeBrew.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getRecipeCategoryUid() {
|
||||
return "botania.brewery";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull RecipeBrew recipe) {
|
||||
return new BreweryRecipeWrapper(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(@Nonnull RecipeBrew recipe) {
|
||||
return recipe.getInputs().size() <= 6;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package vazkii.botania.client.integration.jei.brewery;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import vazkii.botania.api.recipe.RecipeBrew;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class BreweryRecipeWrapper implements IRecipeWrapper {
|
||||
|
||||
private final List input;
|
||||
private final List<ItemStack> output;
|
||||
|
||||
public BreweryRecipeWrapper(RecipeBrew recipeBrew) {
|
||||
ImmutableList.Builder builder = ImmutableList.builder();
|
||||
builder.add(new ItemStack(ModItems.vial));
|
||||
for (Object o : recipeBrew.getInputs()) {
|
||||
if (o instanceof ItemStack) {
|
||||
builder.add(o);
|
||||
}
|
||||
if (o instanceof String) {
|
||||
builder.add(OreDictionary.getOres(((String) o)));
|
||||
}
|
||||
}
|
||||
|
||||
input = builder.build();
|
||||
output = ImmutableList.of(recipeBrew.getOutput(new ItemStack(ModItems.vial)).copy(), new ItemStack(ModBlocks.brewery));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getInputs() {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getOutputs() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidInputs() { return ImmutableList.of(); }
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidOutputs() { return ImmutableList.of(); }
|
||||
|
||||
@Override
|
||||
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {}
|
||||
}
|
||||
Reference in new issue
Block a user