Jump to content

Three Icon problems


TrekkieCub314

Recommended Posts

So, I seem to be having some problems when it comes to Icons.

 

1: I have a machine that renders the icon of the fluid it contains, but this is only working for vanilla fluids.  I have one custom fluid created so far, but when I try to render the icon, I get a NullPointer Exception, and where it's being called from is telling me that I'm getting a null value for the still icon in the fluid.  I rearranged my main mod file to see if the problem was in the order I was instantiating the blocks/fluids and registering them, but that didn't seem to work (unless I messed that up)

 

[spoiler=Mod File]

package com.trekkiecub.allthethings;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.FMLEventChannel;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;


@Mod(modid="TrekkieCub_AllTheThings", name = "Trekkie Cub's All The Things", version = "alpha")

public class mod_TCAllTheThings {

//
//  Create an instance of the mod
//

@Instance("mod_TCAllTheThings")
public static mod_TCAllTheThings instance;

//
//  Creative Mode Tab
//

public static CreativeTabs allTheThingsTab = new CreativeTabs("allTheThings"){
	@Override
	public Item getTabIconItem() {
		return Items.emerald;
	}
};

//
//  Item Declarations
//

public static Item Paper_Bowl, Shard_Diamond, Shard_Stone, Powdered_Diamond, Powdered_Stone, Fried_Egg, Burial_Wraps, Bread_Slice, Toast, Crouton, Paper_Mushroom_Stew,
					Lettuce, Bucket_Boiling_Water, Nugget_Iron, Throwing_Star, Throwing_Star_anim, Boomerang_anim, Boomerang, Wood_Board, Amber;

//
//  Block Declarations
//

public static Block Rock_Crusher, dummy_Rock_Crusher, Immersion_Tank, Light_Stone, Block_Boiling_Water, Block_Amber;

//
//  Fluid Declarations
//

public Fluid Boiling_Water;

//
//  Proxy Definitions
//

@SidedProxy(clientSide = "com.trekkiecub.allthethings.Proxy_Client", serverSide = "com.trekkiecub.allthethings.Proxy_Server")
public static Proxy_Common commonProxy;
public static Proxy_Client clientProxy = new Proxy_Client();



public static final String channelName = "TCAllTheThingsChannel";

//
//  Pre-Initialization Event
//

@EventHandler
public void preInit(FMLPreInitializationEvent e) {
	this.clientProxy.preInit(e);

	//
	//  Item Definitions
	//

	Paper_Bowl = new Item_Paper_Bowl().setCreativeTab(allTheThingsTab).setUnlocalizedName("paper_bowl").setTextureName("trekkiecub:paper_bowl");
	Shard_Diamond = new Item_Shard_Diamond();
	Shard_Stone = new Item_Shard_Stone().setCreativeTab(allTheThingsTab).setUnlocalizedName("shard_stone").setTextureName("trekkiecub:shard_rock");
	Powdered_Diamond = new Item_Powdered_Diamond().setCreativeTab(allTheThingsTab).setUnlocalizedName("powdered_diamond").setTextureName("trekkiecub:powdered_diamond");
	Powdered_Stone = new Item_Powdered_Stone().setCreativeTab(allTheThingsTab).setUnlocalizedName("powdered_stone").setTextureName("trekkiecub:powdered_stone");
	Fried_Egg = new Item_Fried_Egg(6, 0.6F).setCreativeTab(allTheThingsTab).setUnlocalizedName("fried_egg").setTextureName("trekkiecub:fried_egg");
	Bread_Slice = new Item_Slice_Bread(1, 0.6F).setCreativeTab(allTheThingsTab).setUnlocalizedName("bread_slice").setTextureName("trekkiecub:bread_slice");
	Burial_Wraps = new Item_Burial_Wraps().setCreativeTab(allTheThingsTab).setUnlocalizedName("burial_wraps").setTextureName("trekkiecub:burial_wraps");
	Toast = new Item_Toast(1, 0.6F).setCreativeTab(allTheThingsTab).setUnlocalizedName("toast").setTextureName("trekkiecub:toast");
	Crouton = new Item_Crouton().setCreativeTab(allTheThingsTab).setUnlocalizedName("crouton").setTextureName("trekkiecub:crouton");
	Paper_Mushroom_Stew = new Item_Disp_Mushroom_Stew(6, 0.6F).setCreativeTab(allTheThingsTab).setUnlocalizedName("paper_mushroom_stew").setTextureName("trekkiecub:paper_mushroom_stew");
	Lettuce = new Item_Lettuce(2, 0.6F).setCreativeTab(allTheThingsTab).setUnlocalizedName("lettuce").setTextureName("trekkiecub:lettuce");
	Nugget_Iron = new Item_Nugget_Iron().setCreativeTab(allTheThingsTab).setUnlocalizedName("nugget_iron").setTextureName("trekkiecub:nugget_iron");
	Throwing_Star = new Item_Throwing_Star().setCreativeTab(allTheThingsTab).setUnlocalizedName("throwing_star").setTextureName("trekkiecub:throwing_star");
	Throwing_Star_anim = new Item_Throwing_Star_Spin().setTextureName("trekkiecub:throwing_star_spin").setCreativeTab(null);
	Boomerang_anim = new Item_Boomerang_Spin().setTextureName("trekkiecub:boomerang_spin").setCreativeTab(null);
	Boomerang = new Item_Boomerang().setTextureName("trekkiecub:boomerang").setCreativeTab(allTheThingsTab).setUnlocalizedName("boomerang");
	Wood_Board = new Item_Wood_Board().setTextureName("trekkiecub:wood_board").setCreativeTab(allTheThingsTab).setUnlocalizedName("wood_board");
	Amber = new Amber().setCreativeTab(allTheThingsTab).setUnlocalizedName("amber").setTextureName("trekkiecub:amber");

	//
	//  Item Registry
	//

	GameRegistry.registerItem(Paper_Bowl, "paper_bowl");
	GameRegistry.registerItem(Shard_Diamond, "shard_diamond");
	GameRegistry.registerItem(Powdered_Diamond, "powdered_diamond");
	GameRegistry.registerItem(Powdered_Stone, "powdered_stone");
	GameRegistry.registerItem(Shard_Stone, "shard_stone");
	GameRegistry.registerItem(Fried_Egg, "fried_egg");
	GameRegistry.registerItem(Burial_Wraps, "burial_wraps");
	GameRegistry.registerItem(Bread_Slice, "bread_slice");
	GameRegistry.registerItem(Toast, "toast");
	GameRegistry.registerItem(Crouton, "crouton");
	GameRegistry.registerItem(Paper_Mushroom_Stew, "paper_mushroom_stew");
	GameRegistry.registerItem(Lettuce, "lettuce");
	GameRegistry.registerItem(Nugget_Iron, "nugget_iron");
	GameRegistry.registerItem(Throwing_Star, "throwing_star");
	GameRegistry.registerItem(Throwing_Star_anim, "throwing_star_anim");
	GameRegistry.registerItem(Boomerang_anim, "boomerang_anim");
	GameRegistry.registerItem(Boomerang, "boomerang");
	GameRegistry.registerItem(Wood_Board, "wood_board");
	GameRegistry.registerItem(Amber, "amber");


	//
	//  Block Definitions
	//

	Rock_Crusher = new Block_Rock_Crusher(Material.rock, false).setStepSound(Block.soundTypeStone).setBlockName("block_rock_crusher").setCreativeTab(allTheThingsTab).setBlockTextureName("trekkiecub:rock_crusher");
	dummy_Rock_Crusher = new Block_Rock_Crusher(Material.rock, true).setStepSound(Block.soundTypeStone).setBlockName("block_rock_crusher").setBlockTextureName("trekkiecub:rock_crusher").setLightLevel((float)1/15);
	Light_Stone = new Block_Light_Stone(Material.rock).setStepSound(Block.soundTypeStone).setBlockName("block_light_stone").setCreativeTab(allTheThingsTab).setBlockTextureName("stone_slab_top");
	Block_Amber = new Block_Amber(Material.iron).setBlockName("block_amber").setCreativeTab(allTheThingsTab).setBlockTextureName("trekkiecub:block_amber").setHardness(3.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);

	//
	//  Block Registry
	//
	GameRegistry.registerBlock(Rock_Crusher, "block_rock_crusher");
	GameRegistry.registerBlock(dummy_Rock_Crusher, "lit_block_rock_crusher");
	GameRegistry.registerBlock(Light_Stone, "block_light_stone");
	GameRegistry.registerBlock(Block_Amber, "block_amber");
	//
	//  Entity Registry
	//

	int ID_Mummy = EntityRegistry.findGlobalUniqueEntityId();
	EntityRegistry.registerGlobalEntityID(Entity_Mummy.class, "Mummy", ID_Mummy);
	EntityRegistry.registerModEntity(Entity_Mummy.class, "Mummy", ID_Mummy, this, 80, 1, true);
	EntityRegistry.addSpawn(Entity_Mummy.class, 2, 0, 1, EnumCreatureType.monster, BiomeGenBase.desert);
	EntityList.entityEggs.put(Integer.valueOf(ID_Mummy), new EntityList.EntityEggInfo(ID_Mummy, 0xe9e5c3, 0xc6c57b));	

	int ID_Throwing_Star = EntityRegistry.findGlobalUniqueEntityId();
	EntityRegistry.registerGlobalEntityID(Entity_Throwing_Star.class, "Throwing Star", ID_Throwing_Star);
	EntityRegistry.registerModEntity(Entity_Throwing_Star.class, "Throwing Star", ID_Throwing_Star, this, 64, 10, true);

	int ID_Boomerang = EntityRegistry.findGlobalUniqueEntityId();
	EntityRegistry.registerGlobalEntityID(Entity_Boomerang.class, "Boomerang", ID_Boomerang);
	EntityRegistry.registerModEntity(Entity_Boomerang.class, "Boomerang", ID_Boomerang, this, 64, 1, true);

	//
	//  Fluid Stuff
	//

	Boiling_Water = new Fluid("boiling_water");
	FluidRegistry.registerFluid(Boiling_Water);
	Block_Boiling_Water = new Fluid_Boiling_Water(Boiling_Water, Material.water).setBlockName("block_boiling_water");
	GameRegistry.registerBlock(Block_Boiling_Water, "block_boiling_water");
	Boiling_Water.setUnlocalizedName(Block_Boiling_Water.getUnlocalizedName());

	Bucket_Boiling_Water = new Item_Bucket_Boiling_Water(Block_Boiling_Water).setCreativeTab(allTheThingsTab).setUnlocalizedName("bucket_boiling_water").setContainerItem(Items.bucket).setTextureName("trekkiecub:bucket_boiling_water");
	GameRegistry.registerItem(Bucket_Boiling_Water, "bucket_boiling_water");
	FluidContainerRegistry.registerFluidContainer(Boiling_Water, new ItemStack(Bucket_Boiling_Water), new ItemStack(Items.bucket));
	Handler_Bucket.INSTANCE.buckets.put(Block_Boiling_Water, Bucket_Boiling_Water);
	MinecraftForge.EVENT_BUS.register(Handler_Bucket.INSTANCE);

	//
	//  Fluid-reliant Items/Blocks
	//

	Immersion_Tank = new Block_Immersion_Tank(Material.rock).setStepSound(Block.soundTypeStone).setBlockName("block_immersion_tank").setCreativeTab(allTheThingsTab).setBlockTextureName("trekkiecub:immersion_tank");
	GameRegistry.registerBlock(Immersion_Tank, "block_immersion_tank");

	//
	//  Crafting Recipes
	//

	GameRegistry.addRecipe(new ItemStack(Paper_Bowl, 10), "p p", " p ", 'p', Items.paper);
	GameRegistry.addRecipe(new ItemStack(Rock_Crusher), "cpc", "p p", "cpc", 'c', Blocks.cobblestone, 'p', Blocks.piston);
	GameRegistry.addRecipe(new ItemStack(Items.spawn_egg, 1, 50), "ggg", "geg", "ggg", 'g', Items.gunpowder, 'e', Items.egg);
	GameRegistry.addRecipe(new ItemStack(Items.spawn_egg, 1, ID_Mummy), "www", "wew", "www", 'w', Burial_Wraps, 'e', Items.egg);
	GameRegistry.addRecipe(new ItemStack(Immersion_Tank), "i i", "ici", "iii", 'i', Items.iron_ingot, 'c', Blocks.chest);
	GameRegistry.addRecipe(new ItemStack(Blocks.cobblestone), "rr", "rr", 'r', Shard_Stone);
	GameRegistry.addShapelessRecipe(new ItemStack(Bread_Slice, , new ItemStack(Items.bread));
	GameRegistry.addShapelessRecipe(new ItemStack(Immersion_Tank), new ItemStack(Blocks.cauldron), new ItemStack(Blocks.chest));
	GameRegistry.addShapelessRecipe(new ItemStack(Crouton, 4), new ItemStack(Toast));
	GameRegistry.addShapelessRecipe(new ItemStack(Paper_Mushroom_Stew),new ItemStack(Paper_Bowl), new ItemStack(Blocks.red_mushroom), new ItemStack(Blocks.brown_mushroom));
	GameRegistry.addShapelessRecipe(new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.stone_slab, 1, 3), new ItemStack(Blocks.stone_slab, 1, 3)); // Make separate block
	GameRegistry.addShapelessRecipe(new ItemStack(Blocks.brick_block), new ItemStack(Blocks.stone_slab, 1, 4), new ItemStack(Blocks.stone_slab, 1, 4));
	GameRegistry.addShapelessRecipe(new ItemStack(Blocks.stonebrick), new ItemStack(Blocks.stone_slab, 1, 5), new ItemStack(Blocks.stone_slab, 1, 5));
	GameRegistry.addShapelessRecipe(new ItemStack(Blocks.nether_brick), new ItemStack(Blocks.stone_slab, 1, 6), new ItemStack(Blocks.stone_slab, 1, 6));
	GameRegistry.addShapelessRecipe(new ItemStack(Blocks.quartz_block), new ItemStack(Blocks.stone_slab, 1, 7), new ItemStack(Blocks.stone_slab, 1, 7));
	GameRegistry.addShapelessRecipe(new ItemStack(Light_Stone), new ItemStack(Blocks.stone_slab, 1, 0), new ItemStack(Blocks.stone_slab, 1, 0));
	GameRegistry.addShapelessRecipe(new ItemStack(Nugget_Iron, 9), new ItemStack(Items.iron_ingot));
	GameRegistry.addRecipe(new ItemStack(Throwing_Star, 4), " f ", "fif", " f ", 'f', Items.flint, 'i', Items.iron_ingot);
	GameRegistry.addRecipe(new ItemStack(Blocks.planks), "ww", "ww", 'w', Wood_Board);
	GameRegistry.addRecipe(new ItemStack(Boomerang), " w ", "w w", 'w', Wood_Board);

	//
	//  Smelting Recipes
	//

	GameRegistry.addSmelting(Items.egg, new ItemStack(Fried_Egg), 0);
	GameRegistry.addSmelting(Bread_Slice, new ItemStack(Toast), 0);
	GameRegistry.addSmelting(Powdered_Stone, new ItemStack(Shard_Stone), 0);
	GameRegistry.addSmelting(Items.water_bucket, new ItemStack(Bucket_Boiling_Water), 0);

	//
	//  Proxy Functions
	//

	clientProxy.registerRenderThings();


	//

	GameRegistry.registerTileEntity(TileEntity_ImmersionTank.class, "immersion_tank");

}

//
//  Initialization Event
//

@EventHandler
public void Init(FMLInitializationEvent e) {
	this.clientProxy.init(e);
}

//
//  Post-Initialization Event
//

@EventHandler
public void postInit(FMLPostInitializationEvent e) {
	this.clientProxy.postInit(e);
	//
	//  Network Registry
	//

	NetworkRegistry.INSTANCE.registerGuiHandler(this, new Handler_Gui());
}

}

 

 

