Jump to content

[Solved] [1.7.10] No Fluid Icon


tiffit

Recommended Posts

I am trying to make a GUI that displays fluids inside. I got water to work, but I am not able to get my custom fluid to work.

It says null pointer exception when it tries to get the IIcon from my fluid.

 

Drawing the fluids:

	public void drawFluidTank(IFluidTank tank, int x, int y){
        FluidStack fluid = tank.getFluid();
        TextureManager manager = mc.getTextureManager();
        if (fluid != null){
            manager.bindTexture(manager.getResourceLocation(0)); //Bind the blocks texture map
            float amount = fluid.amount; //The amount of fluid in the tank
            float capacity = tank.getCapacity(); //The max capacity of the tank
            float scale = amount / capacity; // The 'scale' of the fluid, ranging from 0 to 1, with 0 being empty, and 1 being full
            int fluidTankHeight = 60;  // The max height of which the fluid can be drawed, i use 60, so the fluid is drawn max 60 pixels high
            int fluidAmount = (int) (scale * fluidTankHeight); // The amount of pixels the fluid has to be drawn on
            drawFluid(x, y + fluidTankHeight - fluidAmount, fluid.getFluid().getIcon(fluid), 16, fluidAmount); //Actually draw the fluid
        }
    }
    
    private void drawFluid(int x, int y, IIcon icon, int width, int height){
        int i = 0;
        int j = 0;
        
        int drawHeight = 0;
        int drawWidth = 0;
        
        for (i = 0; i < width; i += 16){
            for (j = 0; j < height; j += 16) {
                drawWidth = Math.min(width - i, 16);
                drawHeight = Math.min(height - j, 16);
                System.out.println(icon == null);
                drawTexturedModelRectFromIcon(x + i, y + j, icon, drawWidth, drawHeight);
            }
        }
    }

 

Creating/Registering the fluid:

		Main.filteredWater = new Fluid("filteredWater");
	FluidRegistry.registerFluid(Main.filteredWater);

 

My fluid does work, as in I can place it, pick it up with a bucket, it flows, etc.

Link to comment
Share on other sites

Does your Fluid actually have an icon?

And I mean the

Fluid

not the

BlockFluid

.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.