Chemical reactor GUI & a couple recipe fixes

This commit is contained in:
ProfessorProspector 2017-01-09 16:54:48 -08:00
parent 99be70713b
commit af91263621
8 changed files with 58 additions and 73 deletions

View file

@ -1,62 +1,38 @@
package techreborn.client.gui; package techreborn.client.gui;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import techreborn.tiles.TileChemicalReactor; import techreborn.tiles.TileChemicalReactor;
public class GuiChemicalReactor extends GuiContainer { public class GuiChemicalReactor extends GuiBase {
public static final ResourceLocation texture = new ResourceLocation("techreborn", TileChemicalReactor tile;
"textures/gui/chemical_reactor.png");
TileChemicalReactor chemicalReactor; public GuiChemicalReactor(final EntityPlayer player, final TileChemicalReactor tile) {
super(player, tile, tile.createContainer(player));
public GuiChemicalReactor(final EntityPlayer player, final TileChemicalReactor chemicalReactor) { this.tile = tile;
super(chemicalReactor.createContainer(player));
this.xSize = 176;
this.ySize = 167;
this.chemicalReactor = chemicalReactor;
} }
@Override @Override
public void initGui() { protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
final int k = (this.width - this.xSize) / 2; super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
final int l = (this.height - this.ySize) / 2; final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND;
super.initGui();
this.drawSlot(8, 72, layer);
this.drawSlot(34, 47, layer);
this.drawSlot(126, 47, layer);
this.drawOutputSlot(80, 47, layer);
this.builder.drawJEIButton(this, 150, 4, layer);
} }
@Override @Override
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) { protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); super.drawGuiContainerForegroundLayer(mouseX, mouseY);
this.mc.getTextureManager().bindTexture(GuiChemicalReactor.texture); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
final int k = (this.width - this.xSize) / 2;
final int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0; this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 55, 51, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer);
this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 105, 51, mouseX, mouseY, TRBuilder.ProgressDirection.LEFT, layer);
j = this.chemicalReactor.getProgressScaled(11); this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer);
if (j > 0) {
this.drawTexturedModalRect(k + 73, l + 39, 177, 15, 30, j);
}
j = this.chemicalReactor.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 9, l + 32 + 12 - j, 176, 12 - j, 14, j + 2);
}
}
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.chemicalreactor.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
} }
} }

View file