[spoiler=Liquid File]

package com.trekkiecub.allthethings;

import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class Fluid_Boiling_Water extends BlockFluidClassic {

@SideOnly(Side.CLIENT)
protected IIcon stillIcon, flowingIcon;

public Fluid_Boiling_Water(Fluid fluid, Material material) {
	super(fluid, material);
	// TODO Auto-generated constructor stub
}

@Override public IIcon getIcon(int side, int meta)
{
	return (side == 0 || side == 1) ? stillIcon : flowingIcon;
}

//@SideOnly(Side.CLIENT)
@Override public void registerBlockIcons(IIconRegister register)
{
	stillIcon = register.registerIcon("trekkiecub:still_boiling_water");
	flowingIcon = register.registerIcon("trekkiecub:flow_boiling_water");
}

 @Override
     public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
        if (world.getBlock(x,  y,  z).getMaterial().isLiquid()) return false;
        return super.canDisplace(world, x, y, z);
     }
     
     @Override
     public boolean displaceIfPossible(World world, int x, int y, int z) {
        if (world.getBlock(x,  y,  z).getMaterial().isLiquid()) return false;
        return super.displaceIfPossible(world, x, y, z);
     }
     
     public IIcon getStillIcon()
     {
    	 return getIcon(0, 0);
     }
     
     public IIcon getFlowingIcon()
     {
    	 return getIcon(1, 0);
     }

}

 

 

