Java Code Examples for net.minecraftforge.fluids.FluidStack#getFluid()

The following examples show how to use net.minecraftforge.fluids.FluidStack#getFluid() . 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: 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 2
Source File: TofuEnergyStoragedFluidMap.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public static Map.Entry<FluidStack, TofuEnergyStoragedFluid> getSufficientRecipe(FluidStack stack){
    for (Map.Entry<FluidStack, TofuEnergyStoragedFluid> entry : recipes.entrySet()){
        if (entry.getKey().getFluid() == stack.getFluid())
            return entry;
    }
    return null;
}
 
Example 3
Source File: TofuEnergyStoragedFluidMap.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public static Map.Entry<FluidStack, TofuEnergyStoragedFluid> getReversedRecipe(FluidStack stack){
    for (Map.Entry<FluidStack, TofuEnergyStoragedFluid> entry : recipes.entrySet()){
        if (entry.getValue().getOutput().getFluid() == stack.getFluid())
            return entry;
    }

    return null;
}
 
Example 4
Source File: TileEntityAerialInterface.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){
    if(resource != null && canDrain(from, resource.getFluid())) {
        EntityPlayer player = getPlayer();
        if(player != null) {
            int liquidToXP = PneumaticCraftAPIHandler.getInstance().liquidXPs.get(resource.getFluid());
            int pointsDrained = Math.min(getPlayerXP(player), resource.amount / liquidToXP);
            if(doDrain) addPlayerXP(player, -pointsDrained);
            return new FluidStack(resource.getFluid(), pointsDrained * liquidToXP);
        }
    }
    return null;
}
 
Example 5
Source File: TileEntityThermopneumaticProcessingPlant.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private IThermopneumaticProcessingPlantRecipe getValidRecipe(){
    for(IThermopneumaticProcessingPlantRecipe recipe : PneumaticRecipeRegistry.getInstance().thermopneumaticProcessingPlantRecipes) {
        if(recipe.isValidRecipe(inputTank.getFluid(), inventory[4])) {
            if(outputTank.getFluid() == null) {
                return recipe;
            } else {
                FluidStack output = recipe.getRecipeOutput(inputTank.getFluid(), inventory[4]);
                if(output.getFluid() == outputTank.getFluid().getFluid() && output.amount <= outputTank.getCapacity() - outputTank.getFluidAmount()) {
                    return recipe;
                }
            }
        }
    }
    return null;
}
 
Example 6
Source File: RecipeHandlerBase.java    From NEI-Integration with MIT License 5 votes vote down vote up
@Override
public void loadCraftingRecipes(ItemStack result) {
    FluidStack fluid = Utils.getFluidStack(result);
    if (fluid != null && fluid.getFluid() != null) {
        this.loadCraftingRecipes(fluid);
    }
}
 
Example 7
Source File: TileFluidTank.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public FluidStack drain(FluidStack resource,
		boolean doDrain) {
	if(this.fluidTank.getFluid() == null || resource.getFluid() != this.fluidTank.getFluid().getFluid())
		return null;

	return this.drain(resource.amount, doDrain);
}
 
Example 8
Source File: RenderUtil.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static int getFluidColor(FluidStack fluidStack) {
    if (fluidStack.getFluid() == FluidRegistry.WATER)
        return 0x3094CF;
    else if (fluidStack.getFluid() == FluidRegistry.LAVA)
        return 0xFFD700;
    return fluidStack.getFluid().getColor(fluidStack);
}
 
Example 9
Source File: BarrelFluidHandler.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
@Override
public boolean canFillFluidType(FluidStack fluid) {
    if(fluid == null || fluid.getFluid() == null || BarrelLiquidBlacklistRegistry.isBlacklisted(barrel.getTier(), fluid.getFluid().getName()))
        return false;
    
	for (IBarrelMode mode : BarrelModeRegistry.getModes(TriggerType.FLUID))	{
		if (mode.isTriggerFluidStack(fluid))
			return true;
	}
    return false;
}
 
Example 10
Source File: HydroponicTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
public String getFluidName() {

        FluidStack fluid = this.getFluidStack();

        if (fluid == null) {
            return "No fluid";
        }

        if (fluid.getFluid() == null) {
            return "No fluid";
        }

        return fluid.getFluid().getName();
    }
 
Example 11
Source File: MiscUtils.java    From OpenModsLib with MIT License 5 votes vote down vote up
public static String getTranslatedFluidName(FluidStack fluidStack) {
	if (fluidStack == null) return "";
	final Fluid fluid = fluidStack.getFluid();
	String localizedName = fluid.getLocalizedName(fluidStack);
	if (!Strings.isNullOrEmpty(localizedName) && !localizedName.equals(fluid.getUnlocalizedName())) {
		return fluid.getRarity(fluidStack).rarityColor.toString() + localizedName;
	} else {
		return TextFormatting.OBFUSCATED + "LOLNOPE" + TextFormatting.RESET;
	}
}
 
Example 12
Source File: ScrubberTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean canFillFluidType(FluidStack fluidStack) {

    Fluid fluid = fluidStack.getFluid();

    if (fluid == null) {
        return false;
    }

    return ScrubberRecipes.isValidGas(fluid);
}
 
Example 13
Source File: Util.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
public static int getLightValue(FluidStack fluid)
{
    if(fluid != null && fluid.getFluid() != null)
    {
        return fluid.getFluid().getLuminosity(fluid);
    }
    else
    {
        return 0;
    }
}
 
