net.minecraftforge.fluids.FluidTankInfo Java Examples

The following examples show how to use net.minecraftforge.fluids.FluidTankInfo. 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: FluidHelper.java    From BigReactors with MIT License 6 votes vote down vote up
public FluidTankInfo[] getTankInfo(int idx) {
	if(idx >= fluids.length) { return emptyTankArray; }
	
	FluidTankInfo[] info;

	if(idx < 0) {
		// All tanks
		info = new FluidTankInfo[fluids.length];
		for(int i = 0; i < fluids.length; i++) {
			info[i] = new FluidTankInfo(fluids[i] == null ? null : fluids[i].copy(), getCapacity());
		}
		
		return info;
	}
	else {
		info = new FluidTankInfo[1];
		info[0] = new FluidTankInfo(fluids[idx] == null ? null : fluids[idx].copy(), getCapacity());
	}

	return info;
}
 
Example #2
Source File: RenderUtils.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
public void renderLiquid(FluidTankInfo info, RenderInfo renderInfo, World worldObj){
    if(info.fluid.getFluid().getBlock() != null) {
        renderInfo.baseBlock = info.fluid.getFluid().getBlock();
    } else {
        renderInfo.baseBlock = Blocks.water;
    }
    renderInfo.texture = info.fluid.getFluid().getIcon(info.fluid);
    FMLClientHandler.instance().getClient().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
    // Tessellator.instance.setColorOpaque_I();
    int color = info.fluid.getFluid().getColor(info.fluid);
    int red = color >> 16 & 255;
    int green = color >> 8 & 255;
    int blue = color & 255;
    GL11.glColor4ub((byte)red, (byte)green, (byte)blue, (byte)255);
    RenderUtils.INSTANCE.renderBlock(renderInfo, worldObj, 0, 0, 0, false, true);
}
 
Example #3
Source File: BeefGuiFluidBar.java    From BigReactors with MIT License 6 votes vote down vote up
@Override
public String[] getTooltip() {
	if(!visible) { return null; }

	FluidTankInfo[] tanks = this._entity.getTankInfo();
	if(tanks != null && tankIdx < tanks.length) {
		FluidStack tankFluid = tanks[tankIdx].fluid;
		if(tankFluid != null) {
			String fluidName = tankFluid.getFluid().getLocalizedName(tankFluid);
			if(tankFluid.getFluid().getID() == FluidRegistry.WATER.getID()) {
				fluidName = "Water";
			}
			else if(tankFluid.getFluid().getID() == FluidRegistry.LAVA.getID()) {
				fluidName = "Lava";
			}

			return new String[] { fluidName, String.format("%d / %d mB", tankFluid.amount, tanks[tankIdx].capacity) };
		}
		else {
			return new String[] { "Empty", String.format("0 / %d mB", tanks[tankIdx].capacity) };
		}
	}
	return null;
}
 
Example #4
Source File: ModelPlasticMixer.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void renderStatic(float size, TileEntity te){
    Shape2.render(size);
    Shape3b.render(size);
    Shape1.render(size);
    Shape3.render(size);
    Shape4b.render(size);
    Shape4.render(size);

    if(te != null) {
        TileEntityPlasticMixer mixer = (TileEntityPlasticMixer)te;
        FluidTankInfo info = mixer.getTankInfo(null)[0];
        if(info.fluid != null && info.fluid.amount > 10) {
            float percentageFull = (float)info.fluid.amount / info.capacity;
            RenderInfo renderInfo = new RenderInfo(-6 / 16F + 0.01F, 22 / 16F - percentageFull * 13.999F / 16F, -6 / 16F + 0.01F, 6 / 16F - 0.01F, 22 / 16F, 6 / 16F - 0.01F);
            RenderUtils.INSTANCE.renderLiquid(info, renderInfo, mixer.getWorldObj());
        }
    }
}
 