[spoiler=Block Renderer]

package com.trekkiecub.allthethings;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidRegistry;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import com.trekkiecub.allthethings.Block_Immersion_Tank;

public class Render_Immersion_Tank implements ISimpleBlockRenderingHandler {


@Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
	// TODO Auto-generated method stub

}

@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
	if (Proxy_Client.renderPass == 0)
	{
		TileEntity_ImmersionTank tileEnt = (TileEntity_ImmersionTank) world.getTileEntity(x, y, z);
		IIcon newIcon = FluidRegistry.WATER.getIcon();

		if (tileEnt.getFluid() == null || tileEnt.getFluid().getFluid() == null || tileEnt.getFluid().amount == 0)
		{
			newIcon = ((Block_Immersion_Tank) block).front_fluid;
		}
		else
			newIcon = tileEnt.getFluid().getFluid().getStillIcon();

		renderer.renderFaceXNeg(block, x, y, z, newIcon);
		renderer.renderFaceXPos(block, x, y, z, newIcon);
		renderer.renderFaceZNeg(block, x, y, z, newIcon);
		renderer.renderFaceZPos(block, x, y, z, newIcon);
		renderer.renderFaceYNeg(block, x, y, z, newIcon);
		renderer.renderFaceYPos(block, x, y, z, newIcon);
		//renderer.renderStandardBlock(Blocks.flowing_water, x, y, z);
	}
	else
	{
		renderer.renderStandardBlock(mod_TCAllTheThings.Immersion_Tank, x, y, z);
	}

	return true;
}



