Generator gui!
This commit is contained in:
parent
cd33860403
commit
eea9b83a9c
6 changed files with 131 additions and 132 deletions
|
@ -1,63 +1,35 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
|
||||
import techreborn.tiles.generator.TileGenerator;
|
||||
|
||||
public class GuiGenerator extends GuiContainer {
|
||||
public class GuiGenerator extends GuiBase {
|
||||
|
||||
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/generator.png");
|
||||
TileGenerator tile;
|
||||
|
||||
TileGenerator generator;
|
||||
|
||||
public GuiGenerator(final EntityPlayer player, final TileGenerator generator) {
|
||||
super(generator.createContainer(player));
|
||||
this.xSize = 176;
|
||||
this.ySize = 167;
|
||||
this.generator = generator;
|
||||
public GuiGenerator(final EntityPlayer player, final TileGenerator tile) {
|
||||
super(player, tile, tile.createContainer(player));
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
final int k = (this.width - this.xSize) / 2;
|
||||
final int l = (this.height - this.ySize) / 2;
|
||||
super.initGui();
|
||||
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
final Layer layer = Layer.BACKGROUND;
|
||||
|
||||
this.drawSlot(8, 72, layer);
|
||||
|
||||
this.drawSlot(80, 54, layer);
|
||||
|
||||
this.builder.drawJEIButton(this, 150, 4, mouseX, mouseY, layer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
|
||||
this.mc.getTextureManager().bindTexture(GuiGenerator.texture);
|
||||
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);
|
||||
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
final Layer layer = Layer.FOREGROUND;
|
||||
|
||||
int j = 0;
|
||||
|
||||
j = this.generator.getEnergyScaled(24);
|
||||
if (j > 0) {
|
||||
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
|
||||
}
|
||||
|
||||
if (this.generator.burnTime != 0) {
|
||||
j = this.generator.getScaledBurnTime(13);
|
||||
this.drawTexturedModalRect(k + 80, l + 38 + 12 - j, 176, 30 - j, 14, j + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
|
||||
final String name = I18n.translateToLocal("tile.techreborn.generator.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);
|
||||
|
||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(this.generator.getEnergy()), 25,
|
||||
this.ySize - 150, 4210752);
|
||||
this.builder.drawBurnBar(this, this.tile.getScaledBurnTime(100), 100, 81, 38, mouseX, mouseY, layer);
|
||||
this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,6 +155,37 @@ public class TRBuilder extends GuiBuilder {
|
|||
gui.drawTexturedModalRect(x - 4, y - 4, 202, 44, 24, 24);
|
||||
}
|
||||
|
||||
public void drawBurnBar(GuiBase gui, int progress, int maxProgress, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer) {
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
y += gui.getGuiTop();
|
||||
}
|
||||
if (layer == GuiBase.Layer.FOREGROUND) {
|
||||
mouseX -= gui.getGuiLeft();
|
||||
mouseY -= gui.getGuiTop();
|
||||
}
|
||||
|
||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(x, y, 171, 84, 13, 13);
|
||||
int j = 13 - (int) ((double) progress / (double) maxProgress * 13);
|
||||
if (j > 0) {
|
||||
gui.drawTexturedModalRect(x, y + j, 171, 70 + j, 13, 13 - j);
|
||||
|
||||
}
|
||||
if (isInRect(x, y, 12, 12, mouseX, mouseY)) {
|
||||
int percentage = percentage(maxProgress, progress);
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(getPercentageColour(percentage) + "" + percentage + "%");
|
||||
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRendererObj);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public int getScaledBurnTime(int scale, int burnTime, int totalBurnTime) {
|
||||
return (int) (((float) burnTime / (float) totalBurnTime) * scale);
|
||||
}
|
||||
|
||||
public TextFormatting getPercentageColour(int percentage) {
|
||||
if (percentage <= 10) {
|
||||
return TextFormatting.RED;
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
package techreborn.compat.jei;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import mezz.jei.api.BlankModPlugin;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
|
||||
import mezz.jei.config.Config;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import reborncore.api.recipe.RecipeHandler;
|
||||
|
||||
import techreborn.Core;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.api.generator.GeneratorRecipeHelper;
|
||||
|
@ -58,17 +61,10 @@ import techreborn.items.ItemParts;
|
|||
import techreborn.parts.TechRebornParts;
|
||||
import techreborn.parts.powerCables.EnumCableType;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mezz.jei.api.BlankModPlugin;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
|
||||
import mezz.jei.config.Config;
|
||||
|
||||
@mezz.jei.api.JEIPlugin
|
||||
public class TechRebornJeiPlugin extends BlankModPlugin {
|
||||
private static void addDebugRecipes(final IModRegistry registry) {
|
||||
|
@ -212,6 +208,7 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
|
|||
registry.addRecipeClickArea(GuiAssemblingMachine.class, 85, 34, 24, 20, RecipeCategoryUids.ASSEMBLING_MACHINE);
|
||||
registry.addRecipeClickArea(GuiBlastFurnace.class, 63, 36, 24, 15, RecipeCategoryUids.BLAST_FURNACE);
|
||||
registry.addRecipeClickArea(GuiCentrifuge.class, 150, 4, 20, 12, RecipeCategoryUids.CENTRIFUGE);
|
||||
registry.addRecipeClickArea(GuiGenerator.class, 150, 4, 20, 12, VanillaRecipeCategoryUid.FUEL);
|
||||
registry.addRecipeClickArea(GuiChemicalReactor.class, 73, 39, 32, 12, RecipeCategoryUids.CHEMICAL_REACTOR);
|
||||
registry.addRecipeClickArea(GuiFusionReactor.class, 111, 34, 27, 19, RecipeCategoryUids.FUSION_REACTOR);
|
||||
registry.addRecipeClickArea(GuiIndustrialGrinder.class, 50, 35, 25, 16, RecipeCategoryUids.INDUSTRIAL_GRINDER);
|
||||
|
|
|
@ -5,6 +5,7 @@ import mezz.jei.api.IJeiHelpers;
|
|||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
import mezz.jei.api.gui.IDrawableStatic;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.api.recipe.machines.CentrifugeRecipe;
|
||||
import techreborn.client.gui.TRBuilder;
|
||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||
|
@ -35,12 +36,12 @@ public class CentrifugeRecipeWrapper extends BaseRecipeWrapper<CentrifugeRecipe>
|
|||
progressRight.draw(minecraft, 25, 26);
|
||||
|
||||
int x = -10;
|
||||
int y1 = 3;
|
||||
int y2 = 52;
|
||||
int y1 = 1;
|
||||
int y2 = 54;
|
||||
int lineHeight = minecraft.fontRendererObj.FONT_HEIGHT;
|
||||
|
||||
minecraft.fontRendererObj.drawString("Time: " + baseRecipe.tickTime / 20 + " secs", (recipeWidth / 2 - minecraft.fontRendererObj.getStringWidth("Time: " + baseRecipe.tickTime / 20 + " secs") / 2) - 40, y1, 0x444444);
|
||||
minecraft.fontRendererObj.drawString("EU: " + baseRecipe.euPerTick + " EU/t", (recipeWidth / 2 - minecraft.fontRendererObj.getStringWidth("EU: " + baseRecipe.euPerTick + " EU/t") / 2) - 40, y2, 0x444444);
|
||||
minecraft.fontRendererObj.drawString(baseRecipe.tickTime / 20 + " seconds", (recipeWidth / 2 - minecraft.fontRendererObj.getStringWidth(baseRecipe.tickTime / 20 + " seconds") / 2) - 40, y1, 0x444444);
|
||||
minecraft.fontRendererObj.drawString(PowerSystem.getLocaliszedPowerFormatted(baseRecipe.euPerTick * baseRecipe.tickTime), (recipeWidth / 2 - minecraft.fontRendererObj.getStringWidth(PowerSystem.getLocaliszedPowerFormatted(baseRecipe.euPerTick * baseRecipe.tickTime)) / 2) - 40, y2, 0x444444);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,14 +7,12 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.ForgeModContainer;
|
||||
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
|
@ -109,7 +107,7 @@ public class TileGenerator extends TilePowerAcceptor implements IWrenchable, IIn
|
|||
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 100;
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -169,8 +167,8 @@ public class TileGenerator extends TilePowerAcceptor implements IWrenchable, IIn
|
|||
|
||||
@Override
|
||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||
return new ContainerBuilder("generator").player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
|
||||
.tile(this).fuelSlot(0, 80, 53).energySlot(1, 80, 17).syncEnergyValue()
|
||||
return new ContainerBuilder("generator").player(player.inventory).inventory().hotbar().addInventory()
|
||||
.tile(this).fuelSlot(0, 80, 54).energySlot(1, 8, 72).syncEnergyValue()
|
||||
.syncIntegerValue(this::getBurnTime, this::setBurnTime)
|
||||
.syncIntegerValue(this::getTotalBurnTime, this::setTotalBurnTime).addInventory().create();
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Loading…
Add table
Reference in a new issue