Java Code Examples for net.minecraftforge.fluids.FluidTank#getCapacity()

The following examples show how to use net.minecraftforge.fluids.FluidTank#getCapacity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GuiTFBattery.java    From TofuCraftReload with MIT License 6 votes vote down vote up
/**
     * Draws the background layer of this container (behind the items).
     */
    @Override
    protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {

        TextureManager manager = this.mc.getTextureManager();
        manager.bindTexture(TXTURE);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        int var5 = (this.width - this.xSize) / 2;
        int var6 = (this.height - this.ySize) / 2;
        this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
//        int var7;
        if (this.tileBattery.inputTank.getFluid() != null) {
            FluidTank fluidTank = this.tileBattery.inputTank;
            int heightInd = (int) (72 * ((float) fluidTank.getFluidAmount() / (float) fluidTank.getCapacity()));
            if (heightInd > 0) {
                ClientUtils.drawRepeatedFluidSprite(fluidTank.getFluid(), var5 + 167 - 47 - heightInd, var6 + 54, heightInd, 16f);
            }

        }

    }
 
Example 2
Source File: GuiMapleCauldron.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
protected void drawGuiContainerBackgroundLayer(float partialTickTime, int x, int y) {

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    this.mc.getTextureManager().bindTexture(GuiTextures);

    int k = (this.width - this.xSize) / 2;
    int l = (this.height - this.ySize) / 2;

    this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
    
    if(this.tilePot.isBurning()){
    	this.drawTexturedModalRect(k + 71, l + 59, 176, 17, 14, 14);
    }
    
    int l2 = this.getProgressScaled(44);
    this.drawTexturedModalRect(k + 59, l + 36, 176, 0, l2 + 1, 17);
    
    if (this.tilePot.getTank().getFluid() != null) {
        FluidTank fluidTank = this.tilePot.getTank();
        int heightInd = (int) (68 * ((float) fluidTank.getFluidAmount() / (float) fluidTank.getCapacity()));
        if (heightInd > 0) {
            ClientUtils.drawRepeatedFluidSprite(fluidTank.getFluid(), k + 35, l + 78 - heightInd , 16f, heightInd);
        }
    }
}
 
Example 3
Source File: GuiTFAggreagator.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Draws the background layer of this container (behind the items).
 */
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {

    TextureManager manager = this.mc.getTextureManager();
    manager.bindTexture(TXTURE);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    int var5 = (this.width - this.xSize) / 2;
    int var6 = (this.height - this.ySize) / 2;
    this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
    int var7,var8;
    var8 = this.getEnergyScaled(55);
    this.drawTexturedModalRect(var5 + 61, var6 + 58, 176, 31, var8 , 8);
    
    // Progress arrow
    var7 = this.getProgressScaled(55);
    this.drawTexturedModalRect(var5 + 62, var6 + 16, 176, 31, var7, 8);
    
    if (this.tileFurnace.getTank().getFluid() != null) {
        FluidTank fluidTank = this.tileFurnace.getTank();
        int heightInd = (int) (55 * ((float) fluidTank.getFluidAmount() / (float) fluidTank.getCapacity()));
        if (heightInd > 0) {
        	this.drawTexturedModalRect(var5 + 18, var6 + 66 - heightInd, 176, 39, 9, heightInd);
        }

    }
}
 
Example 4
Source File: GuiTFStorage.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Draws the background layer of this container (behind the items).
 */
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {

    TextureManager manager = this.mc.getTextureManager();
    manager.bindTexture(TXTURE);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    int var5 = (this.width - this.xSize) / 2;
    int var6 = (this.height - this.ySize) / 2;
    this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
    int var7,var8;
    var8 = this.getEnergyScaled(55);
    this.drawTexturedModalRect(var5 + 87, var6 + 34, 176, 31, var8 , 8);

    // Progress arrow
    var7 = this.tileFurnace.getProgressScaled(24);
    this.drawTexturedModalRect(var5 + 53, var6 + 30, 176, 15, var7 + 1, 16);

    if (this.tileFurnace.getTank().getFluid() != null) {
        FluidTank fluidTank = this.tileFurnace.getTank();
        int heightInd = (int) (41 * ((float) fluidTank.getFluidAmount() / (float) fluidTank.getCapacity()));
        if (heightInd > 0) {
        	this.drawTexturedModalRect(var5 + 9, var6 + 52 - heightInd, 176, 40, 9, heightInd);
        }

    }
}
 
