Jump to content

MultiTexture Block


BloodMists

Recommended Posts

I'm very new to minecraft modding but I have a little bit of Java coding background. I have been trying for the last 6 hour to texture a block in a similar manor to a crafting table but it refuses to work. There is no error other then the one informing of a missing texture. I have gone over my file structure many times and am sure it is correct. I have also gone over the code for telling where and what the file is many time. I have no idea what I am missing nor can I seem to figure it out. Please help. -Blood

 

Code -imports & class(com.Bloods.BloodTG.block;)

 

 

public class BlockInfusion extends BlockBTG

{

@SideOnly(Side.CLIENT)

    private static IIcon infusionTop, infusionFront, infusionSide;

 

public BlockInfusion()

{

super(Material.wood);

this.setBlockName("infusion_table");

this.setBlockTextureName("infusion_table");

this.setHardness(2.5F);

this.setResistance(12.5F);

this.setHarvestLevel("axe", 0);

}

public boolean renderAsNormalBlock()

{

return false;

}

 

@Override @SideOnly(Side.CLIENT)

public void registerBlockIcons(IIconRegister reg) {

infusionTop = reg.registerIcon("infusion_table_top");

infusionFront = reg.registerIcon("infusion_table_front");

infusionSide = reg.registerIcon("infusion_table_side");

}

 

 

    @Override @SideOnly(Side.CLIENT)

    public IIcon getIcon(int side, int meta)

    {

    if (side == 0)

    {

    if (side == 1)

    {

    if (side == 2)

    {

    return infusionFront;

    }

    else

    return infusionTop;

    }

    else

    return ModBlocksLoader.stoneLife.getBlockTextureFromSide(side);

    }

    else

    return infusionSide;

    }

 

 

Link to comment
Share on other sites

First you check if the side is 1. Then, if that is true, you check if the side is 2. Which of course can never be, because, well, you just checked that the side is 1.

 

Well then what might you suggest I do as this is the what I got from sources like here after trying to use the vanilla crafting table method and it not working in the exact same way. I only ever get the bottom of the block textured, seemingly regardless of the method used.

Link to comment
Share on other sites

You mean like...

if(side == 0) { return bottom; }
else if(side == 1) { return top; }
else if...

?

 

Basic java.

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 mean like...

if(side == 0) { return bottom; }
else if(side == 1) { return top; }
else if...

?

 

Basic java.

 

Pardon the animosity but;

First off, did you even look at the code?

It's already more or less that way and is not working. I even changed it just now to test using else ifs rather then nested and it still does not work.

 

Second, am i missing something obvious that is simple? The texture files are in the right file path and named identically so unless there is some thing new that I don't know about it should work.

 

Third, I used a post from you before to try and make this work and it still isn't. So I'm not sure how valid your help is right now.

Link to comment
Share on other sites

"More or less that way" - That's not how programming works.

 

I know that's not how near all of it works but if the yield would be the same then it is. Besides did you happen to look at what was suggested? It's near identical, just if else if instead of nested if. I could really use some help here. If you have a suggestion as to how to fix this it would be nice to hear.

Link to comment
Share on other sites

Might want to recover some basic logic and programming... Your code (in an analogy) is checking if a fruit is an apple, then if it is an apple checking if the apple is also an orange. Finally if the fruit is both an apple and an orange, doing something. I think you're thinking about a switch statement, just google that. Either that or else-ifs will do what you need.

Link to comment
Share on other sites

Updated to using if else if and it is still not working as I said before, "I even changed it just now to test using else ifs rather then nested and it still does not work." I am not very advanced in Java but I am not an idiot with it either. I know that nested if statements work differently from if else if. However, if the result of both methods are the same the regardless of how it works it's more or less the same. (In the fact that it's useless.) So, since neither of these are working, what might you suggest is wrong or how might you suggest I get it to work?(We are back to the actual question again.)

 

 

 

    @Override @SideOnly(Side.CLIENT)

    public void registerBlockIcons(IIconRegister reg)

      {

infusionTop = reg.registerIcon("infusion_table_top");

infusionFront = reg.registerIcon("infusion_table_front");

infusionSide = reg.registerIcon("infusion_table_side");

}

 

 

    @Override @SideOnly(Side.CLIENT)

    public IIcon getIcon(int side, int meta)

    {

    if (side == 0 )

    { return ModBlocksLoader.stoneLife.getBlockTextureFromSide(side);}

    else if (side == 1 )

    { return infusionTop;}

    else if (side == 2 )

    { return infusionFront;}

    return infusionSide;

    }

 

 

