GhostSnyperRecon Posted July 2, 2013 Share Posted July 2, 2013 so yeah as the title says i need some help with how to get textures to work on meta data blocks. this is my code for the block package naturemod.common.blocks; import static net.minecraftforge.common.EnumPlantType.Cave; import static net.minecraftforge.common.EnumPlantType.Crop; import static net.minecraftforge.common.EnumPlantType.Desert; import static net.minecraftforge.common.EnumPlantType.Nether; import static net.minecraftforge.common.EnumPlantType.Plains; import static net.minecraftforge.common.EnumPlantType.Water; import java.util.List; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockFlower; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.common.IPlantable; public class BlockMoreFlowers extends BlockFlower implements IPlantable { private Icon[] icon; public static final String[] flowerType = new String[] {"flowerOrange", "flowerMagenta", "flowerLBlue", "flowerPink", "flowerCyan", "flowerPurple"}; private static final String[] field_94370_b = new String[] {"Nature:flower_0", "Nature:flower_1", "Nature:flower_2", "Nature:flower_3", "Nature:flower_4", "Nature:flower_5"}; @SideOnly(Side.CLIENT) private Icon[] flowerIcon; public BlockMoreFlowers(int id) { super(id, Material.plants); this.setStepSound(soundGrassFootstep); this.setHardness(0.0f); this.disableStats(); } @SideOnly(Side.CLIENT) /** * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata */ public Icon getIcon(int par1, int par2) { return this.icon[par2 % this.icon.length]; } public int getDamageValue(World par1World, int par2, int par3, int par4) { return par1World.getBlockMetadata(par2, par3, par4); } @Override public int damageDropped (int metadata) { return metadata; } @SideOnly(Side.CLIENT) public void getSubBlocks(int unknown, CreativeTabs tab, List subItems) { for (int ix = 0; ix < 6; ix++) { subItems.add(new ItemStack(this, 1, ix)); } } @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister par1IconRegister) { this.icon = new Icon[6]; for(int i = 0; i < 6; i++) { this.icon = par1IconRegister.registerIcon("Nature:flower_" + i); } } @Override public EnumPlantType getPlantType(World world, int x, int y, int z) { return Plains; } @Override public int getPlantID(World world, int x, int y, int z) { return blockID; } @Override public int getPlantMetadata(World world, int x, int y, int z) { return world.getBlockMetadata(x, y, z); } } and this is the error im getting: 2013-07-02 22:08:23 [iNFO] [sTDOUT] Time: 02/07/13 22:08 2013-07-02 22:08:23 [iNFO] [sTDOUT] Description: Unexpected error 2013-07-02 22:08:23 [iNFO] [sTDOUT] 2013-07-02 22:08:23 [iNFO] [sTDOUT] java.lang.NullPointerException 2013-07-02 22:08:23 [iNFO] [sTDOUT] at naturemod.common.blocks.BlockMoreFlowers.getIcon(BlockMoreFlowers.java:50) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.RenderBlocks.getBlockIconFromSideAndMetadata(RenderBlocks.java:8164) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.RenderBlocks.drawCrossedSquares(RenderBlocks.java:3604) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.RenderBlocks.renderCrossedSquares(RenderBlocks.java:3482) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.RenderBlocks.renderBlockByRenderType(RenderBlocks.java:449) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.WorldRenderer.updateRenderer(WorldRenderer.java:224) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.RenderGlobal.updateRenderers(RenderGlobal.java:1561) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1129) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1006) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:930) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.Minecraft.run(Minecraft.java:822) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.main.Main.main(Main.java:93) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at java.lang.reflect.Method.invoke(Unknown Source) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.launchwrapper.Launch.launch(Launch.java:57) 2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.launchwrapper.Launch.main(Launch.java:18) Quote Link to comment Share on other sites More sharing options...
Draco18s Posted July 2, 2013 Share Posted July 2, 2013 You have an issue here: this.icon = par1IconRegister.registerIcon("Nature:flower_" + i); Isn't "this.icon" an array? Quote 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 More sharing options...
GhostSnyperRecon Posted July 2, 2013 Author Share Posted July 2, 2013 ah thank you, that seemed to have fixed it [edit] nevermind, im still having some issues Quote Link to comment Share on other sites More sharing options...
Draco18s Posted July 2, 2013 Share Posted July 2, 2013 [edit] nevermind, im still having some issues Same error, different error? Quote 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 More sharing options...
GhostSnyperRecon Posted July 2, 2013 Author Share Posted July 2, 2013 same error, i copied the texture code from the BlockTallGrass.class this time and still having issues Quote Link to comment Share on other sites More sharing options...
zombiepig333 Posted July 2, 2013 Share Posted July 2, 2013 Same here, been getting that error whenever I try and access one of the blocks my mod adds. Probably another screw-up with the new texture system. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.