Example 5
Source File: GuiTFAdvancedAggreagator.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Draws the background layer of this container (behind the items).
 */
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {

    TextureManager manager = this.mc.getTextureManager();
    manager.bindTexture(TXTURE);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    int var5 = (this.width - this.xSize) / 2;
    int var6 = (this.height - this.ySize) / 2;
    this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
    int var7,var8;
    var8 = this.getEnergyScaled(55);
    this.drawTexturedModalRect(var5 + 88, var6 + 53, 176, 31, var8, 8);
    
    // Progress arrow
    var7 = this.getProgressScaled(55);
    this.drawTexturedModalRect(var5 + 62, var6 + 12, 176, 31, var7, 8);
    
    if (this.tileFurnace.getTank().getFluid() != null) {
        FluidTank fluidTank = this.tileFurnace.getTank();
        int heightInd = (int) (55 * ((float) fluidTank.getFluidAmount() / (float) fluidTank.getCapacity()));
        if (heightInd > 0) {
        	this.drawTexturedModalRect(var5 + 18, var6 + 66 - heightInd, 176, 39, 9, heightInd);
        }

    }
}
 
Example 6
Source File: GuiCampfirePot.java    From Sakura_mod with MIT License 5 votes vote down vote up
@Override
protected void drawGuiContainerBackgroundLayer(float partialTickTime, int x, int y) {

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    this.mc.getTextureManager().bindTexture(mortarGuiTextures);

    int k = (this.width - this.xSize) / 2;
    int l = (this.height - this.ySize) / 2;

    this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);

    int var7;

    // Flame
    if (this.tilePot.isBurning()) {
        var7 = this.tilePot.getBurnTimeRemainingScaled(12);

        this.drawTexturedModalRect(k + 100, l + 67 - var7, 176, 12 - var7, 14, var7 + 2);
    }

    int l2 = this.getCookProgressScaled(24);
    this.drawTexturedModalRect(k + 96, l + 37, 176, 14, l2 + 1, 16);
    
    if (this.tilePot.getTank().getFluid() != null) {
        FluidTank fluidTank = this.tilePot.getTank();
        int heightInd = (int) (72 * ((float) fluidTank.getFluidAmount() / (float) fluidTank.getCapacity()));
        if (heightInd > 0) {
            ClientUtils.drawRepeatedFluidSprite(fluidTank.getFluid(), k + 167- heightInd, l + 11 , heightInd, 16f);
        }

    }
}
 
Example 7
Source File: MetaTileEntityQuantumTank.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public int getActualComparatorValue() {
    FluidTank fluidTank = this.fluidTank;
    int fluidAmount = fluidTank.getFluidAmount();
    int maxCapacity = fluidTank.getCapacity();
    float f = fluidAmount / (maxCapacity * 1.0f);
    return MathHelper.floor(f * 14.0f) + (fluidAmount > 0 ? 1 : 0);
}
 
