mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
* Use Recipe generics in more places * Use Recipe generics in even more places * Use Recipe generics for IMCHandler * Turns out I was wrong about the old enum names being used * More Recipe generics for getting recipes * Pass MachineType as constructor parameter up the chain * Minor readability cleanup * Use method to get block name while in external classes * Improve readability of some references to internal enum classes * More missed recipe generics to reduce number of casts * Make sure to check NBT for the recipes, and switch back to for loops from streams
81 lines
3.9 KiB
Java
81 lines
3.9 KiB
Java
package mekanism.client.gui;
|
|
|
|
import java.util.Arrays;
|
|
import mekanism.client.gui.element.GuiEnergyInfo;
|
|
import mekanism.client.gui.element.GuiPowerBar;
|
|
import mekanism.client.gui.element.GuiProgress;
|
|
import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler;
|
|
import mekanism.client.gui.element.GuiProgress.ProgressBar;
|
|
import mekanism.client.gui.element.GuiRedstoneControl;
|
|
import mekanism.client.gui.element.GuiSecurityTab;
|
|
import mekanism.client.gui.element.GuiSideConfigurationTab;
|
|
import mekanism.client.gui.element.GuiSlot;
|
|
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
|
|
import mekanism.client.gui.element.GuiSlot.SlotType;
|
|
import mekanism.client.gui.element.GuiTransporterConfigTab;
|
|
import mekanism.client.gui.element.GuiUpgradeTab;
|
|
import mekanism.common.inventory.container.ContainerChanceMachine;
|
|
import mekanism.common.recipe.machines.ChanceMachineRecipe;
|
|
import mekanism.common.tile.TileEntityChanceMachine;
|
|
import mekanism.common.util.LangUtils;
|
|
import mekanism.common.util.MekanismUtils;
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
import net.minecraft.util.ResourceLocation;
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public class GuiChanceMachine<RECIPE extends ChanceMachineRecipe<RECIPE>> extends GuiMekanismTile<TileEntityChanceMachine<RECIPE>> {
|
|
|
|
public GuiChanceMachine(InventoryPlayer inventory, TileEntityChanceMachine<RECIPE> tile) {
|
|
super(tile, new ContainerChanceMachine<>(inventory, tile));
|
|
ResourceLocation resource = getGuiLocation();
|
|
addGuiElement(new GuiRedstoneControl(this, tileEntity, resource));
|
|
addGuiElement(new GuiUpgradeTab(this, tileEntity, resource));
|
|
addGuiElement(new GuiSecurityTab(this, tileEntity, resource));
|
|
addGuiElement(new GuiSideConfigurationTab(this, tileEntity, resource));
|
|
addGuiElement(new GuiTransporterConfigTab(this, 34, tileEntity, resource));
|
|
addGuiElement(new GuiPowerBar(this, tileEntity, resource, 164, 15));
|
|
addGuiElement(new GuiEnergyInfo(() -> {
|
|
String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick);
|
|
return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t",
|
|
LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy()));
|
|
}, this, resource));
|
|
addGuiElement(new GuiSlot(SlotType.INPUT, this, resource, 55, 16));
|
|
addGuiElement(new GuiSlot(SlotType.POWER, this, resource, 55, 52).with(SlotOverlay.POWER));
|
|
addGuiElement(new GuiSlot(SlotType.OUTPUT_WIDE, this, resource, 111, 30));
|
|
addGuiElement(new GuiProgress(new IProgressInfoHandler() {
|
|
@Override
|
|
public double getProgress() {
|
|
return tileEntity.getScaledProgress();
|
|
}
|
|
}, getProgressType(), this, resource, 77, 37));
|
|
}
|
|
|
|
public ProgressBar getProgressType() {
|
|
return ProgressBar.BLUE;
|
|
}
|
|
|
|
@Override
|
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
|
fontRenderer.drawString(tileEntity.getName(), 45, 6, 0x404040);
|
|
fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
|
}
|
|
|
|
@Override
|
|
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
|
|
mc.renderEngine.bindTexture(getGuiLocation());
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
int guiWidth = (width - xSize) / 2;
|
|
int guiHeight = (height - ySize) / 2;
|
|
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
|
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
|
}
|
|
|
|
@Override
|
|
protected ResourceLocation getGuiLocation() {
|
|
return tileEntity.guiLocation;
|
|
}
|
|
} |