Link to comment
Share on other sites

Give us a crash report/ log from your IDE. I think the side code looks good, so most probable solution is that the textures aren't in the right place or you load them incorrectly. (Pretty sure that isn't exactly how you register icons, I'll check my old code...)

Link to comment
Share on other sites

Give us a crash report/ log from your IDE.

 

The console log after running client. Sections pertaining to missing textures of block in question are all that are included

 

 

java.io.FileNotFoundException: minecraft:textures/blocks/.png

at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:65) ~[FallbackResourceManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:67) ~[simpleReloadableResourceManager.class:?]

at net.minecraft.client.renderer.texture.TextureMap.loadTextureAtlas(TextureMap.java:126) [TextureMap.class:?]

at net.minecraft.client.renderer.texture.TextureMap.loadTexture(TextureMap.java:91) [TextureMap.class:?]

at net.minecraft.client.renderer.texture.TextureManager.loadTexture(TextureManager.java:89) [TextureManager.class:?]

at net.minecraft.client.renderer.texture.TextureManager.onResourceManagerReload(TextureManager.java:170) [TextureManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.notifyReloadListeners(SimpleReloadableResourceManager.java:134) [simpleReloadableResourceManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.reloadResources(SimpleReloadableResourceManager.java:118) [simpleReloadableResourceManager.class:?]

at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:643) [Minecraft.class:?]

at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:303) [FMLClientHandler.class:?]

at net.minecraft.client.Minecraft.startGame(Minecraft.java:586) [Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:931) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_11]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_11]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?]

at GradleStart.main(GradleStart.java:45) [start/:?]

[22:44:52] [Client thread/ERROR]: Using missing texture, unable to load minecraft:textures/blocks/infusion_table_front.png

java.io.FileNotFoundException: minecraft:textures/blocks/infusion_table_front.png

at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:65) ~[FallbackResourceManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:67) ~[simpleReloadableResourceManager.class:?]

at net.minecraft.client.renderer.texture.TextureMap.loadTextureAtlas(TextureMap.java:126) [TextureMap.class:?]

at net.minecraft.client.renderer.texture.TextureMap.loadTexture(TextureMap.java:91) [TextureMap.class:?]

at net.minecraft.client.renderer.texture.TextureManager.loadTexture(TextureManager.java:89) [TextureManager.class:?]

at net.minecraft.client.renderer.texture.TextureManager.onResourceManagerReload(TextureManager.java:170) [TextureManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.notifyReloadListeners(SimpleReloadableResourceManager.java:134) [simpleReloadableResourceManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.reloadResources(SimpleReloadableResourceManager.java:118) [simpleReloadableResourceManager.class:?]

at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:643) [Minecraft.class:?]

at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:303) [FMLClientHandler.class:?]

at net.minecraft.client.Minecraft.startGame(Minecraft.java:586) [Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:931) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_11]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_11]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?]

at GradleStart.main(GradleStart.java:45) [start/:?]

[22:44:52] [Client thread/ERROR]: Using missing texture, unable to load minecraft:textures/blocks/infusion_table_side.png

java.io.FileNotFoundException: minecraft:textures/blocks/infusion_table_side.png

at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:65) ~[FallbackResourceManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:67) ~[simpleReloadableResourceManager.class:?]

at net.minecraft.client.renderer.texture.TextureMap.loadTextureAtlas(TextureMap.java:126) [TextureMap.class:?]

at net.minecraft.client.renderer.texture.TextureMap.loadTexture(TextureMap.java:91) [TextureMap.class:?]

at net.minecraft.client.renderer.texture.TextureManager.loadTexture(TextureManager.java:89) [TextureManager.class:?]

at net.minecraft.client.renderer.texture.TextureManager.onResourceManagerReload(TextureManager.java:170) [TextureManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.notifyReloadListeners(SimpleReloadableResourceManager.java:134) [simpleReloadableResourceManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.reloadResources(SimpleReloadableResourceManager.java:118) [simpleReloadableResourceManager.class:?]

at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:643) [Minecraft.class:?]

at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:303) [FMLClientHandler.class:?]

at net.minecraft.client.Minecraft.startGame(Minecraft.java:586) [Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:931) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_11]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_11]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?]

at GradleStart.main(GradleStart.java:45) [start/:?]

[22:44:52] [Client thread/ERROR]: Using missing texture, unable to load minecraft:textures/blocks/infusion_table_top.png

