Revamp centrifuge jei support
This commit is contained in:
parent
eb220643fc
commit
2a78196939
8 changed files with 48 additions and 71 deletions
|
@ -3,11 +3,11 @@ 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.inventory.Container;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.gui.widget.GuiButtonPowerBar;
|
||||
|
||||
/**
|
||||
|
@ -19,9 +19,9 @@ public class GuiBase extends GuiContainer {
|
|||
public int ySize = 176;
|
||||
public TRBuilder builder = new TRBuilder();
|
||||
public TileEntity tile;
|
||||
public Container container;
|
||||
public BuiltContainer container;
|
||||
|
||||
public GuiBase(EntityPlayer player, TileEntity tile, Container container) {
|
||||
public GuiBase(EntityPlayer player, TileEntity tile, BuiltContainer container) {
|
||||
super(container);
|
||||
this.tile = tile;
|
||||
this.container = container;
|
||||
|
|
|
@ -1,23 +1,15 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import techreborn.tiles.TileCentrifuge;
|
||||
|
||||
public class GuiCentrifuge extends GuiBase {
|
||||
|
||||
TileCentrifuge centrifuge;
|
||||
TileCentrifuge tile;
|
||||
|
||||
public GuiCentrifuge(final EntityPlayer player, final TileCentrifuge centrifuge) {
|
||||
super(player, centrifuge, centrifuge.createContainer(player));
|
||||
this.centrifuge = centrifuge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
final int k = (this.width - this.xSize) / 2;
|
||||
final int l = (this.height - this.ySize) / 2;
|
||||
super.initGui();
|
||||
public GuiCentrifuge(final EntityPlayer player, final TileCentrifuge tile) {
|
||||
super(player, tile, tile.createContainer(player));
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,7 +35,7 @@ public class GuiCentrifuge extends GuiBase {
|
|||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
final Layer layer = Layer.FOREGROUND;
|
||||
|
||||
this.builder.drawProgressBar(this, this.centrifuge.getProgressScaled(100), 100, 61, 47, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer);
|
||||
this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.centrifuge.getEnergy(), (int) this.centrifuge.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 61, 47, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer);
|
||||
this.builder.drawMultiEnergyBar(this, 9, 18, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.client.renderer.GlStateManager;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import reborncore.client.guibuilder.GuiBuilder;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
@ -91,19 +92,21 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawJEIButton(GuiBase gui, 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);
|
||||
if (isInRect(x, y, 20, 12, mouseX, mouseY)) {
|
||||
gui.drawTexturedModalRect(x, y, 184, 82, 20, 12);
|
||||
} else {
|
||||
gui.drawTexturedModalRect(x, y, 184, 70, 20, 12);
|
||||
if (Loader.isModLoaded("jei")) {
|
||||
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);
|
||||
if (isInRect(x, y, 20, 12, mouseX, mouseY)) {
|
||||
gui.drawTexturedModalRect(x, y, 184, 82, 20, 12);
|
||||
} else {
|
||||
gui.drawTexturedModalRect(x, y, 184, 70, 20, 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,14 +14,14 @@ import techreborn.compat.jei.RecipeUtil;
|
|||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CentrifugeRecipeCategory extends BlankRecipeCategory<CentrifugeRecipeWrapper> {
|
||||
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_centrifuge.png");
|
||||
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png");
|
||||
private static final int[] INPUT_SLOTS = { 0, 1 };
|
||||
private static final int[] OUTPUT_SLOTS = { 2, 3, 4, 5 };
|
||||
private final IDrawable background;
|
||||
private final String title;
|
||||
|
||||
public CentrifugeRecipeCategory(IGuiHelper guiHelper) {
|
||||
background = guiHelper.createDrawable(texture, 49, 4, 78, 78);
|
||||
background = guiHelper.createDrawable(texture, 0, 0, 104, 62);
|
||||
title = I18n.translateToLocal("tile.techreborn.centrifuge.name");
|
||||
}
|
||||
|
||||
|
@ -52,13 +52,13 @@ public class CentrifugeRecipeCategory extends BlankRecipeCategory<CentrifugeReci
|
|||
@Nonnull
|
||||
IIngredients ingredients) {
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
guiItemStacks.init(INPUT_SLOTS[0], true, 30, 30);
|
||||
guiItemStacks.init(INPUT_SLOTS[1], true, 0, 0);
|
||||
guiItemStacks.init(INPUT_SLOTS[0], true, 3, 12);
|
||||
guiItemStacks.init(INPUT_SLOTS[1], true, 3, 32);
|
||||
|
||||
guiItemStacks.init(OUTPUT_SLOTS[0], false, 30, 0);
|
||||
guiItemStacks.init(OUTPUT_SLOTS[1], false, 60, 30);
|
||||
guiItemStacks.init(OUTPUT_SLOTS[2], false, 30, 60);
|
||||
guiItemStacks.init(OUTPUT_SLOTS[3], false, 0, 30);
|
||||
guiItemStacks.init(OUTPUT_SLOTS[0], false, 45, 22);
|
||||
guiItemStacks.init(OUTPUT_SLOTS[1], false, 64, 3);
|
||||
guiItemStacks.init(OUTPUT_SLOTS[2], false, 83, 22);
|
||||
guiItemStacks.init(OUTPUT_SLOTS[3], false, 64, 41);
|
||||
|
||||
RecipeUtil.setRecipeItems(recipeLayout, ingredients, INPUT_SLOTS, OUTPUT_SLOTS, null, null);
|
||||
}
|
||||
|
|
|
@ -5,17 +5,13 @@ import mezz.jei.api.IJeiHelpers;
|
|||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
import mezz.jei.api.gui.IDrawableStatic;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import techreborn.api.recipe.machines.CentrifugeRecipe;
|
||||
import techreborn.client.gui.TRBuilder;
|
||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CentrifugeRecipeWrapper extends BaseRecipeWrapper<CentrifugeRecipe> {
|
||||
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_centrifuge.png");
|
||||
private final IDrawableAnimated progressUp;
|
||||
private final IDrawableAnimated progressLeft;
|
||||
private final IDrawableAnimated progressDown;
|
||||
private final IDrawableAnimated progressRight;
|
||||
|
||||
public CentrifugeRecipeWrapper(
|
||||
|
@ -25,37 +21,26 @@ public class CentrifugeRecipeWrapper extends BaseRecipeWrapper<CentrifugeRecipe>
|
|||
CentrifugeRecipe baseRecipe) {
|
||||
super(baseRecipe);
|
||||
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
|
||||
IDrawableStatic progressUpStatic = guiHelper.createDrawable(texture, 176, 14, 12, 12);
|
||||
IDrawableStatic progressLeftStatic = guiHelper.createDrawable(texture, 176, 26, 12, 12);
|
||||
IDrawableStatic progressDownStatic = guiHelper.createDrawable(texture, 176, 38, 12, 12);
|
||||
IDrawableStatic progressRightStatic = guiHelper.createDrawable(texture, 176, 50, 12, 12);
|
||||
IDrawableStatic progressStatic = guiHelper.createDrawable(TRBuilder.GUI_SHEET, 100, 151, 16, 10);
|
||||
|
||||
int ticksPerCycle = baseRecipe.tickTime() / 4; // speed up the animation
|
||||
// a bit
|
||||
this.progressUp = guiHelper.createAnimatedDrawable(progressUpStatic, ticksPerCycle,
|
||||
IDrawableAnimated.StartDirection.BOTTOM, false);
|
||||
this.progressLeft = guiHelper.createAnimatedDrawable(progressLeftStatic, ticksPerCycle,
|
||||
IDrawableAnimated.StartDirection.RIGHT, false);
|
||||
this.progressDown = guiHelper.createAnimatedDrawable(progressDownStatic, ticksPerCycle,
|
||||
IDrawableAnimated.StartDirection.TOP, false);
|
||||
this.progressRight = guiHelper.createAnimatedDrawable(progressRightStatic, ticksPerCycle,
|
||||
|
||||
this.progressRight = guiHelper.createAnimatedDrawable(progressStatic, ticksPerCycle,
|
||||
IDrawableAnimated.StartDirection.LEFT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
||||
progressUp.draw(minecraft, 33, 18);
|
||||
progressLeft.draw(minecraft, 18, 33);
|
||||
progressDown.draw(minecraft, 33, 48);
|
||||
progressRight.draw(minecraft, 48, 33);
|
||||
progressRight.draw(minecraft, 25, 26);
|
||||
|
||||
int x = -45;
|
||||
int y = 60;
|
||||
int x = -10;
|
||||
int y1 = 3;
|
||||
int y2 = 52;
|
||||
int lineHeight = minecraft.fontRendererObj.FONT_HEIGHT;
|
||||
|
||||
minecraft.fontRendererObj.drawString("Time: " + baseRecipe.tickTime / 20 + " secs", x, y, 0x444444);
|
||||
minecraft.fontRendererObj.drawString("EU: " + baseRecipe.euPerTick + " EU/t", x, y += lineHeight, 0x444444);
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.power.IEnergyItemInfo;
|
||||
|
@ -15,7 +14,6 @@ import reborncore.common.powerSystem.PoweredItem;
|
|||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
|
@ -28,7 +26,7 @@ import techreborn.utils.upgrade.UpgradeHandler;
|
|||
import java.util.List;
|
||||
|
||||
public class TileCentrifuge extends TilePowerAcceptor
|
||||
implements IWrenchable, IInventoryProvider, IListInfoProvider, IRecipeCrafterProvider, IContainerProvider {
|
||||
implements IWrenchable, IInventoryProvider, IListInfoProvider, IRecipeCrafterProvider, IContainerProvider {
|
||||
|
||||
public int tickTime;
|
||||
public Inventory inventory = new Inventory(11, "TileCentrifuge", 64, this);
|
||||
|
@ -185,11 +183,10 @@ implements IWrenchable, IInventoryProvider, IListInfoProvider, IRecipeCrafterPro
|
|||
|
||||
@Override
|
||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||
return new ContainerBuilder("centrifuge").player(player.inventory).inventory(8, 84).hotbar(8, 142)
|
||||
.addInventory().tile(this).slot(0, 80, 35).slot(1, 50, 5).outputSlot(2, 80, 5).outputSlot(3, 110, 35)
|
||||
.outputSlot(4, 80, 65).outputSlot(5, 50, 35).energySlot(6, 8, 51).upgradeSlot(7, 152, 8)
|
||||
.upgradeSlot(8, 152, 26).upgradeSlot(9, 152, 44).upgradeSlot(10, 152, 62).syncEnergyValue()
|
||||
.syncCrafterValue().addInventory().create();
|
||||
return new ContainerBuilder("centrifuge").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().tile(this).slot(0, 40, 34).slot(1, 40, 54).outputSlot(2, 82, 44).outputSlot(3, 101, 25)
|
||||
.outputSlot(4, 120, 44).outputSlot(5, 101, 63).energySlot(6, 8, 72).syncEnergyValue()
|
||||
.syncCrafterValue().addInventory().create();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB |
BIN
src/main/resources/assets/techreborn/textures/gui/jei.png
Normal file
BIN
src/main/resources/assets/techreborn/textures/gui/jei.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Loading…
Add table
Reference in a new issue