So then all of the code i need to register a single item would be
bleachBottleClorox = new BleachBottleClorox();
GameRegistry.registerItem(bleachBottleClorox, "bleachBottleClorox");
ModelLoader.setCustomModelResourceLocation(bleachBottle, 0,new ModelResourceLocation("bleachcraft:bleachBottleClorox", "inventory"));
This looks right now.
But you really should create a register method that you can call fr each Item, like this:
public static void reigster(Item item, String name) //maybe store the name in your item class and use a getter method
{
GameRegistry.registerItem(item, name);
}
public static void registerItemRender(Item item, int meta)
ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName(), "inventory"));
call register for each item, then call registerItemRender for each item on the client side.
I made a new method to register an item to a location.
public static void reigsterItem(Item item, String name, String location) //maybe store the name in your item class and use a getter method
{
GameRegistry.registerItem(item, name);
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(location, "inventory"));
}
You never initialise the Recipes fields, so they're null when you try to add recipes that use them. You shouldn't have any Item fields in your Recipes class, use the fields from your Items class.
Recipes should be added in init rather than preInit.
Since your Items class has the same name as Minecraft's Items class, you can't import both of them in one file. This means that you'll need to refer to one by its fully qualified name (i.e. package name and class name) if you use both classes in the same file (which you probably will at some point). To make things easier, I'd recommend renaming your Items class to ModItems or BleachCraftItems.
As I've told you several times now, you cannot register models in common code. Model registration must happen in a client-only class.
The default model loaded for every Item is the one with its registry name, so I suggest using this as the default model location for your Items.
You should also be using GameRegistry.register instead of the deprecated GameRegistry.registerItem.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
As I've told you several times now, you cannot register models in common code. Model registration must happen in a client-only class.
Sorry I just changed that so it will register in the clientProxy class. Everything is now working, no crashes, However my fluid (clorine) is appearing as the default texture and not the one specified in my ClorineBlock.json file. Here is my fml log.
Post your Clorine and ClorineBlock classes and the FML log.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Also right before I reran Minecraft I changed all of the clorine/Clorine words to chlorine/Chlorine finally! You should see the change in the fml log but not the attached files.
You never call your proxy methods from anywhere, so you never register models for your blocks/items.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
The BleachCraft.proxy field holds your proxy instance, call the appropriate methods on this from your lifecycle methods (e.g. call CommonProxy#preInit from BleachCraft#preInit).
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
That appears to be the same log as the last one with an extra bit on the end. It also appears to be the console output rather than the FML log file.
There's no crash in that log.
Please post the actual latest FML log and the latest version of your main class (BleachCraft).
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
You can't register a model for a block/item before you create/register it, so call your proxy methods at the end of the lifecycle methods.
java.lang.IllegalArgumentException: Attempted to register a Block with conflicting names. Old: bleachcraft:ChlorineBlock New: ChlorineBlock
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:438)
at net.bleachcraft.init.Fluids.registerFluids(Fluids.java:21)
at net.bleachcraft.BleachCraft.preInit(BleachCraft.java:38)
This exception is thrown when you call GameRegistry.registerBlock(Block, String) with a Block that's had its registry name set and a String that doesn't match that name exactly. It's technically incorrect in this case because the mod ID prefix is automatically added, but it's unlikely to be fixed because the method is deprecated and will be removed in a future version.
You should fix your code to properly use the new registry system:
Don't store the object's name in a field.
Call setRegistryName to set the object's registry name. This will automatically be prefixed with your mod ID.
Call GameRegistry.register(IForgeRegistry) to register the object.
If the object has an unlocalised name and it's the same as the registry name, set it to the full registry name (returned by getRegistryName).
This applies to any IForgeRegistryEntry implementation, including Item, Block and Biome.
You will need to register an ItemBlock for each of your Blocks yourself. Use the Block's registry name as the ItemBlock's registry name.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Don't store the name at all, just pass it directly to setRegistryName. If the class will be used for multiple instances, take the name as a constructor argument.
Store the instances themselves in static fields like you are now.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
In which file should i call this to make things easier?
In the constructor of the IForgeRegistryEntry implementation (e.g. Block/Item).
and what would I use as the resource for setRegistryName(ResourceLocation name);
Use the setRegistryName(String) overload from IForgeRegistryEntry.Impl (which is extended by all vanilla IForgeRegistryEntry implementations). Pass the registry name of the object without your mod ID.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Where do you recommend that I implement it in my code?
Block and Item already implement it. You just need to call the method in your constructor.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
How would I use GameRegistry.register(); I was trying (i am probably wrong which is why I plan to learn a lot more about Java this weekend) the line GameRegistry.register((K) ChlorineBlock); But I was getting errors. Am I even using the code right?
This looks right now.
But you really should create a register method that you can call fr each Item, like this:
call register for each item, then call registerItemRender for each item on the client side.
I like your thinking
I made a new method to register an item to a location.
HOWEVER
I am getting another crash with my recipes
Here is my fml log
I am assuming this is another error with something that should be in normal fml init and not in preFMLinit Is there a way to fix this
You never initialise the Recipes fields, so they're null when you try to add recipes that use them. You shouldn't have any Item fields in your Recipes class, use the fields from your Items class.
Recipes should be added in init rather than preInit.
Since your Items class has the same name as Minecraft's Items class, you can't import both of them in one file. This means that you'll need to refer to one by its fully qualified name (i.e. package name and class name) if you use both classes in the same file (which you probably will at some point). To make things easier, I'd recommend renaming your Items class to ModItems or BleachCraftItems.
As I've told you several times now, you cannot register models in common code. Model registration must happen in a client-only class.
The default model loaded for every Item is the one with its registry name, so I suggest using this as the default model location for your Items.
You should also be using GameRegistry.register instead of the deprecated GameRegistry.registerItem.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Sorry I just changed that so it will register in the clientProxy class. Everything is now working, no crashes, However my fluid (clorine) is appearing as the default texture and not the one specified in my ClorineBlock.json file. Here is my fml log.
Other files:
Main file
clientProxy
fluids
ClorineBlock.json file:
Post your Clorine and ClorineBlock classes and the FML log.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Clorine.java
ClorineBlock.java
FML log
Also right before I reran Minecraft I changed all of the clorine/Clorine words to chlorine/Chlorine finally! You should see the change in the fml log but not the attached files.
You never call your proxy methods from anywhere, so you never register models for your blocks/items.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
What would i use to call it?
Would I use
proxy.preInit(event);
The BleachCraft.proxy field holds your proxy instance, call the appropriate methods on this from your lifecycle methods (e.g. call CommonProxy#preInit from BleachCraft#preInit).
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
When i put proxy.preInit(event); into my code (preInit of main file) the game crashes with this fml log.
That appears to be the same log as the last one with an extra bit on the end. It also appears to be the console output rather than the FML log file.
There's no crash in that log.
Please post the actual latest FML log and the latest version of your main class (BleachCraft).
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Here is the actual FML log
Here is the main class(BleachCraft)
You can't register a model for a block/item before you create/register it, so call your proxy methods at the end of the lifecycle methods.
This exception is thrown when you call GameRegistry.registerBlock(Block, String) with a Block that's had its registry name set and a String that doesn't match that name exactly. It's technically incorrect in this case because the mod ID prefix is automatically added, but it's unlikely to be fixed because the method is deprecated and will be removed in a future version.
You should fix your code to properly use the new registry system:
This applies to any IForgeRegistryEntry implementation, including Item, Block and Biome.
You will need to register an ItemBlock for each of your Blocks yourself. Use the Block's registry name as the ItemBlock's registry name.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Then how should i store the object.
Don't store the name at all, just pass it directly to setRegistryName. If the class will be used for multiple instances, take the name as a constructor argument.
Store the instances themselves in static fields like you are now.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
In which file should i call this to make things easier?
and what would I use as the resource for setRegistryName(ResourceLocation name);
In the constructor of the IForgeRegistryEntry implementation (e.g. Block/Item).
Use the setRegistryName(String) overload from IForgeRegistryEntry.Impl (which is extended by all vanilla IForgeRegistryEntry implementations). Pass the registry name of the object without your mod ID.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Where do you recommend that I implement it in my code?
Block and Item already implement it. You just need to call the method in your constructor.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
How would I use GameRegistry.register(); I was trying (i am probably wrong which is why I plan to learn a lot more about Java this weekend) the line GameRegistry.register((K) ChlorineBlock); But I was getting errors. Am I even using the code right?