Updated fluid generators GUI. Closes #1097

This commit is contained in:
drcrazy 2017-09-04 00:12:58 +03:00
parent 37d8b8641f
commit dfaef8a6c2
12 changed files with 92 additions and 184 deletions

View file

@ -89,7 +89,7 @@ public class Core {
public void preinit(FMLPreInitializationEvent event) throws IllegalAccessException, InstantiationException {
event.getModMetadata().version = ModInfo.MOD_VERSION;
INSTANCE = this;
FMLCommonHandler.instance().bus().register(this);
// FMLCommonHandler.instance().bus().register(this);
MinecraftForge.EVENT_BUS.register(this);
configDir = new File(new File(event.getModConfigurationDirectory(), "teamreborn"), "techreborn");

View file

@ -40,8 +40,8 @@ public class GuiDieselGenerator extends GuiBase {
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND;
drawSlot(10, 35, layer);
drawSlot(10, 55, layer);
drawSlot(25, 35, layer);
drawSlot(25, 55, layer);
this.builder.drawJEIButton(this, 150, 4, layer);
}
@ -53,7 +53,7 @@ public class GuiDieselGenerator extends GuiBase {
this.builder.drawProgressBar(this, this.tile.getProgressScaled(10), 100, 83, 48, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer);
this.builder.drawMultiEnergyBar(this, 130, 28, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer);
this.builder.drawTank(this, 29, 25, mouseX, mouseY, this.tile.tank.getFluid(), this.tile.tank.getCapacity(), this.tile.tank.isEmpty(), layer);
this.builder.drawTank(this, 44, 25, mouseX, mouseY, this.tile.tank.getFluid(), this.tile.tank.getCapacity(), this.tile.tank.isEmpty(), layer);
}

View file

@ -24,51 +24,36 @@
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.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import techreborn.tiles.generator.TileGasTurbine;
public class GuiGasTurbine extends GuiContainer {
public class GuiGasTurbine extends GuiBase {
// TODO: use semifluid generator texture
private static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/thermal_generator.png");
TileGasTurbine tile;
TileGasTurbine gasTurbine;
public GuiGasTurbine(final EntityPlayer player, final TileGasTurbine gasTurbine) {
super(gasTurbine.createContainer(player));
this.xSize = 176;
this.ySize = 167;
this.gasTurbine = gasTurbine;
public GuiGasTurbine(final EntityPlayer player, final TileGasTurbine tile) {
super(player, tile, tile.createContainer(player));
this.tile = tile;
}
@Override
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(GuiGasTurbine.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 drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND;
drawSlot(25, 35, layer);
drawSlot(25, 55, layer);
this.builder.drawJEIButton(this, 150, 4, layer);
}
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = "Gas Turbine";
this.fontRenderer.drawString(name, this.xSize / 2 - this.fontRenderer.getStringWidth(name) / 2, 6,
4210752);
this.fontRenderer.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRenderer.drawString("Liquid Amount", 10, 20, 16448255);
this.fontRenderer.drawString(this.gasTurbine.tank.getFluidAmount() + "", 10, 30, 16448255);
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY);
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
this.builder.drawProgressBar(this, this.tile.getProgressScaled(10), 100, 83, 48, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer);
this.builder.drawMultiEnergyBar(this, 130, 28, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer);
this.builder.drawTank(this, 44, 25, mouseX, mouseY, this.tile.tank.getFluid(), this.tile.tank.getCapacity(), this.tile.tank.isEmpty(), layer);
}
}

View file

@ -24,53 +24,36 @@
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.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import reborncore.client.RenderUtil;
import techreborn.tiles.generator.TileSemiFluidGenerator;
public class GuiSemifluidGenerator extends GuiContainer {
public class GuiSemifluidGenerator extends GuiBase {
// TODO: use semifluid generator texture
private static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/semifluid_generator.png");
TileSemiFluidGenerator tile;
TileSemiFluidGenerator semifluidGenerator;
public GuiSemifluidGenerator(final EntityPlayer player, final TileSemiFluidGenerator semifluidGenerator) {
super(semifluidGenerator.createContainer(player));
this.xSize = 176;
this.ySize = 167;
this.semifluidGenerator = semifluidGenerator;
public GuiSemifluidGenerator(final EntityPlayer player, final TileSemiFluidGenerator tile) {
super(player, tile, tile.createContainer(player));
this.tile = tile;
}
@Override
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(GuiSemifluidGenerator.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);
RenderUtil.renderGuiTank(this.semifluidGenerator.tank.getFluid(), 16, 16, k + 59, l + 42, this.zLevel, 16, 16);
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND;
drawSlot(25, 35, layer);
drawSlot(25, 55, layer);
this.builder.drawJEIButton(this, 150, 4, layer);
}
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = "Semifluid Generator";
this.fontRenderer.drawString(name, this.xSize / 2 - this.fontRenderer.getStringWidth(name) / 2, 6,
4210752);
this.fontRenderer.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRenderer.drawString("Liquid Amount", 10, 20, 16448255);
this.fontRenderer.drawString(this.semifluidGenerator.tank.getFluidAmount() + "", 10, 30, 16448255);
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY);
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
this.builder.drawProgressBar(this, this.tile.getProgressScaled(10), 100, 83, 48, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer);
this.builder.drawMultiEnergyBar(this, 130, 28, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer);
this.builder.drawTank(this, 44, 25, mouseX, mouseY, this.tile.tank.getFluid(), this.tile.tank.getCapacity(), this.tile.tank.isEmpty(), layer);
}
}

View file

@ -24,54 +24,36 @@
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.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import reborncore.client.RenderUtil;
import techreborn.tiles.generator.TileThermalGenerator;
public class GuiThermalGenerator extends GuiContainer {
public class GuiThermalGenerator extends GuiBase {
private static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/thermal_generator.png");
TileThermalGenerator tile;
TileThermalGenerator thermalGenerator;
public GuiThermalGenerator(final EntityPlayer player, final TileThermalGenerator thermalGenerator) {
super(thermalGenerator.createContainer(player));
this.xSize = 176;
this.ySize = 167;
this.thermalGenerator = thermalGenerator;
public GuiThermalGenerator(final EntityPlayer player, final TileThermalGenerator tile) {
super(player, tile, tile.createContainer(player));
this.tile = tile;
}
@Override
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(GuiThermalGenerator.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);
RenderUtil.renderGuiTank(this.thermalGenerator.tank.getFluid(), 16, 16, k + 59, l + 42, this.zLevel, 16, 16);
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND;
drawSlot(25, 35, layer);
drawSlot(25, 55, layer);
this.builder.drawJEIButton(this, 150, 4, layer);
}
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn:thermal_generator.name");
this.fontRenderer.drawString(name, this.xSize / 2 - this.fontRenderer.getStringWidth(name) / 2, 6,
4210752);
this.fontRenderer.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRenderer.drawString("Liquid Amount", 10, 20, 16448255);
this.fontRenderer.drawString(this.thermalGenerator.tank.getFluidAmount() + "", 10, 30, 16448255);
this.fontRenderer.drawString(this.thermalGenerator.getEnergy() + "", 10, 40, 16448255);
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY);
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
this.builder.drawProgressBar(this, this.tile.getProgressScaled(10), 100, 83, 48, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer);
this.builder.drawMultiEnergyBar(this, 130, 28, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer);
this.builder.drawTank(this, 44, 25, mouseX, mouseY, this.tile.tank.getFluid(), this.tile.tank.getCapacity(), this.tile.tank.isEmpty(), layer);
}
}