@Override
public boolean shouldRender3DInInventory(int modelId) {
	// TODO Auto-generated method stub
	return false;
}

@Override
public int getRenderId() {
	return Proxy_Client.immersionTankRenderType;
}

}

 

 

 

2: Because I am using a custom renderer, I'm not sure how to go about rendering the icon for the block while in the inventory.  Currently it's using the block's top face, but I'd like it to render like a furnace might.

 

3: I am using a GUI for my block that renders the icon of the fluid as a large box in the center of the gui, but I also wanted to have the graphic for an item slot appear on top of that.  As such, I rendered the fluid, then the graphic on top of that.  Unfortunately, when working, the icon for the item I place in the slot disappears as it's being rendered over by the fluid and the graphic.  I was thinking about getting the icon for the item in the appropriate slot from the tile entity that was passed in, but I can't get further than getting the item.  I'm not sure how to get the icon from the item, and the item passed in can either be a regular Item or an item obtained from a Block.

 

[spoiler=GUI]

package com.trekkiecub.allthethings;

import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;

import org.lwjgl.opengl.GL11;

public class Gui_ImmersionTank extends GuiContainer {
private TileEntity_ImmersionTank tileTank;

public Gui_ImmersionTank(InventoryPlayer invPlayer, TileEntity_ImmersionTank tileImmTank)
{
	super(new Container_ImmersionTank(invPlayer, tileImmTank));
	this.tileTank = tileImmTank;
}

@Override protected void drawGuiContainerForegroundLayer(int param1, int param2)
{
	fontRendererObj.drawString("Immersion Tank", 8, 6, 4210752);
	fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize-96+2, 4210752);
}

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
	this.mc.renderEngine.bindTexture(new ResourceLocation("trekkiecub:textures/gui/immersion_tank.png"));
	int x = (this.width - this.xSize)/2;
	int y = (this.height - this.ySize)/2;
	this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);

	// Soak Progress Bar

	int startPoint = this.tileTank.getSoakProgressScaled(54);
	this.drawTexturedModalRect(x+62, x+69, 2, 176, startPoint+1, 5);

	// Fluid

	FluidStack fluid = tileTank.getFluid();
	IIcon drawThis;
	if (fluid == null)
	{
		drawThis = FluidRegistry.WATER.getStillIcon();
	}
	else
		drawThis = fluid.getFluid().getStillIcon();
	mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
	GL11.glColor3f(1.0F,1.0F,1.0F);
	int rectHeight = this.tileTank.getFluidAmountScaled(37);
	this.drawTexturedModelRectFromIcon(x+65, y+27+(37-rectHeight), drawThis, 48, rectHeight); // max 63

	// Draw slot item on top of fluid texture
	this.mc.renderEngine.bindTexture(new ResourceLocation("trekkiecub:textures/gui/immersion_tank.png"));
	GL11.glColor3f(1.0F, 1.0F, 1.0F);
	this.drawTexturedModalRect(x+79, y+36, 79, 36, 18, 18);

	// Figure out how to draw item icon here

	// Draw progress bar
	int i1 = this.tileTank.getSoakProgressScaled(54);
	this.drawTexturedModalRect(x+63, y+69, 3, 167, i1, 5);

}

}

 

 

 