java.io.FileNotFoundException: minecraft:textures/blocks/infusion_table_top.png

at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:65) ~[FallbackResourceManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:67) ~[simpleReloadableResourceManager.class:?]

at net.minecraft.client.renderer.texture.TextureMap.loadTextureAtlas(TextureMap.java:126) [TextureMap.class:?]

at net.minecraft.client.renderer.texture.TextureMap.loadTexture(TextureMap.java:91) [TextureMap.class:?]

at net.minecraft.client.renderer.texture.TextureManager.loadTexture(TextureManager.java:89) [TextureManager.class:?]

at net.minecraft.client.renderer.texture.TextureManager.onResourceManagerReload(TextureManager.java:170) [TextureManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.notifyReloadListeners(SimpleReloadableResourceManager.java:134) [simpleReloadableResourceManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.reloadResources(SimpleReloadableResourceManager.java:118) [simpleReloadableResourceManager.class:?]

at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:643) [Minecraft.class:?]

at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:303) [FMLClientHandler.class:?]

at net.minecraft.client.Minecraft.startGame(Minecraft.java:586) [Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:931) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_11]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_11]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?]

at GradleStart.main(GradleStart.java:45) [start/:?]

 

 

 

That should be all that's needed.

Link to comment
Share on other sites

I have a generic class that should already be handling that for me.

 

BlockBTG

 

 

public class BlockBTG extends Block

{

public BlockBTG(Material material)

{

super(material);

this.setCreativeTab(CreativetabBBTG.BTG_Blocks);

}

 

public BlockBTG()

{

super(Material.rock);

this.setCreativeTab(CreativetabBBTG.BTG_Blocks);

}

 

@Override

public String getUnlocalizedName()

{

return String.format("tile.%s%s", Reference.Mod_ID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName()));

}

 

@Override

@SideOnly(Side.CLIENT)

public void registerBlockIcons(IIconRegister iconRegister)

{

blockIcon = iconRegister.registerIcon(String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName())));

}

 

protected String getUnwrappedUnlocalizedName(String unlocalizedName)

{

return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);

}

}

 

 

 

Is it missing something?

I mean I don't mind doing it in the block's class as it should be the only multi-textured block but if it can work with the generic class so I don't need to worry about it later on if I decide to add more like this I think it would be better.

Link to comment
Share on other sites

Also: Please don't use that "unwrappedUnlocalizedName" BS by Pahimar.

All you need is to call

setBlockName

and

setBlockTextureName

in your constructor. No need to override any methods.

 

I don't have any other examples to go off right now as far as this goes. Could you maybe explain a bit? Also now that the textures work, if I always want the "front" of the block to face east I just leave it like it is and nothing crazy like pistons right?

 

 

public class BlockInfusion extends BlockBTG

{

@SideOnly(Side.CLIENT)

    private static IIcon infusionTop, infusionFront, infusionSide;

 

public BlockInfusion()

{

super(Material.wood);

this.setBlockName("infusion_table");

//this.setBlockTextureName(Reference.Mod_ID.toLowerCase() + ":" + "infusion_table");

this.setHardness(2.5F);

this.setResistance(12.5F);

this.setHarvestLevel("axe", 0);

}

public boolean renderAsNormalBlock()

{

return false;

}

 

@Override @SideOnly(Side.CLIENT)

public void registerBlockIcons(IIconRegister reg)

{

infusionTop = reg.registerIcon(Reference.Mod_ID.toLowerCase() + ":" + "infusion_table_top");

infusionFront = reg.registerIcon(Reference.Mod_ID.toLowerCase() + ":" + "infusion_table_front");

infusionSide = reg.registerIcon(Reference.Mod_ID.toLowerCase() + ":" + "infusion_table_side");

}

 

 

    @Override @SideOnly(Side.CLIENT)

    public IIcon getIcon(int side, int meta)

    {

    if (side == 0 )

    { return ModBlocksLoader.stoneLife.getBlockTextureFromSide(side);}

    else if (side == 1 )

    { return infusionTop;}

    else if (side == 2 )

    { return infusionFront;}

    return infusionSide;

    }

 

 

Link to comment
Share on other sites

Well, that's that problem sorted. Thank you all for your help. I'm sorry if I appeared to be angry with anyone. I have excuses for it but they are excuses.

 

I just have two question. What is wrong/bad about using the method Pahimar made? Without Pahimar's method, is there a better way to declare the mod id in the generic class? It seems to be quite useful for standard blocks.

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.