Example #5
Source File: TileLiquidTranslocator.java    From Translocators with MIT License 6 votes vote down vote up
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from)
{
    if(from == ForgeDirection.UNKNOWN) {
        List<FluidTankInfo> list = new LinkedList<FluidTankInfo>();
        for(Attachment a : attachments)
            if(a != null)
                list.add(new FluidTankInfo(null, 0));
        
        return list.toArray(new FluidTankInfo[0]);
    }
    
    if(attachments[from.ordinal()] != null)
        return new FluidTankInfo[]{new FluidTankInfo(null, 0)};
    
    return new FluidTankInfo[0];
}
 
Example #6
Source File: SemiBlockRequester.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int amountRequested(FluidStack stack){
    int totalRequestingAmount = getTotalRequestedAmount(stack);
    if(totalRequestingAmount > 0) {
        TileEntity te = getTileEntity();
        if(te instanceof IFluidHandler) {

            int count = 0;

            for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                FluidTankInfo[] infos = ((IFluidHandler)te).getTankInfo(d);
                if(infos != null) {
                    for(FluidTankInfo info : infos) {
                        if(info.fluid != null && info.fluid.getFluid() == stack.getFluid()) {
                            count += info.fluid.amount;
                        }
                    }
                    if(count > 0) break;
                }
            }

            count += getIncomingFluid(stack.getFluid());
            int requested = Math.max(0, Math.min(stack.amount, totalRequestingAmount - count));
            return requested;
        }

    }
    return 0;
}
 
Example #7
Source File: TileEntityAerialInterface.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from){
    updateXpFluid();
    if(curXpFluid != null) {
        EntityPlayer player = getPlayer();
        if(player != null) {
            return new FluidTankInfo[]{new FluidTankInfo(new FluidStack(curXpFluid, getPlayerXP(player) * PneumaticCraftAPIHandler.getInstance().liquidXPs.get(curXpFluid)), Integer.MAX_VALUE)};
        }
    }
    return null;
}
 
Example #8
Source File: TileEntityReactorCoolantPort.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
	if(!isConnected() || from != getOutwardsDir()) { return emptyTankArray; }

	CoolantContainer cc = getReactorController().getCoolantContainer();
	return cc.getTankInfo(getConnectedTank());
}
 
Example #9
Source File: MultiblockTurbine.java    From BigReactors with MIT License 5 votes vote down vote up
public FluidTankInfo[] getTankInfo() {
	FluidTankInfo[] infos = new FluidTankInfo[NUM_TANKS];
	for(int i = 0; i < NUM_TANKS; i++) {
		infos[i] = tanks[i].getInfo();
	}

	return infos;
}
 
Example #10
Source File: ModelLiquidHopper.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void renderBottom(TileEntityOmnidirectionalHopper hopper){
    if(hopper != null) {

        TileEntityLiquidHopper liquidHopper = (TileEntityLiquidHopper)hopper;
        FluidTankInfo info = liquidHopper.getTankInfo(null)[0];
        if(info.fluid != null && info.fluid.amount > 10) {
            GL11.glDisable(GL11.GL_LIGHTING);
            float percentageFull = Math.min(1, (float)info.fluid.amount / (info.capacity / 10));
            RenderInfo renderInfo = new RenderInfo(-2 / 16F + 0.001F, 14 / 16F + 0.001F, 8 / 16F - percentageFull * 3.999F / 16F, 2 / 16F - 0.001F, 18 / 16F - 0.001F, 8 / 16F - 0.001F);
            RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());
            GL11.glEnable(GL11.GL_LIGHTING);
        }
    }
}
 
Example #11
Source File: ModelKeroseneLamp.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void renderStatic(float size, TileEntity te){
    ForgeDirection sideConnected = ForgeDirection.DOWN;
    if(te != null) {
        sideConnected = ((TileEntityKeroseneLamp)te).getSideConnected();
    }

    Tank.render(size);
    Holder1.render(size);
    Holder2.render(size);
    Base.render(size);
    Top.render(size);
    if(sideConnected != ForgeDirection.DOWN) {
        Support1.render(size);
        if(sideConnected != ForgeDirection.UP) {
            SupportSide.rotateAngleY = 0;
            ForgeDirection rotation = ((TileEntityKeroseneLamp)te).getRotation();
            if(rotation != ForgeDirection.UP && rotation != ForgeDirection.DOWN) {
                while(sideConnected != rotation.getOpposite()) {
                    sideConnected = sideConnected.getRotation(ForgeDirection.DOWN);
                    SupportSide.rotateAngleY += Math.toRadians(90);
                }
            }
            SupportSide2.rotateAngleY = SupportSide.rotateAngleY;
            SupportSide.render(size);
            SupportSide2.render(size);
        }
    }
    if(te != null) {
        FluidTankInfo info = ((TileEntityKeroseneLamp)te).getTankInfo(null)[0];
        if(info.fluid != null && info.fluid.amount > 10) {
            float percentageFull = (float)info.fluid.amount / info.capacity;
            RenderInfo renderInfo = new RenderInfo(-3 / 16F + 0.01F, 23 / 16F - percentageFull * 2.999F / 16F, -3 / 16F + 0.01F, 3 / 16F - 0.01F, 22.99F / 16F, 3 / 16F - 0.01F);
            RenderUtils.INSTANCE.renderLiquid(info, renderInfo, te.getWorldObj());
        }
    }
}
 
Example #12
Source File: TileEntityPoweredInventoryFluid.java    From BigReactors with MIT License 5 votes vote down vote up
/**
 * Returns an array of objects which represent the internal tanks. These objects cannot be used
 * to manipulate the internal tanks. See {@link FluidTankInfo}.
 * 
 * @return Info for the relevant internal tanks.
 */
public FluidTankInfo[] getTankInfo() {
	FluidTankInfo[] infos = new FluidTankInfo[tanks.length];
	for(int i = 0; i < tanks.length; i++) {
		infos[i] = tanks[i].getInfo();
	}
	
	return infos;
}
 
Example #13
Source File: MultiblockTurbineSimulator.java    From reactor_simulator with MIT License 5 votes vote down vote up
public FluidTankInfo[] getTankInfo() {
  FluidTankInfo[] infos = new FluidTankInfo[NUM_TANKS];
  for (int i = 0; i < NUM_TANKS; i++) {
    infos[i] = tanks[i].getInfo();
  }

  return infos;
}
 
Example #14
Source File: MultiblockReactorSimulator.java    From reactor_simulator with MIT License 5 votes vote down vote up
@Override
public FluidTankInfo[] getTankInfo() {
  if (isPassivelyCooled()) {
    return emptyTankInfo;
  }

  return coolantContainer.getTankInfo(-1);
}
 
Example #15
Source File: BeefGuiFluidBar.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
protected IIcon getProgressBarIcon() {
	FluidTankInfo[] tanks = this._entity.getTankInfo();
	if(tanks != null && tankIdx < tanks.length) {
		if(tanks[tankIdx].fluid != null) {
			return tanks[tankIdx].fluid.getFluid().getIcon();
		}
	}
	return null;
}
 
Example #16
Source File: BeefGuiFluidBar.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
protected float getProgress() {
	FluidTankInfo[] tanks = this._entity.getTankInfo();
	if(tanks != null && tankIdx < tanks.length) {
		FluidStack tankFluid = tanks[tankIdx].fluid;
		if(tankFluid != null) {
			return (float)tankFluid.amount / (float)tanks[tankIdx].capacity;
		}
	}
	return 0.0f;
}
 
Example #17
Source File: ConverterFluidTankInfoOutbound.java    From OpenPeripheral with MIT License 5 votes vote down vote up
@Override
public Object convert(IConverter registry, FluidTankInfo fti) {
	Map<String, Object> map = Maps.newHashMap();
	map.put("capacity", fti.capacity);
	map.put("contents", registry.fromJava(fti.fluid));
	return map;
}
 
Example #18
Source File: FluidBusInventoryHandler.java    From ExtraCells1 with MIT License 5 votes vote down vote up
public FluidTankInfo[] getTankInfo(IFluidHandler tank)
{
	if (tank != null)
	{
		if (tank.getTankInfo(facing) != null && tank.getTankInfo(facing).length != 0)
		{
			return tank.getTankInfo(facing);
		} else if (tank.getTankInfo(ForgeDirection.UNKNOWN) != null && tank.getTankInfo(ForgeDirection.UNKNOWN).length != 0)
		{
			return tank.getTankInfo(ForgeDirection.UNKNOWN);
		}
	}
	return null;
}
 
Example #19
Source File: TileEnderTank.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
    if(worldObj.isRemote)
        return new FluidTankInfo[]{new FluidTankInfo(liquid_state.s_liquid, EnderLiquidStorage.CAPACITY)};

    return storage.getTankInfo(from);
}
 
Example #20
Source File: MultiblockReactorSimulator.java    From reactor_simulator with MIT License 5 votes vote down vote up
@Override
public FluidTankInfo[] getTankInfo() {
  if (isPassivelyCooled()) {
    return emptyTankInfo;
  }

  return coolantContainer.getTankInfo(-1);
}
 
Example #21
Source File: MultiblockTurbineSimulator.java    From reactor_simulator with MIT License 5 votes vote down vote up
public FluidTankInfo[] getTankInfo() {
  FluidTankInfo[] infos = new FluidTankInfo[NUM_TANKS];
  for (int i = 0; i < NUM_TANKS; i++) {
    infos[i] = tanks[i].getInfo();
  }

  return infos;
}
 
Example #22
Source File: MultiblockTurbine.java    From BigReactors with MIT License 4 votes vote down vote up
public FluidTankInfo getTankInfo(int tankIdx) {
	return tanks[tankIdx].getInfo();
}
 
Example #23
Source File: TileEntityTurbineFluidPort.java    From BigReactors with MIT License 4 votes vote down vote up
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
	if(!isConnected() || from != getOutwardsDir()) { return emptyTankInfoArray; }
	return new FluidTankInfo[] { getTurbine().getTankInfo(getTankIndex()) };
}
 
Example #24
Source File: MultiblockReactor.java    From BigReactors with MIT License 4 votes vote down vote up
@Override
public FluidTankInfo[] getTankInfo() {
	if(isPassivelyCooled()) { return emptyTankInfo; }
	
	return coolantContainer.getTankInfo(-1);
}
 
Example #25
Source File: BlockBRDevice.java    From BigReactors with MIT License 4 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) {
	TileEntity te = world.getTileEntity(x, y, z);
	if(te == null) { return false; }

	if(entityPlayer.isSneaking()) {

		// Wrench + Sneak = Dismantle
		if(StaticUtils.Inventory.isPlayerHoldingWrench(entityPlayer)) {
			// Pass simulate == true on the client to prevent creation of "ghost" item stacks
			dismantleBlock(entityPlayer, null, world, x, y, z, false, world.isRemote);
			return true;
		}

		return false;
	}
	
	if(te instanceof IWrenchable && StaticUtils.Inventory.isPlayerHoldingWrench(entityPlayer)) {
		return ((IWrenchable)te).onWrench(entityPlayer, side);
	}

	// Handle buckets
	if(te instanceof IFluidHandler)
	{
		if(FluidContainerRegistry.isEmptyContainer(entityPlayer.inventory.getCurrentItem())) {
			IFluidHandler fluidHandler = (IFluidHandler)te;
			FluidTankInfo[] infoz = fluidHandler.getTankInfo(ForgeDirection.UNKNOWN);
			for(FluidTankInfo info : infoz) {
				if(StaticUtils.Fluids.fillContainerFromTank(world, fluidHandler, entityPlayer, info.fluid)) {
					return true;
				}
			}
		}
		else if(FluidContainerRegistry.isFilledContainer(entityPlayer.inventory.getCurrentItem()))
		{
			if(StaticUtils.Fluids.fillTankWithContainer(world, (IFluidHandler)te, entityPlayer)) {
				return true;
			}
		}
	}

	// Show GUI
	if(te instanceof TileEntityBeefBase) {
		if(!world.isRemote) {
			entityPlayer.openGui(BRLoader.instance, 0, world, x, y, z);
		}
		return true;
	}
	
	return false;
}
 