If anyone knows how to help me with these and is willing to provide said help, I'd greatly appreciate it!

Link to comment
Share on other sites

You got a crash, which is a Null Pointer, and you didn't bother including the crash report.

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

You got a crash, which is a Null Pointer, and you didn't bother including the crash report.

 

I didn't include a crash report because this isn't the first time I've programmed and I know how to parse error messages.  A NullPointer exception comes up when trying to use a method or access a property of a field which isn't instantiated or is set to null.  Hence why I explained where the error is coming from in the OP.

 

But if you want the crash report, here it is:

[spoiler=crash report]

 

java.lang.NullPointerException: Unexpected error

at net.minecraft.client.renderer.RenderBlocks.renderFaceXNeg(RenderBlocks.java:7652)

at com.trekkiecub.allthethings.Render_Immersion_Tank.renderWorldBlock(Render_Immersion_Tank.java:37)

at cpw.mods.fml.client.registry.RenderingRegistry.renderWorldBlock(RenderingRegistry.java:118)

at net.minecraft.src.FMLRenderAccessLibrary.renderWorldBlock(FMLRenderAccessLibrary.java:53)

at net.minecraft.client.renderer.RenderBlocks.renderBlockByRenderType(RenderBlocks.java:386)

at net.minecraft.client.renderer.WorldRenderer.updateRenderer(WorldRenderer.java:206)

at net.minecraft.client.renderer.RenderGlobal.updateRenderers(RenderGlobal.java:1610)

at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1251)

at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1086)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1010)

at net.minecraft.client.Minecraft.run(Minecraft.java:898)

at net.minecraft.client.main.Main.main(Main.java:112)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

 

 

 

 

Link to comment
Share on other sites

Ok, from that, I get the following:

 

java.lang.NullPointerException: Unexpected error something was null

  at net.minecraft.client.renderer.RenderBlocks.renderFaceXNeg(RenderBlocks.java:7652) here's the line the null object was referenced, not "my" code, but...

  at com.trekkiecub.allthethings.Render_Immersion_Tank.renderWorldBlock(Render_Immersion_Tank.java:37) Ah, this line passed a null object to RenderBlocks

 

Looking at Render_Immersion_Tank.java line 37, I see the call to renderFaceXNeg.

renderer.renderFaceXNeg(block, x, y, z, newIcon);

 

Only two things could possibly be null here:

block

or

newIcon

.  My bet is on

newIcon

.

 

Insert some debug statements to figure out which path through your if statement the code is taking and what value

newIcon

has at each step.  Work backwards until you figure out where the null is coming from and why.

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

Ok, from that, I get the following:

 

java.lang.NullPointerException: Unexpected error something was null

  at net.minecraft.client.renderer.RenderBlocks.renderFaceXNeg(RenderBlocks.java:7652) here's the line the null object was referenced, not "my" code, but...

  at com.trekkiecub.allthethings.Render_Immersion_Tank.renderWorldBlock(Render_Immersion_Tank.java:37) Ah, this line passed a null object to RenderBlocks

 

