Add alloy furnace recipes

This commit is contained in:
mezz 2015-12-30 21:17:20 -08:00
parent 202555b4ac
commit 4b804c3521
13 changed files with 253 additions and 43 deletions

View file

@ -10,7 +10,7 @@ import techreborn.tiles.TileAlloySmelter;
public class GuiAlloySmelter extends GuiContainer { public class GuiAlloySmelter extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/electric_alloy_furnace.png"); public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/electric_alloy_furnace.png");
TileAlloySmelter alloysmelter; TileAlloySmelter alloysmelter;

View file

@ -0,0 +1,34 @@
package techreborn.compat.jei;
import javax.annotation.Nonnull;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import techreborn.api.recipe.BaseRecipe;
public abstract class BaseRecipeWrapper extends BlankRecipeWrapper {
protected final BaseRecipe baseRecipe;
public BaseRecipeWrapper(BaseRecipe baseRecipe) {
this.baseRecipe = baseRecipe;
}
@Override
public List<ItemStack> getInputs() {
return baseRecipe.getInputs();
}
@Override
public List<ItemStack> getOutputs() {
return baseRecipe.getOutputs();
}
@Override
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
// TODO: make right location for each recipe
// RecipeInfoUtil.drawInfo(minecraft, 0, 0, baseRecipe.euPerTick(), baseRecipe.tickTime());
}
}

View file

@ -0,0 +1,9 @@
package techreborn.compat.jei;
public class RecipeCategoryUids {
private RecipeCategoryUids() {
}
public static final String ALLOY_SMELTER = "AlloySmelter";
public static final String FUSION_REACTOR = "FusionReactor";
}

View file

@ -0,0 +1,46 @@
package techreborn.compat.jei;
import javax.annotation.Nonnull;
import java.awt.Color;
import java.text.NumberFormat;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.util.StatCollector;
public class RecipeInfoUtil {
private static final int color = Color.darkGray.getRGB();
private RecipeInfoUtil() {
}
public static void drawInfo(@Nonnull Minecraft minecraft, int x, int y, final double startCost, final double euPerTick, final int tickTime) {
FontRenderer fontRendererObj = minecraft.fontRendererObj;
int lineSpacing = fontRendererObj.FONT_HEIGHT + 1;
NumberFormat formatter = NumberFormat.getInstance();
String startCostEU = formatter.format(startCost);
String startCostString = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.start.cost", startCostEU);
fontRendererObj.drawString(startCostString, x, y, color);
y += lineSpacing;
drawInfo(minecraft, x, y, euPerTick, tickTime);
}
public static void drawInfo(@Nonnull Minecraft minecraft, int x, int y, final double euPerTick, final int tickTime) {
FontRenderer fontRendererObj = minecraft.fontRendererObj;
int lineSpacing = fontRendererObj.FONT_HEIGHT + 1;
String runningCostString = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.running.cost", euPerTick);
fontRendererObj.drawString(runningCostString, x, y, color);
y += lineSpacing;
String processingTimeString1 = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.processing.time.1", tickTime);
fontRendererObj.drawString(processingTimeString1, x, y, color);
y += lineSpacing;
int seconds = tickTime / 20;
String processingTimeString2 = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.processing.time.2", seconds);
fontRendererObj.drawString(processingTimeString2, x + 10, y, color);
}
}

View file

@ -1,7 +0,0 @@
package techreborn.compat.jei;
public class TechRebornCategoryUids {
private TechRebornCategoryUids() {}
public static final String FUSION_REACTOR = "FusionReactor";
}

View file