@ -84,6 +84,13 @@ public class TRBuilder extends GuiBuilder {
gui.drawTexturedModalRect(x, y, direction.xActive, direction.yActive, j, 10); gui.drawTexturedModalRect(x, y, direction.xActive, direction.yActive, j, 10);
} }
if (direction.equals(ProgressDirection.LEFT)) {
int j = (int) ((double) progress / (double) maxProgress * 16);
if (j < 0)
j = 0;
gui.drawTexturedModalRect(x + 16 - j, y, direction.xActive + 16 - j, direction.yActive, j, 10);
}
if (isInRect(x, y, direction.width, direction.height, mouseX, mouseY)) { if (isInRect(x, y, direction.width, direction.height, mouseX, mouseY)) {
int percentage = percentage(maxProgress, progress); int percentage = percentage(maxProgress, progress);
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
@ -247,7 +254,7 @@ public class TRBuilder extends GuiBuilder {
} }
public enum ProgressDirection { public enum ProgressDirection {
RIGHT(84, 151, 100, 151, 16, 10)/*, DOWN(104, 171, 114, 171, 10, 16), UP(84, 171, 94, 171, 10, 16), LEFT(84, 161, 100, 161, 16, 10)*/; RIGHT(84, 151, 100, 151, 16, 10), LEFT(100, 161, 84, 161, 16, 10)/*, DOWN(104, 171, 114, 171, 10, 16), UP(84, 171, 94, 171, 10, 16)*/;
public int x; public int x;
public int y; public int y;
public int xActive; public int xActive;

View file

@ -211,13 +211,13 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
registry.addRecipeClickArea(GuiGrinder.class, 150, 4, 20, 12, RecipeCategoryUids.GRINDER); registry.addRecipeClickArea(GuiGrinder.class, 150, 4, 20, 12, RecipeCategoryUids.GRINDER);
registry.addRecipeClickArea(GuiVacuumFreezer.class, 150, 4, 20, 12, RecipeCategoryUids.VACUUM_FREEZER); registry.addRecipeClickArea(GuiVacuumFreezer.class, 150, 4, 20, 12, RecipeCategoryUids.VACUUM_FREEZER);
registry.addRecipeClickArea(GuiBlastFurnace.class, 150, 4, 20, 12, RecipeCategoryUids.BLAST_FURNACE); registry.addRecipeClickArea(GuiBlastFurnace.class, 150, 4, 20, 12, RecipeCategoryUids.BLAST_FURNACE);
registry.addRecipeClickArea(GuiChemicalReactor.class, 150, 4, 20, 12, RecipeCategoryUids.CHEMICAL_REACTOR);
//OLD ONES //OLD ONES
registry.addRecipeClickArea(GuiAlloyFurnace.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER, registry.addRecipeClickArea(GuiAlloyFurnace.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER,
VanillaRecipeCategoryUid.FUEL); VanillaRecipeCategoryUid.FUEL);
registry.addRecipeClickArea(GuiAlloySmelter.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER); registry.addRecipeClickArea(GuiAlloySmelter.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER);
registry.addRecipeClickArea(GuiAssemblingMachine.class, 85, 34, 24, 20, RecipeCategoryUids.ASSEMBLING_MACHINE); registry.addRecipeClickArea(GuiAssemblingMachine.class, 85, 34, 24, 20, RecipeCategoryUids.ASSEMBLING_MACHINE);
registry.addRecipeClickArea(GuiChemicalReactor.class, 73, 39, 32, 12, RecipeCategoryUids.CHEMICAL_REACTOR);
registry.addRecipeClickArea(GuiFusionReactor.class, 111, 34, 27, 19, RecipeCategoryUids.FUSION_REACTOR); registry.addRecipeClickArea(GuiFusionReactor.class, 111, 34, 27, 19, RecipeCategoryUids.FUSION_REACTOR);
registry.addRecipeClickArea(GuiIndustrialGrinder.class, 50, 35, 25, 16, RecipeCategoryUids.INDUSTRIAL_GRINDER); registry.addRecipeClickArea(GuiIndustrialGrinder.class, 50, 35, 25, 16, RecipeCategoryUids.INDUSTRIAL_GRINDER);
registry.addRecipeClickArea(GuiImplosionCompressor.class, 60, 37, 24, 15, registry.addRecipeClickArea(GuiImplosionCompressor.class, 60, 37, 24, 15,

View file

@ -6,14 +6,15 @@ import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.BlankRecipeCategory;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n; import net.minecraft.util.text.translation.I18n;
import techreborn.client.gui.GuiChemicalReactor;
import techreborn.compat.jei.RecipeCategoryUids; import techreborn.compat.jei.RecipeCategoryUids;
import techreborn.compat.jei.RecipeUtil; import techreborn.compat.jei.RecipeUtil;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public class ChemicalReactorRecipeCategory extends BlankRecipeCategory<ChemicalReactorRecipeWrapper> { public class ChemicalReactorRecipeCategory extends BlankRecipeCategory<ChemicalReactorRecipeWrapper> {
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png");
private static final int[] INPUT_SLOTS = { 0, 1 }; private static final int[] INPUT_SLOTS = { 0, 1 };
private static final int[] OUTPUT_SLOTS = { 2 }; private static final int[] OUTPUT_SLOTS = { 2 };
@ -21,7 +22,7 @@ public class ChemicalReactorRecipeCategory extends BlankRecipeCategory<ChemicalR
private final String title; private final String title;
public ChemicalReactorRecipeCategory(IGuiHelper guiHelper) { public ChemicalReactorRecipeCategory(IGuiHelper guiHelper) {
background = guiHelper.createDrawable(GuiChemicalReactor.texture, 69, 20, 38, 48); background = guiHelper.createDrawable(texture, 0, 172, 116, 52);
title = I18n.translateToLocal("tile.techreborn.chemicalreactor.name"); title = I18n.translateToLocal("tile.techreborn.chemicalreactor.name");
} }
@ -52,10 +53,10 @@ public class ChemicalReactorRecipeCategory extends BlankRecipeCategory<ChemicalR
@Nonnull @Nonnull
IIngredients ingredients) { IIngredients ingredients) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
guiItemStacks.init(INPUT_SLOTS[0], true, 0, 0); guiItemStacks.init(INPUT_SLOTS[0], true, 3, 7);
guiItemStacks.init(INPUT_SLOTS[1], true, 20, 0); guiItemStacks.init(INPUT_SLOTS[1], true, 95, 7);
guiItemStacks.init(OUTPUT_SLOTS[0], false, 10, 30); guiItemStacks.init(OUTPUT_SLOTS[0], false, 49, 7);
RecipeUtil.setRecipeItems(recipeLayout, ingredients, INPUT_SLOTS, OUTPUT_SLOTS, null, null); RecipeUtil.setRecipeItems(recipeLayout, ingredients, INPUT_SLOTS, OUTPUT_SLOTS, null, null);
} }

View file

@ -5,14 +5,16 @@ import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.gui.IDrawableAnimated; import mezz.jei.api.gui.IDrawableAnimated;
import mezz.jei.api.gui.IDrawableStatic; import mezz.jei.api.gui.IDrawableStatic;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import reborncore.common.powerSystem.PowerSystem;
import techreborn.api.recipe.machines.ChemicalReactorRecipe; import techreborn.api.recipe.machines.ChemicalReactorRecipe;
import techreborn.client.gui.GuiChemicalReactor; import techreborn.client.gui.TRBuilder;
import techreborn.compat.jei.BaseRecipeWrapper; import techreborn.compat.jei.BaseRecipeWrapper;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public class ChemicalReactorRecipeWrapper extends BaseRecipeWrapper<ChemicalReactorRecipe> { public class ChemicalReactorRecipeWrapper extends BaseRecipeWrapper<ChemicalReactorRecipe> {
private final IDrawableAnimated progress; private final IDrawableAnimated progressright;
private final IDrawableAnimated progressleft;
public ChemicalReactorRecipeWrapper( public ChemicalReactorRecipeWrapper(
@Nonnull @Nonnull
@ -21,23 +23,25 @@ public class ChemicalReactorRecipeWrapper extends BaseRecipeWrapper<ChemicalReac
ChemicalReactorRecipe baseRecipe) { ChemicalReactorRecipe baseRecipe) {
super(baseRecipe); super(baseRecipe);
IGuiHelper guiHelper = jeiHelpers.getGuiHelper(); IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
IDrawableStatic progressStatic = guiHelper.createDrawable(GuiChemicalReactor.texture, 176, 14, 32, 12); IDrawableStatic progressrightStatic = guiHelper.createDrawable(TRBuilder.GUI_SHEET, 100, 151, 16, 10);
IDrawableStatic progressleftStatic = guiHelper.createDrawable(TRBuilder.GUI_SHEET, 84, 161, 16, 10);
int ticksPerCycle = baseRecipe.tickTime(); int ticksPerCycle = baseRecipe.tickTime(); // speed up the animation
this.progress = guiHelper.createAnimatedDrawable(progressStatic, ticksPerCycle,
IDrawableAnimated.StartDirection.TOP, false); this.progressright = guiHelper.createAnimatedDrawable(progressrightStatic, ticksPerCycle, IDrawableAnimated.StartDirection.LEFT, false);
this.progressleft = guiHelper.createAnimatedDrawable(progressleftStatic, ticksPerCycle, IDrawableAnimated.StartDirection.RIGHT, false);
} }
@Override @Override
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
progress.draw(minecraft, 3, 18); progressright.draw(minecraft, 25, 12);
progressleft.draw(minecraft, 75, 12);
int x = (int) (-recipeWidth * 1.6f); int y = 30 ;
int y = (int) (recipeHeight - recipeHeight / 3F);
int lineHeight = minecraft.fontRendererObj.FONT_HEIGHT; int lineHeight = minecraft.fontRendererObj.FONT_HEIGHT;
minecraft.fontRendererObj.drawString("Time: " + baseRecipe.tickTime / 20 + " secs", x, y, 0x444444); minecraft.fontRendererObj.drawString(baseRecipe.tickTime / 20 + " seconds", (recipeWidth / 2 - minecraft.fontRendererObj.getStringWidth(baseRecipe.tickTime / 20 + " seconds") / 2), y, 0x444444);
minecraft.fontRendererObj.drawString("EU: " + baseRecipe.euPerTick + " EU/t", x, y += lineHeight, 0x444444); minecraft.fontRendererObj.drawString(PowerSystem.getLocaliszedPowerFormatted(baseRecipe.euPerTick * baseRecipe.tickTime), (recipeWidth / 2 - minecraft.fontRendererObj.getStringWidth(PowerSystem.getLocaliszedPowerFormatted(baseRecipe.euPerTick * baseRecipe.tickTime)) / 2), y + lineHeight, 0x444444);
} }
} }

View file

@ -15,11 +15,11 @@ public class RollingMachineRecipes extends RecipeMethods {
if (oresExist("ingotAluminum")) { if (oresExist("ingotAluminum")) {
register(getMaterial("kanthal_heating_coil", 3, Type.PART), "RRR", "CAA", "CCA", 'R', "ingotRefinedIron", 'C', "ingotChrome", 'A', "ingotAluminum"); register(getMaterial("kanthal_heating_coil", 3, Type.PART), "RRR", "CAA", "CCA", 'R', "ingotRefinedIron", 'C', "ingotChrome", 'A', "ingotAluminum");
} }
if (oresExist("ingotAluminum")) { if (oresExist("ingotAluminium")) {
register(getMaterial("kanthal_heating_coil", 3, Type.PART), "RRR", "CAA", "CCA", 'R', "ingotRefinedIron", 'C', "ingotChrome", 'A', "ingotAluminium"); register(getMaterial("kanthal_heating_coil", 3, Type.PART), "RRR", "CAA", "CCA", 'R', "ingotRefinedIron", 'C', "ingotChrome", 'A', "ingotAluminium");
} }
register(getStack(Blocks.RAIL, 24), "I I", "ISI", "I I", 'I', "ingotIron", 'S', "stickWood"); register(getStack(Blocks.RAIL, 24), "I I", "ISI", "I I", 'I', "ingotIron", 'S', "stickWood");
register(getStack(Blocks.GOLDEN_RAIL, 8), "I I", "ISI", "IRI", 'I', "ingotIron", 'S', "stickWood", 'R', "dustRedstone"); register(getStack(Blocks.GOLDEN_RAIL, 8), "I I", "ISI", "IRI", 'I', "ingotGold", 'S', "stickWood", 'R', "dustRedstone");
register(getStack(Blocks.DETECTOR_RAIL, 8), "I I", "IPI", "IRI", 'I', "ingotIron", 'P', getStack(Blocks.STONE_PRESSURE_PLATE), 'R', "dustRedstone"); register(getStack(Blocks.DETECTOR_RAIL, 8), "I I", "IPI", "IRI", 'I', "ingotIron", 'P', getStack(Blocks.STONE_PRESSURE_PLATE), 'R', "dustRedstone");
register(getStack(Blocks.ACTIVATOR_RAIL, 8), "ISI", "IRI", "ISI", 'I', "ingotIron", 'S', "stickWood", 'R', getStack(Blocks.REDSTONE_TORCH)); register(getStack(Blocks.ACTIVATOR_RAIL, 8), "ISI", "IRI", "ISI", 'I', "ingotIron", 'S', "stickWood", 'R', getStack(Blocks.REDSTONE_TORCH));
register(getStack(Blocks.IRON_BARS, 24), "III", "III", 'I', "ingotIron"); register(getStack(Blocks.IRON_BARS, 24), "III", "III", 'I', "ingotIron");

View file

@ -5,7 +5,6 @@ import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
@ -13,7 +12,6 @@ import reborncore.common.IWrenchable;
import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.client.container.IContainerProvider; import techreborn.client.container.IContainerProvider;
import techreborn.client.container.builder.BuiltContainer; import techreborn.client.container.builder.BuiltContainer;
@ -21,7 +19,7 @@ import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
public class TileChemicalReactor extends TilePowerAcceptor public class TileChemicalReactor extends TilePowerAcceptor
implements IWrenchable, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider, IContainerProvider { implements IWrenchable, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider, IContainerProvider {
public int tickTime; public int tickTime;
public Inventory inventory = new Inventory(8, "TileChemicalReactor", 64, this); public Inventory inventory = new Inventory(8, "TileChemicalReactor", 64, this);
@ -164,9 +162,8 @@ implements IWrenchable, IInventoryProvider, ISidedInventory, IRecipeCrafterProvi
@Override @Override
public BuiltContainer createContainer(final EntityPlayer player) { public BuiltContainer createContainer(final EntityPlayer player) {
return new ContainerBuilder("chemicalreactor").player(player.inventory).inventory(8, 84).hotbar(8, 142) return new ContainerBuilder("chemicalreactor").player(player.inventory).inventory().hotbar()
.addInventory().tile(this).slot(0, 70, 21).slot(1, 90, 21).outputSlot(2, 80, 51).energySlot(3, 8, 51) .addInventory().tile(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).energySlot(3, 8, 72)
.upgradeSlot(4, 152, 8).upgradeSlot(5, 152, 26).upgradeSlot(6, 152, 44).upgradeSlot(7, 152, 62) .syncEnergyValue().syncCrafterValue().addInventory().create();
.syncEnergyValue().syncCrafterValue().addInventory().create();
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB