Jump to content

Splashsky

Members
  • Posts

    22
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • URL
    http://clubsurf.net
  • Location
    Missouri
  • AIM
    skylearj
  • Personal Text
    Le Boss!

Splashsky's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. What I've ended up doing was create the CommonProxy as an interface. public interface CommonProxy { void preInit(); void init(); void postInit(); void registerItemRender(Item item, int meta, String id); } I then proceed to put the client logic into the ClientProxy. public class ClientProxy implements CommonProxy { @Override public void preInit() { } @Override public void init() { } @Override public void postInit() { } @Override public void registerItemRender(Item item, int meta, String id) { ModelLoader.setCustomModelResourceLocation( item, meta, new ModelResourceLocation(Reference.PREFIX + id, "inventory") ); } } And then, finally, server stuff! public class ServerProxy implements CommonProxy { @Override public void preInit() { } @Override public void init() { } @Override public void postInit() { } @Override public void registerItemRender(Item item, int meta, String id) { } } Granted, Draco and jabelar know a lot more than me, but this is my current setup. Not much different then just a ClientProxy and ServerProxy. Though, I probably should be implementing the FMLInitializationEvent thingies....
  2. So I've continued my goofing around with tutorials to try and get the hang of this, and I've come to the next roadblock. I don't know how to assign a model/image to my item! I've created the item class, added a function to it which will allow me to tell the ClientProxy to register the item model with setCustomModelResourceLocation, but it simply shows up as the black and pink boxes. Any help? ModItem.java public class ModItem extends Item { protected String name; public ModItem(String name) { this.name = name; setName(this, name); } public static void setName(final Item item, final String name) { item.setRegistryName(Reference.MODID, name); item.setUnlocalizedName(item.getRegistryName().toString()); } public void registerModel() { Venture.proxy.registerItemRender(this, 0, this.name); } @Override public ModItem setCreativeTab(CreativeTabs tab) { super.setCreativeTab(tab); return this; } } In ClientProxy.java @Override public void registerItemRender(Item item, int meta, String id) { ModelLoader.setCustomModelResourceLocation( item, meta, new ModelResourceLocation(Reference.PREFIX + id, "inventory") ); } ModItems.java @GameRegistry.ObjectHolder(Reference.MODID) public class ModItems { public static ModIngot ObsidianIngot = new ModIngot("obsidian_ingot"); // ... more items go here public static void registerModels() { ObsidianIngot.registerModel(); } @Mod.EventBusSubscriber(modid = Reference.MODID) public static class RegistrationHandler { public static final Set<Item> ITEMS = new HashSet<>(); @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { final Item[] items = { ObsidianIngot }; final IForgeRegistry<Item> registry = event.getRegistry(); for (final Item item : items) { registry.register(item); ITEMS.add(item); } ModItems.registerModels(); } } } obsidian_ingot in resources/assets/csvm/models/item { "parent": "item/generated", "textures": { "layer0": "csvm:items/obsidian_ingot" } } And yes, I have an obsidian_ingot.png in my assets/csvm/textures/items folder. And honestly, I don't know what the inventory variant is actually for.
  3. So basically, merely that class' existence will register the items? EDIT: Answered my own question. It sure does! That's a nifty lil thing right there.
  4. I had actually seen some of that from Choonster's test mod repo. It had some init things in there where he used @ObjectHolder to manage items... @GameRegistry.ObjectHolder(Reference.MODID) public class ModItems { public static ModIngot ObsidianIngot = new ModIngot("obsidian_ingot"); // ... more items go here @Mod.EventBusSubscriber(modid = Reference.MODID) public static class RegistrationHandler { public static final Set<Item> ITEMS = new HashSet<>(); @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { final Item[] items = { ObsidianIngot }; final IForgeRegistry<Item> registry = event.getRegistry(); for (final Item item : items) { registry.register(item); ITEMS.add(item); } } } } but the one thing I couldn't ever figure out is how to make it work, or if things like this worked on their own without having to instantiate the class in the main mod file or something else along those lines.
  5. I see! In this, then, I have another question. Given Draco's EasyRegistry class, it looks like he annotates it with SidedProxy... would this work as I expect it to? @Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION) public class Venture { @Mod.Instance public static Venture instance; @SidedProxy(clientSide = Reference.CLIENTPROXY, serverSide = Reference.SERVERPROXY) public static CommonProxy proxy; public static ServerRegistry registry; public static Logger logger; @Mod.EventHandler public static void preInit(FMLPreInitializationEvent event) { logger = event.getModLog(); MinecraftForge.EVENT_BUS.register(registry); proxy.preInit(); } @Mod.EventHandler public static void init(FMLInitializationEvent event) { proxy.init(); } @Mod.EventHandler public static void postInit(FMLPostInitializationEvent event) { proxy.postInit(); } } public class ServerRegistry { private List<Block> blocksToRegister = new ArrayList<Block>(); private List<Item> itemsToRegister = new ArrayList<Item>(); private List<IForgeRegistryEntry> otherItems = new ArrayList<IForgeRegistryEntry>(); public static void registerItem(Item item) { Venture.registry._registerItem(item); } public void _registerItem(Item item) { itemsToRegister.add(item); } @SubscribeEvent public void registerItems(RegistryEvent.Register<Item> event) { event.getRegistry().registerAll(itemsToRegister.toArray(new Item[itemsToRegister.size()])); } } public class ModItem extends Item { protected String name; public ModItem(String name) { this.name = name; setUnlocalizedName(name); setRegistryName(name); Venture.registry.registerItem(this); } @Override public ModItem setCreativeTab(CreativeTabs tab) { super.setCreativeTab(tab); return this; } }
  6. Okay, so from what I've extrapolated, I came up with a plan in my head. I can use my common.items package, create a ModItem class to act as a base class and set the Unlocalized and Registry names. When that item is created, I can, from the ModItem class, call ServerRegistry.registerItem(), add it to that list, and simply have the ServerRegistry use registerAll on that list. When I get it all hooked up, I use kind of a ItemHub with a method for instantiating all these items, which ultimately adds them to the list in the ServerRegistry. I then just add the ServerRegistry to the EVENT_BUS and call it a day. Is that more or less correct?
  7. Awesome! Thank you. More reading is always helpful. I did end up finding some succinct tutorials at Shadowfacts, so all-in-all I'm working towards piecing it all together. ^^
  8. Couldn't you just make _registerItem static instead?
  9. Additionally, is there any particular reason you make two methods for most actions? Such as registerItem and _registerItem, that is.
  10. So, effectively - and pardon for being such a newb - I could just write a ServerRegistry class with the same base functionality as your EasyRegistry and register that to the EVENT_BUS separate from the ServerProxy I have?
  11. So, gauging from what I read, the EasyRegistry classes could just as easily be the ClientProxy and ServerProxy I have. Just set it up in the same way... okay. Well, thanks, Draco!
  12. So... @Mod.EventHandler ... and I just assign that class to a variable in the main mod file? Or do I use that above the registration function after using @SubscribeEvent / @Mod.EventBusSubscriber above the Registry class declaration? Java's metadata is like alienese to me.
  13. Would it matter too terribly much where I were to put the Registry event? Choonster's puts the class into the ModItems class, and another tutorial puts the class directly into the main mod file. Is there a way I can make a separate Registry class and call the registration somewhere in the main mod class?
  14. I'm brand new to the modding scene. I know PHP, I've got some C++ experience, and I'm aware of Java. I can figure things out, more or less... but really only when I have examples I can first learn from. What I'm getting at is are there any clean, fully working example mods using all the best practices for 1.12.x? Like, registering and rendering items, how I should set up the proxies, etc? I did look at Choonster's test mod, and it had a pretty neat idea with how he registers items... however, I need a guide or an example mod that steps me through the basics of setting up a registry for items and blocks, and how I should set up my proxies to work with that. This is basically just what I pulled from Choonster... public static ModIngot ObsidianIngot = new ModIngot("obsidian_ingot"); public static void init() { } @Mod.EventBusSubscriber(modid = Reference.MODID) public static class RegistrationHandler { public static final Set<Item> ITEMS = new HashSet<>(); @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { final Item[] items = { ObsidianIngot }; final IForgeRegistry<Item> registry = event.getRegistry(); for (final Item item : items) { registry.register(item); ITEMS.add(item); } init(); } } But I don't know where to go from here.
  15. I'm completely new to modding; I installed IDEA because I know it's a stronger IDE than Eclipse, and so I followed this tutorial on the forum to get it working, but I can't see where to edit the configuration he found, nor does genIntellijRuns do anything rather than set the Gradle task to setupDecompWorkspace. Doesn't ask me to refresh the project or anything. edit: Switched the project to run the Minecraft Client instead. Worked as expected. My configuration screen for the Gradle project looks like this...
×
×
  • Create New...

Important Information

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