Example 14
Source File: FluidUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static int getLuminosity(FluidStack stack, double density) {
    if (stack.isEmpty()) {
        return 0;
    }
    Fluid fluid = stack.getFluid();
    FluidAttributes attributes = fluid.getAttributes();
    int light = attributes.getLuminosity(stack);
    if (attributes.isGaseous()) {
        light = (int) (light * density);
    }
    return light;
}
 
Example 15
Source File: ItemRendererCertusTank.java    From ExtraCells1 with MIT License 4 votes vote down vote up
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
	Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("extracells", "textures/blocks/texmap_tank.png"));
	GL11.glPushMatrix();
	GL11.glTranslatef(0.5F, 0.5F, 0.5F);
	GL11.glScalef(1.0F, -1F, -1F);
	model.render(0.0625f);
	GL11.glScalef(1.0F, -1F, 1.0F);
	model.render(0.0625f);

	if (item != null && item.hasTagCompound())
	{
		FluidStack storedFluid = FluidStack.loadFluidStackFromNBT(item.getTagCompound().getCompoundTag("tileEntity"));
		int tankCapacity = 32000;

		if (storedFluid != null && storedFluid.getFluid() != null)
		{
			Icon fluidIcon = storedFluid.getFluid().getIcon();

			Tessellator tessellator = Tessellator.instance;
			RenderBlocks renderer = new RenderBlocks();

			GL11.glScalef(1.0F, 1.0F, -1.0F);
			renderer.setRenderBounds(0.08F, 0.001F, 0.08F, 0.92, (float) storedFluid.amount / (float) tankCapacity * 0.999F, 0.92F);
			Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
			GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

			GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
			GL11.glEnable(GL11.GL_CULL_FACE);
			GL11.glDisable(GL11.GL_LIGHTING);
			GL11.glEnable(GL11.GL_BLEND);
			GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

			tessellator.startDrawingQuads();
			tessellator.setNormal(0.0F, -1F, 0.0F);
			renderer.renderFaceYNeg(Block.blocksList[FluidRegistry.WATER.getBlockID()], 0.0D, 0.0D, 0.0D, fluidIcon);
			tessellator.draw();
			tessellator.startDrawingQuads();
			tessellator.setNormal(0.0F, 1.0F, 0.0F);
			renderer.renderFaceYPos(Block.blocksList[FluidRegistry.WATER.getBlockID()], 0.0D, 0.0D, 0.0D, fluidIcon);
			tessellator.draw();
			tessellator.startDrawingQuads();
			tessellator.setNormal(0.0F, 0.0F, -1F);
			renderer.renderFaceZNeg(Block.blocksList[FluidRegistry.WATER.getBlockID()], 0.0D, 0.0D, 0.0D, fluidIcon);
			tessellator.draw();
			tessellator.startDrawingQuads();
			tessellator.setNormal(0.0F, 0.0F, 1.0F);
			renderer.renderFaceZPos(Block.blocksList[FluidRegistry.WATER.getBlockID()], 0.0D, 0.0D, 0.0D, fluidIcon);
			tessellator.draw();
			tessellator.startDrawingQuads();
			tessellator.setNormal(-1F, 0.0F, 0.0F);
			renderer.renderFaceXNeg(Block.blocksList[FluidRegistry.WATER.getBlockID()], 0.0D, 0.0D, 0.0D, fluidIcon);
			tessellator.draw();
			tessellator.startDrawingQuads();
			tessellator.setNormal(1.0F, 0.0F, 0.0F);
			renderer.renderFaceXPos(Block.blocksList[FluidRegistry.WATER.getBlockID()], 0.0D, 0.0D, 0.0D, fluidIcon);
			tessellator.draw();

			GL11.glPopAttrib();
		}
	}

	GL11.glPopMatrix();
}
 
Example 16
Source File: RecipeHandlerCyaniteReprocessor.java    From NEI-Integration with MIT License 4 votes vote down vote up
@Override
public void loadUsageRecipes(FluidStack ingredient) {
    if (ingredient.getFluid() == FluidRegistry.WATER) {
        this.loadAllRecipes();
    }
}
 
Example 17
Source File: FluidStorageHandler.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Override
public boolean canFillFluidType(FluidStack fluid) {

    return fluid.getFluid() == FluidRegistry.WATER;
}
 
Example 18
Source File: RenderUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static boolean shouldRenderFluid(FluidStack stack) {
    return stack.amount > 0 && stack.getFluid() != null;
}
 
Example 19
Source File: DiffuserTileEntity.java    From EmergingTechnology with MIT License 3 votes vote down vote up
@Override
public boolean canFillFluidType(FluidStack fluidStack) {

    Fluid fluid = fluidStack.getFluid();

    return ScrubberRecipes.isValidGas(fluid);
}
 
Example 20
Source File: ModFluidProvider.java    From EmergingTechnology with MIT License 3 votes vote down vote up
public static int getBoostModifierForFluidByFluidStack(FluidStack fluidStack) {

        if (fluidStack == null) return 0;
        if (fluidStack.getFluid() == null) return 0;

        String name = fluidStack.getFluid().getName();

        ModFluid fluid = getFluidByName(name);

        if (fluid == null) return 0;

        return fluid.boostModifier;
    }