View file

@ -261,13 +261,10 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
registry.addRecipeClickArea(GuiIronFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING,
VanillaRecipeCategoryUid.FUEL);
registry.addRecipeClickArea(GuiSemifluidGenerator.class, 79, 34, 18, 18,
EFluidGenerator.SEMIFLUID.getRecipeID());
registry.addRecipeClickArea(GuiSemifluidGenerator.class, 150, 4, 18, 18, EFluidGenerator.SEMIFLUID.getRecipeID());
registry.addRecipeClickArea(GuiDieselGenerator.class, 150, 4, 18, 18, EFluidGenerator.DIESEL.getRecipeID());
registry.addRecipeClickArea(GuiGasTurbine.class, 79, 34, 18, 18,
EFluidGenerator.GAS.getRecipeID());
registry.addRecipeClickArea(GuiThermalGenerator.class, 79, 34, 18, 18,
EFluidGenerator.THERMAL.getRecipeID());
registry.addRecipeClickArea(GuiGasTurbine.class, 150, 4, 18, 18, EFluidGenerator.GAS.getRecipeID());
registry.addRecipeClickArea(GuiThermalGenerator.class, 150, 4, 18, 18, EFluidGenerator.THERMAL.getRecipeID());
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IRON_FURNACE), VanillaRecipeCategoryUid.SMELTING, VanillaRecipeCategoryUid.FUEL);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IRON_ALLOY_FURNACE), RecipeCategoryUids.ALLOY_SMELTER, VanillaRecipeCategoryUid.FUEL);

View file

@ -32,26 +32,12 @@ import mezz.jei.api.recipe.BlankRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import reborncore.common.powerSystem.PowerSystem;
import techreborn.api.generator.FluidGeneratorRecipe;
import javax.annotation.Nonnull;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.Locale;
public class FluidGeneratorRecipeWrapper extends BlankRecipeWrapper {
private static final DecimalFormat formatter;
static {
formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US);
DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols();
symbols.setGroupingSeparator(' ');
formatter.setDecimalFormatSymbols(symbols);
}
private static final int FLUID_GENERATOR_STORAGE = 100_000;
private final FluidGeneratorRecipe baseRecipe;
@ -76,8 +62,9 @@ public class FluidGeneratorRecipeWrapper extends BlankRecipeWrapper {
energyProduced.draw(minecraft, 73, 26);
minecraft.fontRenderer.drawString(formatter.format(baseRecipe.getEnergyPerMb() * 1000) + " EU", 70, 13,
0x444444);
minecraft.fontRenderer
.drawString(PowerSystem.getLocaliszedPowerFormattedNoSuffix(baseRecipe.getEnergyPerMb() * 1000) + " "
+ PowerSystem.getDisplayPower().abbreviation, 70, 13, 0x444444);
}
@Override