Example 8
Source File: GuiSaltFurnace.java    From TofuCraftReload with MIT License 4 votes vote down vote up
/**
 * Draws the background layer of this container (behind the items).
 */
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {

    TextureManager manager = this.mc.getTextureManager();
    manager.bindTexture(TXTURE);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    int var5 = (this.width - this.xSize) / 2;
    int var6 = (this.height - this.ySize) / 2;
    this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
    int var7;

    // Flame
    if (this.tileFurnace.isBurning()) {
        var7 = this.tileFurnace.getBurnTimeRemainingScaled(12);
        this.drawTexturedModalRect(var5 + 23, var6 + 36 + 12 - var7, 176, 12 - var7, 14, var7 + 2);
    }

    // Progress arrow
    var7 = this.tileFurnace.getCookProgressScaled(24);
    this.drawTexturedModalRect(var5 + 46, var6 + 34, 176, 14, var7 + 1, 16);

    // Cauldron
    var7 = this.tileFurnace.getCauldronStatus();
    if (var7 < 0) {
        this.drawTexturedModalRect(var5 + 23, var6 + 17, 176, 31, 16, 16);
    } else if (var7 == 1) {
        this.drawTexturedModalRect(var5 + 23, var6 + 17, 192, 31, 16, 16);
    } else if (var7 >= 2) {
        this.drawTexturedModalRect(var5 + 23, var6 + 17, 208, 31, 16, 16);
    }

    // Nigari Gauge
    if (this.tileFurnace.getNigariTank().getFluid() != null) {
        FluidTank fluidTank = this.tileFurnace.getNigariTank();
        int heightInd = (int) (35 * ((float) fluidTank.getFluidAmount() / (float) fluidTank.getCapacity()));
        if (heightInd > 0) {
            manager.bindTexture(NIGARI);
            int time = (int)this.mc.world.getWorldTime()%64/2;
            GuiSaltFurnace.drawModalRectWithCustomSizedTexture(var5 + 114, var6 + 64 - heightInd, 0.0f, 16*time, 6, heightInd, 16, 512);
        }
    }
}
 
Example 9
Source File: BarrelModeFluid.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void update(TileBarrel barrel) {
	// Fluids on top.
	if (barrel.getTank().getFluid() != null) {
		FluidTank tank = barrel.getTank();
		if (tank.getFluid().amount != tank.getCapacity())
			return;

		Fluid fluidInBarrel = tank.getFluid().getFluid();

		BlockPos barrelPos = barrel.getPos();
		BlockPos pos = new BlockPos(barrelPos.getX(), barrelPos.getY() + 1, barrelPos.getZ());
		Block onTop = barrel.getWorld().getBlockState(pos).getBlock();

		Fluid fluidOnTop = null;
		if (onTop instanceof BlockLiquid) {
			fluidOnTop = onTop.getMaterial(barrel.getWorld().getBlockState(pos)) == Material.WATER
					? FluidRegistry.WATER : FluidRegistry.LAVA;
		}

		if (onTop != null && onTop instanceof IFluidBlock) {
			fluidOnTop = ((BlockFluidBase) onTop).getFluid();
		}

		if (FluidOnTopRegistry.isValidRecipe(fluidInBarrel, fluidOnTop)) {
			ItemInfo info = FluidOnTopRegistry.getTransformedBlock(fluidInBarrel, fluidOnTop);
			tank.drain(tank.getCapacity(), true);
			barrel.setMode("block");
			PacketHandler.sendToAllAround(new MessageBarrelModeUpdate("block", barrel.getPos()), barrel);

			barrel.getMode().addItem(info.getItemStack(), barrel);

			return;
		}

		// Fluid transforming time!
		if (FluidTransformRegistry.containsKey(barrel.getTank().getFluid().getFluid().getName())) {
			List<FluidTransformer> transformers = FluidTransformRegistry
					.getFluidTransformers(barrel.getTank().getFluid().getFluid().getName());

			boolean found = false;
			for (int radius = 0; radius <= 2; radius++) {
				for (FluidTransformer transformer : transformers) {
					if (!BarrelLiquidBlacklistRegistry.isBlacklisted(barrel.getTier(), transformer.getOutputFluid())
							&& (Util.isSurroundingBlocksAtLeastOneOf(transformer.getTransformingBlocks(),
									barrel.getPos().add(0, -1, 0), barrel.getWorld(), radius)
									|| Util.isSurroundingBlocksAtLeastOneOf(transformer.getTransformingBlocks(),
											barrel.getPos(), barrel.getWorld(), radius))) {
						// Time to start the process.
						FluidStack fstack = tank.getFluid();
						tank.setFluid(null);

						barrel.setMode("fluidTransform");
						BarrelModeFluidTransform mode = (BarrelModeFluidTransform) barrel.getMode();

						mode.setTransformer(transformer);
						mode.setInputStack(fstack);
						mode.setOutputStack(FluidRegistry.getFluidStack(transformer.getOutputFluid(), 1000));

						PacketHandler.sendNBTUpdate(barrel);
						found = true;
					}
				}
				if (found) break;
			}
		}
	}
}
 
