Files
Mekanism-Community-Edition/src/main/java/mekanism/client/gui/GuiEmbeddedGaugeTile.java
T
Richard Freimer 0d4b50908f Formatting and code readability cleanup (#5467)
* First pass reformatting code to be more readable (common still not done)

* Replace google common collect calls with Java calls where possible

* Remove a bunch of unnecessary parenthesis leaving clarifying ones

* Add some missing @Nonnull annotations

* Fix checking wrong type

* Remove unnecessary continue/return statements and simplify comparision check

* Pass exception instead of directly printing stack trace

* Work on cleaning up common, through config so far

* Work on cleaning up common, through integration so far

* Work on cleaning up common, through network so far

* Work on cleaning up common, through tier so far

* Remove empty constructors that get created by default anyways

* Work on cleaning up common, through transmitters so far

* Work on cleaning up common, through utils so far

* Finish cleaning up spacing for common
2019-05-11 14:13:24 -04:00

52 lines
2.0 KiB
Java

package mekanism.client.gui;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.MekanismRenderer.FluidType;
import mekanism.common.tile.prefab.TileEntityContainerBlock;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
public abstract class GuiEmbeddedGaugeTile<TILE extends TileEntityContainerBlock> extends GuiMekanismTile<TILE> {
protected GuiEmbeddedGaugeTile(TILE tile, Container container) {
super(tile, container);
}
protected abstract ResourceLocation getGaugeResource();
protected void displayGauge(int xPos, int yPos, int scale, FluidStack fluid) {
displayGauge(xPos, yPos, scale, fluid, 0);
}
protected void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, int side /*0-left, 1-right*/) {
if (fluid == null) {
return;
}
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
int start = 0;
MekanismRenderer.colorFluidGLSM(fluid);
TextureAtlasSprite fluidTexture = MekanismRenderer.getFluidTexture(fluid, FluidType.STILL);
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
while (true) {
int renderRemaining;
if (scale > 16) {
renderRemaining = 16;
scale -= 16;
} else {
renderRemaining = scale;
scale = 0;
}
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluidTexture, 16, renderRemaining);
start += 16;
if (renderRemaining == 0 || scale == 0) {
break;
}
}
mc.renderEngine.bindTexture(getGaugeResource());
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, side == 0 ? 0 : 54, 16, 54);
}
}