Jump to content

Recommended Posts

Posted

I am at the very starting point of moding, I managed to "make" a block , but I can't manage to give it a texture

 

I loooked on pahimar(youtube) tutorials for the begining , so I have the basic stucture he showed , but since he did not post any video , I tried to do somethings my self.

 

So here is my code :

 

First: structure :

 

Ininity bows

  |

  |---common

  |        |

  |        |-------traxys.infbow

  |        |                    |

  |        |                    |---------IninityBow.java

  |        |                     

  |        |-------traxys.infbow.lib       

  |        |                    |

  |        |                    |---------GenBlock.java

  |        |                    |

  |        |                    |---------Reference.java

  |        |

  |        |-------traxys.infbow.proxy(there are two java files , (ckient & common proxy) but there are nearly blank)

  |        |

  |        |-------mcmod.info

  |        |

  |        |-------pack.mcmeta

  |

  |---Ressources

              |

              |------assets.infbow.lang(empty)

              |

              |------assets.infbow.textures.blocks

              |                    |

              |                    |---------hardWall.png(a 16*16 file)

              |

              |------assets.infbow.textures.item(also empty)

 

Here are my codes :

InfinityBow.java

 

 

package traxys.infbow;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraftforge.common.MinecraftForge;

import traxys.infbow.lib.GenBlock;

import traxys.infbow.lib.Reference;

import traxys.infbow.proxy.CommonProxy;

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.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

@Mod(modid= Reference.MOD_ID, name= Reference.MOD_NAME, version = Reference.VERSION)

public class InfinityBow {

 

public static Block hardWall;

 

@Instance(Reference.MOD_ID)

public static InfinityBow instance;

 

@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)

public static CommonProxy proxy;

 

@EventHandler

public void preInit(FMLPreInitializationEvent event){

hardWall = new GenBlock(1048, Material.rock)

.setHardness(55.0F).setResistance(2050.0F).setStepSound(Block.soundStoneFootstep)

.setUnlocalizedName("hardWall").setCreativeTab(CreativeTabs.tabBlock)

.setTextureName("generic:hardWall");

}

 

@EventHandler

public void init(FMLInitializationEvent event){

LanguageRegistry.addName(hardWall, "Hard Wall");

MinecraftForge.setBlockHarvestLevel(hardWall, "pickaxe", 3);

GameRegistry.registerBlock(hardWall, "Hard Wall");

}

@EventHandler

public void postInit(FMLPostInitializationEvent event){

 

}

 

}

 

 

GenBlock.java

 

 

package traxys.infbow.lib;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

 

public class GenBlock extends Block {

 

public GenBlock(int par1, Material par2Material) {

super(par1, par2Material);

}

}

 

 

Reference.java

 

 

package traxys.infbow.lib;

 

public class Reference {

 

public static final String MOD_ID ="InfBow";

public static final String MOD_NAME ="Infinity Bows";

public static final String VERSION ="0.0.1";

 

public static final String SERVER_PROXY_CLASS ="traxys.infbow.proxy.CommonProxy";

public static final String CLIENT_PROXY_CLASS ="traxys.infbow.proxy.ClientProxy";

}

 

 

pack.mcmeta

 

 

{

  "pack":{

      "pack_format":1,

      "description":"Infinity Bows textures"

  }

}

 

 

Posted

in your block.class do this

 

 

 @SideOnly(Side.CLIENT)
    @Override
    public void registerIcons(IconRegister register) {
    	this.blockIcon = register.registerIcon(Reference.MOD_ID + ":" + (this.getUnlocalizedName().substring(5)));

 

replace "Reference.MOD_ID with with the name of the class that contains your modid (most likely your base class) and your modid

Posted

(You don't need to override registerIcons, but it will work using the same details as my post)

 

this.setTextureName("MODID" + ":" + "BLOCKNAME")

 

Where MODID is whatever you want to name your assets folder and BLOCKNAME is whatever you want to name the texture file.  These must be lower case (if they're not, they will be converted).

 

Now go to /src/minecraft/assets and create a new folder there called MODID, inside that a folder called textures inside that a folder called blocks inside that add your texture file named BLOCKNAME.png

 

Voila.

 

http://www.minecraftforge.net/wiki/Icons_and_Textures

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.

Posted

You haven't done any of the things suggested to you, your block class is still basically empty.  You haven't set its name, texture, hardness, resistance, or anything.

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.

Posted

I did it in the Main Mod Class(InfinityBow.java) , It works if I do it in another class ?

 

And Can I put the texture somewhere else than the minecraft texture directory (in a directory for my mod in a folder in an otherplace than minecraft texture (or is thant when the mod is release?)?)

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.