@ -6,15 +6,21 @@ import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.IModPlugin; import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry; import mezz.jei.api.IModRegistry;
import mezz.jei.api.IRecipeRegistry; import mezz.jei.api.IRecipeRegistry;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry; import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
import techreborn.api.reactor.FusionReactorRecipeHelper; import techreborn.api.reactor.FusionReactorRecipeHelper;
import techreborn.api.recipe.RecipeHandler;
import techreborn.client.container.ContainerAlloyFurnace;
import techreborn.client.container.ContainerAlloySmelter;
import techreborn.client.container.ContainerFusionReactor; import techreborn.client.container.ContainerFusionReactor;
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeCategory;
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeHandler;
import techreborn.compat.jei.fusionReactor.FusionReactorRecipeCategory; import techreborn.compat.jei.fusionReactor.FusionReactorRecipeCategory;
import techreborn.compat.jei.fusionReactor.FusionReactorRecipeHandler; import techreborn.compat.jei.fusionReactor.FusionReactorRecipeHandler;
@mezz.jei.api.JEIPlugin @mezz.jei.api.JEIPlugin
public class TechRebornJeiPlugin implements IModPlugin { public class TechRebornJeiPlugin implements IModPlugin {
private IJeiHelpers jeiHelpers; public static IJeiHelpers jeiHelpers;
@Override @Override
public boolean isModLoaded() { public boolean isModLoaded() {
@ -23,7 +29,7 @@ public class TechRebornJeiPlugin implements IModPlugin {
@Override @Override
public void onJeiHelpersAvailable(IJeiHelpers jeiHelpers) { public void onJeiHelpersAvailable(IJeiHelpers jeiHelpers) {
this.jeiHelpers = jeiHelpers; TechRebornJeiPlugin.jeiHelpers = jeiHelpers;
} }
@Override @Override
@ -36,17 +42,23 @@ public class TechRebornJeiPlugin implements IModPlugin {
IGuiHelper guiHelper = jeiHelpers.getGuiHelper(); IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
registry.addRecipeCategories( registry.addRecipeCategories(
new AlloySmelterRecipeCategory(guiHelper),
new FusionReactorRecipeCategory(guiHelper) new FusionReactorRecipeCategory(guiHelper)
); );
registry.addRecipeHandlers( registry.addRecipeHandlers(
new AlloySmelterRecipeHandler(),
new FusionReactorRecipeHandler() new FusionReactorRecipeHandler()
); );
registry.addRecipes(RecipeHandler.recipeList);
registry.addRecipes(FusionReactorRecipeHelper.reactorRecipes); registry.addRecipes(FusionReactorRecipeHelper.reactorRecipes);
IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry(); IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry();
recipeTransferRegistry.addRecipeTransferHandler(ContainerFusionReactor.class, TechRebornCategoryUids.FUSION_REACTOR, 0, 2, 3, 36); recipeTransferRegistry.addRecipeTransferHandler(ContainerAlloyFurnace.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 4, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerAlloySmelter.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 8, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerAlloyFurnace.class, VanillaRecipeCategoryUid.FUEL, 3, 1, 4, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerFusionReactor.class, RecipeCategoryUids.FUSION_REACTOR, 0, 2, 3, 36);
} }
@Override @Override

View file

@ -0,0 +1,77 @@
package techreborn.compat.jei.alloySmelter;
import javax.annotation.Nonnull;
import net.minecraft.client.Minecraft;
import net.minecraft.util.StatCollector;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IDrawableAnimated;
import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.client.gui.GuiAlloySmelter;
import techreborn.compat.jei.RecipeCategoryUids;
public class AlloySmelterRecipeCategory implements IRecipeCategory {
private static final int INPUT_SLOT_0 = 0;
private static final int INPUT_SLOT_1 = 1;
private static final int OUTPUT_SLOT = 2;
private final IDrawable background;
private final IDrawableAnimated electricity;
private final String title;
public AlloySmelterRecipeCategory(IGuiHelper guiHelper) {
background = guiHelper.createDrawable(GuiAlloySmelter.texture, 46, 16, 91, 54);
IDrawableStatic flameDrawable = guiHelper.createDrawable(GuiAlloySmelter.texture, 176, 0, 14, 14);
electricity = guiHelper.createAnimatedDrawable(flameDrawable, 300, IDrawableAnimated.StartDirection.TOP, true);
title = StatCollector.translateToLocal("techreborn.jei.category.alloy.furnace");
}
@Nonnull
@Override
public String getUid() {
return RecipeCategoryUids.ALLOY_SMELTER;
}
@Nonnull
@Override
public String getTitle() {
return title;
}
@Nonnull
@Override
public IDrawable getBackground() {
return background;
}
@Override
public void drawExtras(Minecraft minecraft) {
}
@Override
public void drawAnimations(Minecraft minecraft) {
electricity.draw(minecraft, 10, 20);
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
guiItemStacks.init(INPUT_SLOT_0, true, 0, 0);
guiItemStacks.init(INPUT_SLOT_1, true, 18, 0);
guiItemStacks.init(OUTPUT_SLOT, false, 69, 18);
if (recipeWrapper instanceof AlloySmelterRecipeWrapper) {
AlloySmelterRecipeWrapper alloySmelterRecipe = (AlloySmelterRecipeWrapper) recipeWrapper;
guiItemStacks.set(INPUT_SLOT_0, alloySmelterRecipe.getInputs().get(0));
guiItemStacks.set(INPUT_SLOT_1, alloySmelterRecipe.getInputs().get(1));
guiItemStacks.set(OUTPUT_SLOT, alloySmelterRecipe.getOutputs());
}
}
}

View file

@ -0,0 +1,33 @@
package techreborn.compat.jei.alloySmelter;
import javax.annotation.Nonnull;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.api.recipe.machines.AlloySmelterRecipe;
import techreborn.compat.jei.RecipeCategoryUids;
public class AlloySmelterRecipeHandler implements IRecipeHandler<AlloySmelterRecipe> {
@Nonnull
@Override
public Class<AlloySmelterRecipe> getRecipeClass() {
return AlloySmelterRecipe.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
return RecipeCategoryUids.ALLOY_SMELTER;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull AlloySmelterRecipe recipe) {
return new AlloySmelterRecipeWrapper(recipe);
}
@Override
public boolean isRecipeValid(@Nonnull AlloySmelterRecipe recipe) {
return true;
}
}

View file

@ -0,0 +1,30 @@
package techreborn.compat.jei.alloySmelter;
import javax.annotation.Nonnull;
import net.minecraft.client.Minecraft;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawableAnimated;
import mezz.jei.api.gui.IDrawableStatic;
import techreborn.api.recipe.machines.AlloySmelterRecipe;
import techreborn.client.gui.GuiAlloySmelter;
import techreborn.compat.jei.BaseRecipeWrapper;
import techreborn.compat.jei.TechRebornJeiPlugin;
public class AlloySmelterRecipeWrapper extends BaseRecipeWrapper {
private final IDrawableAnimated arrow;
public AlloySmelterRecipeWrapper(AlloySmelterRecipe baseRecipe) {
super(baseRecipe);
IGuiHelper guiHelper = TechRebornJeiPlugin.jeiHelpers.getGuiHelper();
IDrawableStatic arrowStatic = guiHelper.createDrawable(GuiAlloySmelter.texture, 176, 14, 24, 17);
this.arrow = guiHelper.createAnimatedDrawable(arrowStatic, baseRecipe.tickTime(), IDrawableAnimated.StartDirection.LEFT, false);
}
@Override
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
super.drawAnimations(minecraft, recipeWidth, recipeHeight);
arrow.draw(minecraft, 33, 19);
}
}

View file

@ -12,7 +12,7 @@ import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.IRecipeCategory; import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.client.gui.GuiFusionReactor; import techreborn.client.gui.GuiFusionReactor;
import techreborn.compat.jei.TechRebornCategoryUids; import techreborn.compat.jei.RecipeCategoryUids;
public class FusionReactorRecipeCategory implements IRecipeCategory { public class FusionReactorRecipeCategory implements IRecipeCategory {
@ -33,7 +33,7 @@ public class FusionReactorRecipeCategory implements IRecipeCategory {
@Nonnull @Nonnull
@Override @Override
public String getUid() { public String getUid() {
return TechRebornCategoryUids.FUSION_REACTOR; return RecipeCategoryUids.FUSION_REACTOR;
} }
@Nonnull @Nonnull

View file

@ -5,7 +5,7 @@ import javax.annotation.Nonnull;
import mezz.jei.api.recipe.IRecipeHandler; import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.api.reactor.FusionReactorRecipe; import techreborn.api.reactor.FusionReactorRecipe;
import techreborn.compat.jei.TechRebornCategoryUids; import techreborn.compat.jei.RecipeCategoryUids;
public class FusionReactorRecipeHandler implements IRecipeHandler<FusionReactorRecipe> { public class FusionReactorRecipeHandler implements IRecipeHandler<FusionReactorRecipe> {
@ -18,7 +18,7 @@ public class FusionReactorRecipeHandler implements IRecipeHandler<FusionReactorR
@Nonnull @Nonnull
@Override @Override
public String getRecipeCategoryUid() { public String getRecipeCategoryUid() {
return TechRebornCategoryUids.FUSION_REACTOR; return RecipeCategoryUids.FUSION_REACTOR;
} }
@Nonnull @Nonnull

View file

@ -1,19 +1,16 @@
package techreborn.compat.jei.fusionReactor; package techreborn.compat.jei.fusionReactor;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.awt.Color;
import java.text.NumberFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import mezz.jei.api.recipe.BlankRecipeWrapper; import mezz.jei.api.recipe.BlankRecipeWrapper;
import techreborn.api.reactor.FusionReactorRecipe; import techreborn.api.reactor.FusionReactorRecipe;
import techreborn.compat.jei.RecipeInfoUtil;
public class FusionReactorRecipeWrapper extends BlankRecipeWrapper { public class FusionReactorRecipeWrapper extends BlankRecipeWrapper {
private FusionReactorRecipe baseRecipe; private FusionReactorRecipe baseRecipe;
@ -42,29 +39,6 @@ public class FusionReactorRecipeWrapper extends BlankRecipeWrapper {
@Override @Override
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) { public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
FontRenderer fontRendererObj = minecraft.fontRendererObj; RecipeInfoUtil.drawInfo(minecraft, 0, 67, baseRecipe.getStartEU(), baseRecipe.getEuTick(), baseRecipe.getTickTime());
int color = Color.darkGray.getRGB();
int x = 0;
int y = 67;
int lineSpacing = fontRendererObj.FONT_HEIGHT + 1;
NumberFormat formatter = NumberFormat.getInstance();
String startCostEU = formatter.format(baseRecipe.getStartEU());
String startCostString = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.start.cost", startCostEU);
fontRendererObj.drawString(startCostString, x, y, color);
y += lineSpacing;
String runningCostString = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.running.cost", baseRecipe.getEuTick());
fontRendererObj.drawString(runningCostString, x, y, color);
y += lineSpacing;
int ticks = baseRecipe.getTickTime();
String processingTimeString1 = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.processing.time.1", ticks);
fontRendererObj.drawString(processingTimeString1, x, y, color);
y += lineSpacing;
int seconds = ticks / 20;
String processingTimeString2 = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.processing.time.2", seconds);
fontRendererObj.drawString(processingTimeString2, x + 10, y, color);
} }
} }

View file

@ -907,3 +907,5 @@ techreborn.jei.recipe.start.cost=Start: %sEU
techreborn.jei.recipe.running.cost=EU/t: %s techreborn.jei.recipe.running.cost=EU/t: %s
techreborn.jei.recipe.processing.time.1=Time: %s ticks techreborn.jei.recipe.processing.time.1=Time: %s ticks
techreborn.jei.recipe.processing.time.2=(%s seconds) techreborn.jei.recipe.processing.time.2=(%s seconds)
techreborn.jei.category.alloy.furnace=Alloy Furnace