View file

@ -24,7 +24,6 @@
package techreborn.tiles.generator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
@ -71,9 +70,9 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement
}
@Override
public void update(){
this.ticksSinceLastChange++;
public void update() {
super.update();
this.ticksSinceLastChange++;
// Check cells input slot 2 time per second
if (this.ticksSinceLastChange >= 10) {
@ -83,7 +82,7 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement
}
this.ticksSinceLastChange = 0;
}
if (this.tank.getFluidAmount() > 0) {
if (this.currentRecipe == null || !this.currentRecipe.getFluid().equals(this.tank.getFluidType()))
this.currentRecipe = this.getRecipes().getRecipeForFluid(this.tank.getFluidType()).orElse(null);
@ -101,7 +100,7 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement
}
}
}
if (!this.world.isRemote) {
if (this.world.getTotalWorldTime() - this.lastOutput < 30 && !this.isActive())
this.world.setBlockState(this.getPos(), this.world.getBlockState(this.getPos()).withProperty(BlockMachineBase.ACTIVE, true));

View file

@ -69,7 +69,7 @@ public class TileDieselGenerator extends TileBaseFluidGenerator implements ICont
@Override
public BuiltContainer createContainer(final EntityPlayer player) {
return new ContainerBuilder("dieselgenerator").player(player.inventory).inventory().hotbar()
.addInventory().tile(this).slot(0, 10, 35).outputSlot(1, 10, 55).syncEnergyValue()
.addInventory().tile(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.addInventory().create();
}
}

View file

@ -68,8 +68,8 @@ public class TileGasTurbine extends TileBaseFluidGenerator implements IContainer
@Override
public BuiltContainer createContainer(final EntityPlayer player) {
return new ContainerBuilder("gasturbine").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(this).slot(0, 80, 17).outputSlot(1, 80, 53).fakeSlot(2, 59, 42).syncEnergyValue()
return new ContainerBuilder("gasturbine").player(player.inventory).inventory().hotbar()
.addInventory().tile(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.addInventory().create();
}
}

View file

@ -60,11 +60,16 @@ public class TileSemiFluidGenerator extends TileBaseFluidGenerator implements IC
public double getBaseMaxPower() {
return maxEnergy;
}
@Override
public double getBaseMaxOutput() {
return maxOutput;
}
@Override
public BuiltContainer createContainer(final EntityPlayer player) {
return new ContainerBuilder("semifluidgenerator").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(this).slot(0, 80, 17).outputSlot(1, 80, 53).fakeSlot(2, 59, 42).syncEnergyValue()
return new ContainerBuilder("semifluidgenerator").player(player.inventory).inventory().hotbar()
.addInventory().tile(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.addInventory().create();
}
}

View file

@ -61,36 +61,6 @@ public class TileThermalGenerator extends TileBaseFluidGenerator implements ICon
return new ItemStack(ModBlocks.THERMAL_GENERATOR, 1);
}
public boolean isOn = false;
@Override
public void updateEntity() {
super.updateEntity();
if (!this.world.isRemote) {
boolean didRun = false;
if (this.acceptFluid() && FluidUtils.drainContainers(this.tank, this.inventory, 0, 1))
this.syncWithAll();
for (final EnumFacing direction : EnumFacing.values()) {
if (this.world
.getBlockState(new BlockPos(this.getPos().getX() + direction.getFrontOffsetX(),
this.getPos().getY() + direction.getFrontOffsetY(),
this.getPos().getZ() + direction.getFrontOffsetZ()))
.getBlock() == Blocks.LAVA) {
if (this.tryAddingEnergy(1)) {
this.lastOutput = this.world.getTotalWorldTime();
didRun = true;
}
}
}
if (didRun != isOn) {
isOn = didRun;
world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockThermalGenerator.ACTIVE, isOn));
}
}
}
@Override
public double getBaseMaxPower() {
return maxEnergy;
@ -103,8 +73,8 @@ public class TileThermalGenerator extends TileBaseFluidGenerator implements ICon
@Override
public BuiltContainer createContainer(final EntityPlayer player) {
return new ContainerBuilder("thermalgenerator").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(this).slot(0, 80, 17).outputSlot(1, 80, 53).fakeSlot(2, 59, 42).syncEnergyValue()
return new ContainerBuilder("thermalgenerator").player(player.inventory).inventory().hotbar()
.addInventory().tile(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.addInventory().create();
}
}