mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 10:55:17 +00:00
Rudimentary pure daisy integration
This commit is contained in:
1 parent
b10a642297
commit
6cf82eb98d
4 files changed
+211
-2
No files matched your search
@@ -20,6 +20,8 @@ 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;
|
||||
import vazkii.botania.client.integration.jei.puredaisy.PureDaisyRecipeCategory;
|
||||
import vazkii.botania.client.integration.jei.puredaisy.PureDaisyRecipeHandler;
|
||||
|
||||
@JEIPlugin
|
||||
public class JEIBotaniaPlugin implements IModPlugin {
|
||||
@@ -45,14 +47,17 @@ public class JEIBotaniaPlugin implements IModPlugin {
|
||||
@Override
|
||||
public void register(IModRegistry registry) {
|
||||
registry.addRecipeCategories(
|
||||
new BreweryRecipeCategory(jeiHelpers.getGuiHelper())
|
||||
new BreweryRecipeCategory(jeiHelpers.getGuiHelper()),
|
||||
new PureDaisyRecipeCategory(jeiHelpers.getGuiHelper())
|
||||
);
|
||||
|
||||
registry.addRecipeHandlers(
|
||||
new BreweryRecipeHandler()
|
||||
new BreweryRecipeHandler(),
|
||||
new PureDaisyRecipeHandler()
|
||||
);
|
||||
|
||||
registry.addRecipes(BotaniaAPI.brewRecipes);
|
||||
registry.addRecipes(BotaniaAPI.pureDaisyRecipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
package vazkii.botania.client.integration.jei.puredaisy;
|
||||
|
||||
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 vazkii.botania.common.item.block.ItemBlockSpecialFlower;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
|
||||
public class PureDaisyRecipeCategory implements IRecipeCategory {
|
||||
|
||||
private final IDrawableStatic background;
|
||||
private final String localizedName;
|
||||
private final IDrawableStatic overlay;
|
||||
|
||||
private static final int inputSlot = 0;
|
||||
private static final int pureDaisySlot = 1;
|
||||
private static final int outputSlot = 2;
|
||||
|
||||
public PureDaisyRecipeCategory(IGuiHelper guiHelper) {
|
||||
ResourceLocation location = new ResourceLocation("botania", "textures/gui/neiBlank.png");
|
||||
background = guiHelper.createDrawable(location, 0, 0, 166, 65, 0, 0, 0, 0);
|
||||
localizedName = StatCollector.translateToLocal("botania.nei.pureDaisy");
|
||||
overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pureDaisyOverlay.png"),
|
||||
0, 0, 64, 46);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUid() {
|
||||
return "botania.pureDaisy";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return localizedName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
overlay.draw(minecraft, 48, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(Minecraft minecraft) {}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
if (!(recipeWrapper instanceof PureDaisyRecipeWrapper))
|
||||
return;
|
||||
|
||||
PureDaisyRecipeWrapper wrapper = ((PureDaisyRecipeWrapper) recipeWrapper);
|
||||
boolean inputFluid = wrapper.getInputs().isEmpty();
|
||||
boolean outputFluid = wrapper.getOutputs().isEmpty();
|
||||
|
||||
|
||||
if (inputFluid) {
|
||||
recipeLayout.getFluidStacks().init(inputSlot, true, 40, 12, 16, 16, 1000, false, null);
|
||||
recipeLayout.getFluidStacks().set(inputSlot, wrapper.getFluidInputs().get(0));
|
||||
} else {
|
||||
recipeLayout.getItemStacks().init(inputSlot, true, 40, 12);
|
||||
if (wrapper.getInputs().get(0) instanceof Collection) {
|
||||
recipeLayout.getItemStacks().set(inputSlot, ((Collection<ItemStack>) wrapper.getInputs().get(0)));
|
||||
} else {
|
||||
recipeLayout.getItemStacks().set(inputSlot, ((ItemStack) wrapper.getInputs().get(0)));
|
||||
}
|
||||
}
|
||||
|
||||
recipeLayout.getItemStacks().init(pureDaisySlot, true, 72, 12);
|
||||
recipeLayout.getItemStacks().set(pureDaisySlot, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY));
|
||||
|
||||
if (outputFluid) {
|
||||
recipeLayout.getFluidStacks().init(outputSlot, false, 99, 12, 16, 16, 1000, false, null);
|
||||
recipeLayout.getFluidStacks().set(outputSlot, wrapper.getFluidOutputs().get(0));
|
||||
} else {
|
||||
recipeLayout.getItemStacks().init(outputSlot, false, 99, 12);
|
||||
if (wrapper.getOutputs().get(0) instanceof Collection) {
|
||||
recipeLayout.getItemStacks().set(outputSlot, ((Collection<ItemStack>) wrapper.getOutputs().get(0)));
|
||||
} else {
|
||||
recipeLayout.getItemStacks().set(outputSlot, ((ItemStack) wrapper.getOutputs().get(0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package vazkii.botania.client.integration.jei.puredaisy;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import vazkii.botania.api.recipe.RecipePureDaisy;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class PureDaisyRecipeHandler implements IRecipeHandler<RecipePureDaisy> {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<RecipePureDaisy> getRecipeClass() {
|
||||
return RecipePureDaisy.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getRecipeCategoryUid() {
|
||||
return "botania.pureDaisy";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull RecipePureDaisy recipe) {
|
||||
return new PureDaisyRecipeWrapper(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(@Nonnull RecipePureDaisy recipe) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package vazkii.botania.client.integration.jei.puredaisy;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import vazkii.botania.api.recipe.RecipePureDaisy;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class PureDaisyRecipeWrapper implements IRecipeWrapper {
|
||||
|
||||
private List inputs = ImmutableList.of();
|
||||
private List outputs = ImmutableList.of();
|
||||
private List<FluidStack> fluidInputs = ImmutableList.of();
|
||||
private List<FluidStack> fluidOutputs = ImmutableList.of();
|
||||
|
||||
public PureDaisyRecipeWrapper(RecipePureDaisy recipe) {
|
||||
if (recipe.getInput() instanceof String) {
|
||||
inputs = ImmutableList.of(OreDictionary.getOres(((String) recipe.getInput())));
|
||||
} else if (recipe.getInput() instanceof Block) {
|
||||
Block b = ((Block) recipe.getInput());
|
||||
if (FluidRegistry.lookupFluidForBlock(b) != null) {
|
||||
fluidInputs = ImmutableList.of(new FluidStack(FluidRegistry.lookupFluidForBlock(b), 1000));
|
||||
} else {
|
||||
inputs = ImmutableList.of(new ItemStack(b, 1, b.getMetaFromState(b.getDefaultState())));
|
||||
}
|
||||
}
|
||||
|
||||
Block outBlock = recipe.getOutputState().getBlock();
|
||||
if (FluidRegistry.lookupFluidForBlock(outBlock) != null) {
|
||||
fluidOutputs = ImmutableList.of(new FluidStack(FluidRegistry.lookupFluidForBlock(outBlock), 1000));
|
||||
} else {
|
||||
outputs = ImmutableList.of(new ItemStack(outBlock, 1, outBlock.getMetaFromState(recipe.getOutputState())));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getInputs() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getOutputs() {
|
||||
return outputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidInputs() {
|
||||
return fluidInputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidOutputs() {
|
||||
return fluidOutputs;
|
||||
}
|
||||
|
||||
@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