Example #26
Source File: TileEntityVoidFluid.java    From ExtraCells1 with MIT License 4 votes vote down vote up
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from)
{
	return new FluidTankInfo[]
	{ new FluidTankInfo(null, 10000) };
}
 
Example #27
Source File: ModelLiquidHopper.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void renderMain(TileEntityOmnidirectionalHopper hopper){
    if(hopper != null) {
        TileEntityLiquidHopper liquidHopper = (TileEntityLiquidHopper)hopper;

        FluidTankInfo info = liquidHopper.getTankInfo(null)[0];
        int fluidAmount = info.fluid != null ? info.fluid.amount - info.capacity / 10 : 0;
        if(fluidAmount > 10) {
            GL11.glDisable(GL11.GL_LIGHTING);
            float percentageFull = Math.min(1, fluidAmount / (info.capacity * 0.3F));

            RenderInfo renderInfo = new RenderInfo(-4 / 16F + 0.001F, 12 / 16F + 0.001F, 4 / 16F - percentageFull * 5.999F / 16F, 4 / 16F - 0.001F, 20 / 16F - 0.001F, 4 / 16F - 0.001F);
            RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());

            fluidAmount -= info.capacity * 0.3F;
            if(fluidAmount > 10) {
                percentageFull = Math.min(1, fluidAmount / (info.capacity * 0.3F));

                renderInfo = new RenderInfo(-6 / 16F + 0.001F, 10 / 16F + 0.001F, -2 / 16F - percentageFull * 0.999F / 16F, 6 / 16F - 0.001F, 22 / 16F - 0.001F, -2 / 16F - 0.001F);
                RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());

                fluidAmount -= info.capacity * 0.3F;
                if(fluidAmount > 10) {
                    percentageFull = Math.min(1, fluidAmount / (info.capacity * 0.3F));
                    renderInfo = new RenderInfo(6 / 16F + 0.001F, 8 / 16F + 0.001F, -2 / 16F - percentageFull * 5.999F / 16F, 8 / 16F - 0.001F, 24 / 16F - 0.001F, -2 / 16F - 0.001F);
                    RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());

                    renderInfo = new RenderInfo(-8 / 16F + 0.001F, 8 / 16F + 0.001F, -2 / 16F - percentageFull * 5.999F / 16F, -6 / 16F - 0.001F, 24 / 16F - 0.001F, -2 / 16F - 0.001F);
                    RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());

                    renderInfo = new RenderInfo(-6 / 16F + 0.001F, 22 / 16F + 0.001F, -2 / 16F - percentageFull * 5.999F / 16F, 6 / 16F - 0.001F, 24 / 16F - 0.001F, -2 / 16F - 0.001F);
                    RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());

                    renderInfo = new RenderInfo(-6 / 16F + 0.001F, 8 / 16F + 0.001F, -2 / 16F - percentageFull * 5.999F / 16F, 6 / 16F - 0.001F, 10 / 16F - 0.001F, -2 / 16F - 0.001F);
                    RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());
                }
            }

            FMLClientHandler.instance().getClient().getTextureManager().bindTexture(getModelTexture(hopper));
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glColor4d(1, 1, 1, 1);
        }
    }
}
 
Example #28
Source File: MultiblockTurbineSimulator.java    From reactor_simulator with MIT License 4 votes vote down vote up
public FluidTankInfo getTankInfo(int tankIdx) {
  return tanks[tankIdx].getInfo();
}
 
Example #29
Source File: TileEnderTank.java    From EnderStorage with MIT License 4 votes vote down vote up
@Override
public int comparatorInput() {
    FluidTankInfo tank = storage.getTankInfo(null)[0];
    return tank.fluid.amount * 14 / tank.capacity + (tank.fluid.amount > 0 ? 1 : 0);
}
 
Example #30
Source File: EnderLiquidStorage.java    From EnderStorage with MIT License 4 votes vote down vote up
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
    return new FluidTankInfo[]{tank.getInfo()};
}