mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 19:05:16 +00:00
Elven trade integration
This commit is contained in:
1 parent
10d095d656
commit
28249d1e33
4 files changed
+204
-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.elventrade.ElvenTradeRecipeCategory;
|
||||
import vazkii.botania.client.integration.jei.elventrade.ElvenTradeRecipeHandler;
|
||||
import vazkii.botania.client.integration.jei.petalapothecary.PetalApothecaryRecipeCategory;
|
||||
import vazkii.botania.client.integration.jei.petalapothecary.PetalApothecaryRecipeHandler;
|
||||
import vazkii.botania.client.integration.jei.puredaisy.PureDaisyRecipeCategory;
|
||||
@@ -51,18 +53,21 @@ public class JEIBotaniaPlugin implements IModPlugin {
|
||||
registry.addRecipeCategories(
|
||||
new BreweryRecipeCategory(jeiHelpers.getGuiHelper()),
|
||||
new PureDaisyRecipeCategory(jeiHelpers.getGuiHelper()),
|
||||
new PetalApothecaryRecipeCategory(jeiHelpers.getGuiHelper())
|
||||
new PetalApothecaryRecipeCategory(jeiHelpers.getGuiHelper()),
|
||||
new ElvenTradeRecipeCategory(jeiHelpers.getGuiHelper())
|
||||
);
|
||||
|
||||
registry.addRecipeHandlers(
|
||||
new BreweryRecipeHandler(),
|
||||
new PureDaisyRecipeHandler(),
|
||||
new PetalApothecaryRecipeHandler()
|
||||
new PetalApothecaryRecipeHandler(),
|
||||
new ElvenTradeRecipeHandler()
|
||||
);
|
||||
|
||||
registry.addRecipes(BotaniaAPI.brewRecipes);
|
||||
registry.addRecipes(BotaniaAPI.pureDaisyRecipes);
|
||||
registry.addRecipes(BotaniaAPI.petalRecipes);
|
||||
registry.addRecipes(BotaniaAPI.elvenTradeRecipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
package vazkii.botania.client.integration.jei.elventrade;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
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.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.client.core.handler.RenderEventHandler;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
|
||||
public class ElvenTradeRecipeCategory implements IRecipeCategory {
|
||||
|
||||
private final String localizedName;
|
||||
private final IDrawable background;
|
||||
private final IDrawable overlay;
|
||||
|
||||
public ElvenTradeRecipeCategory(IGuiHelper guiHelper) {
|
||||
localizedName = StatCollector.translateToLocal("botania.nei.elvenTrade");
|
||||
background = guiHelper.createBlankDrawable(145, 95);
|
||||
overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/elvenTradeOverlay.png"), 0, 15, 140, 90);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUid() {
|
||||
return "botania.elvenTrade";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return localizedName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
overlay.draw(minecraft, 0, 4);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.disableAlpha();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(Minecraft minecraft) {
|
||||
minecraft.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
||||
TextureAtlasSprite sprite = RenderEventHandler.INSTANCE.alfPortalTex;
|
||||
Tessellator tess = Tessellator.getInstance();
|
||||
WorldRenderer wr = tess.getWorldRenderer();
|
||||
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||
int startX = 22;
|
||||
int startY = 25;
|
||||
int stopX = 70;
|
||||
int stopY = 73;
|
||||
wr.pos(startX, startY, 0).tex(sprite.getMinU(), sprite.getMinV()).endVertex();
|
||||
wr.pos(startX, stopY, 0).tex(sprite.getMinU(), sprite.getMaxV()).endVertex();
|
||||
wr.pos(stopX, stopY, 0).tex(sprite.getMaxU(), sprite.getMaxV()).endVertex();
|
||||
wr.pos(stopX, startY, 0).tex(sprite.getMaxU(), sprite.getMinV()).endVertex();
|
||||
tess.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
if (!(recipeWrapper instanceof ElvenTradeRecipeWrapper))
|
||||
return;
|
||||
ElvenTradeRecipeWrapper wrapper = ((ElvenTradeRecipeWrapper) recipeWrapper);
|
||||
|
||||
int index = 0, posX = 42;
|
||||
for (Object o : wrapper.getInputs()) {
|
||||
recipeLayout.getItemStacks().init(index, true, posX, 0);
|
||||
if (o instanceof Collection) {
|
||||
recipeLayout.getItemStacks().set(index, ((Collection<ItemStack>) o));
|
||||
} else {
|
||||
recipeLayout.getItemStacks().set(index, ((ItemStack) o));
|
||||
}
|
||||
index++;
|
||||
posX += 18;
|
||||
}
|
||||
|
||||
recipeLayout.getItemStacks().init(index, false, 93, 41);
|
||||
recipeLayout.getItemStacks().set(index, wrapper.getOutputs().get(0));
|
||||
}
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package vazkii.botania.client.integration.jei.elventrade;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import vazkii.botania.api.recipe.RecipeElvenTrade;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ElvenTradeRecipeHandler implements IRecipeHandler<RecipeElvenTrade> {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<RecipeElvenTrade> getRecipeClass() {
|
||||
return RecipeElvenTrade.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getRecipeCategoryUid() {
|
||||
return "botania.elvenTrade";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull RecipeElvenTrade recipe) {
|
||||
return new ElvenTradeRecipeWrapper(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(@Nonnull RecipeElvenTrade recipe) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package vazkii.botania.client.integration.jei.elventrade;
|
||||
|
||||
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.RecipeElvenTrade;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class ElvenTradeRecipeWrapper implements IRecipeWrapper {
|
||||
|
||||
private final List input;
|
||||
private final ItemStack output;
|
||||
|
||||
public ElvenTradeRecipeWrapper(RecipeElvenTrade recipe) {
|
||||
ImmutableList.Builder builder = ImmutableList.builder();
|
||||
for (Object o : recipe.getInputs()) {
|
||||
if (o instanceof ItemStack) {
|
||||
builder.add(o);
|
||||
}
|
||||
if (o instanceof String) {
|
||||
builder.add(OreDictionary.getOres(((String) o)));
|
||||
}
|
||||
}
|
||||
input = builder.build();
|
||||
output = recipe.getOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getInputs() {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getOutputs() {
|
||||
return ImmutableList.of(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