Example 10
Source File: TESRBTank.java    From BetterChests with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void render(TileEntityBTank te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
	FluidTank tank = te.getTank();
	FluidStack stack = tank.getFluid();
	if (stack != null) {

		float fillPercentage = ((float)stack.amount) / tank.getCapacity();
		boolean gaseous = stack.getFluid().isGaseous(stack);
		GlStateManager.pushMatrix();
		GL11.glEnable(GL11.GL_BLEND);

		ResourceLocation loc = stack.getFluid().getStill(stack);
		TextureAtlasSprite sprite = RenderHelper.getAtlasSprite(loc);
		RenderHelper.bindBlockTexture();

		float minY = !gaseous ? 0 : 1 - fillPercentage;
		float maxY = gaseous ? 1 : fillPercentage;

		float minU = sprite.getMinU();
		float maxU = sprite.getMaxU();
		float minV = sprite.getMinV();
		float maxV = sprite.getMaxV();
		float minVHorizontal = minV + (maxV - minV) * minY;
		float maxVHorizontal = minV + (maxV - minV) * maxY;

		GlStateManager.translate(x, y, z);

		GlStateManager.translate(0.5, 0.5, 0.5);
		GlStateManager.scale(12/16D, 12/16D, 12/16D);
		GlStateManager.translate(-0.5, -0.5, -0.5);

		Tessellator tessellator = Tessellator.getInstance();
		BufferBuilder builder = tessellator.getBuffer();

		//south
		builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
		builder.pos(0, minY, 1).tex(minU, minVHorizontal).endVertex();
		builder.pos(1, minY, 1).tex(maxU, minVHorizontal).endVertex();
		builder.pos(1, maxY, 1).tex(maxU, maxVHorizontal).endVertex();
		builder.pos(0, maxY, 1).tex(minU, maxVHorizontal).endVertex();
		tessellator.draw();

		//north
		builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
		builder.pos(1, minY, 0).tex(minU, minVHorizontal).endVertex();
		builder.pos(0, minY, 0).tex(maxU, minVHorizontal).endVertex();
		builder.pos(0, maxY, 0).tex(maxU, maxVHorizontal).endVertex();
		builder.pos(1, maxY, 0).tex(minU, maxVHorizontal).endVertex();
		tessellator.draw();

		//east
		builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
		builder.pos(1, minY, 1).tex(minU, minVHorizontal).endVertex();
		builder.pos(1, minY, 0).tex(maxU, minVHorizontal).endVertex();
		builder.pos(1, maxY, 0).tex(maxU, maxVHorizontal).endVertex();
		builder.pos(1, maxY, 1).tex(minU, maxVHorizontal).endVertex();
		tessellator.draw();

		//west
		builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
		builder.pos(0, minY, 0).tex(minU, minVHorizontal).endVertex();
		builder.pos(0, minY, 1).tex(maxU, minVHorizontal).endVertex();
		builder.pos(0, maxY, 1).tex(maxU, maxVHorizontal).endVertex();
		builder.pos(0, maxY, 0).tex(minU, maxVHorizontal).endVertex();
		tessellator.draw();

		//up
		builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
		builder.pos(1, maxY, 0).tex(minU, minV).endVertex();
		builder.pos(0, maxY, 0).tex(maxU, minV).endVertex();
		builder.pos(0, maxY, 1).tex(maxU, maxV).endVertex();
		builder.pos(1, maxY, 1).tex(minU, maxV).endVertex();
		tessellator.draw();

		//down
		builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
		builder.pos(0, minY, 0).tex(minU, minV).endVertex();
		builder.pos(1, minY, 0).tex(maxU, minV).endVertex();
		builder.pos(1, minY, 1).tex(maxU, maxV).endVertex();
		builder.pos(0, minY, 1).tex(minU, maxV).endVertex();
		tessellator.draw();

		GL11.glDisable(GL11.GL_BLEND);
		GlStateManager.popMatrix();
	}
}