Looking at Render_Immersion_Tank.java line 37, I see the call to renderFaceXNeg.

renderer.renderFaceXNeg(block, x, y, z, newIcon);

 

Only two things could possibly be null here:

block

or

newIcon

.  My bet is on

newIcon

.

 

Insert some debug statements to figure out which path through your if statement the code is taking and what value

newIcon

has at each step.  Work backwards until you figure out where the null is coming from and why.

 

It couldn't be block.  The error starts in the RenderBlocks class, at this line:

double d3 = (double)p_147798_8_.getInterpolatedU(this.renderMinZ * 16.0D);

The only thing that could be null in this case is the p_147798_8, which is the IIcon passed into the function renderFaceXNeg.  A null value had to be passed into the renderFaceXNeg function.

 

Looking back at the Render_Immersion_Tank file, we see the icon is set to the icon of water when it is created.  I then check some conditions to see if I should render a default face instead of a liquid.  The only other change that occurs with the icon is when that if statement doesn't go through and it falls to the else statement below.  Since there was no null pointer error here, the tile entity, its FluidTank, and that FluidTank's fluid were not null.  The only place the null value could come from was the getStillIcon() function.

 

Looking back at the fluid file, the getStillIcon() function calls the getIcon function, with parameters passed to ensure the flowing icon gets returned.  The only way to get a null value out of that is if the getStillIcon() function is being called before the registerBlockIcons function, and I'm not sure how that is happening.  Changing the getStillIcon function to get the stillIcon item directly doesn't help.

 

Link to comment
Share on other sites

Since there was no null pointer error here, the tile entity, its FluidTank, and that FluidTank's fluid were not null.  The only place the null value could come from was the getStillIcon() function.

 

Looking back at the fluid file, the getStillIcon() function calls the getIcon function, with parameters passed to ensure the flowing icon gets returned.  The only way to get a null value out of that is if the getStillIcon() function is being called before the registerBlockIcons function, and I'm not sure how that is happening.  Changing the getStillIcon function to get the stillIcon item directly doesn't help.

 

Again, you're going to have to insert some debug statements to determine the cause.  I can't give you any more help from here.

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

Two of the three problems are now solved:

 

To render the custom fluid correctly, instead of calling getFluid().getStillIcon, I used getFluid().getBlock().getBlockTextureFromSide(0) and it worked for both the gui and the block renderer.

 

The icon for the block was mostly copy-paste from RenderBlocks.renderBlockAsItem() with the metadata being passed in being modified with the corresponding block's getIcon() function being modified to accommodate.

 

I am still unsure how to render the icon for the item being processed on top of the fluid and item slot I'm rendering when the block is updated.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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