Jump to content

Alex S.

Members
  • Posts

    12
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Alex S.'s Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Ok, thank you! I will read up more on this. This has solved my issue.
  2. Ok, I've changed the registerItems method to @SubscribeEvent public void registerItems(RegistryEvent.Register<Item> event) { event.getRegistry().register(new ItemBlock(ModBlocks.RUBY_BLOCK).setRegistryName(ModBlocks.RUBY_BLOCK.getRegistryName())); } But I still can't see it in my inventory. Am I missing anything else?
  3. I decided to venture away from the tutorial and attempt to make my own block using what I know. However, the block won't show up in game (not even with the default texture). I think it's an issue with registering, but I've compared my code with examples posted online and it seems right (per advice from one of my earlier posts I am registering items individually). The registry class: https://pastebin.com/kaMJ8PSz The Block class: https://pastebin.com/Mx7Z55kd The Block base class: https://pastebin.com/S527Ld20
  4. Yeah, but it looks like IForgeRegistry is specifically looking for something that extends IForgeRegistry. Why am I allowed to call its methods using Item?
  5. I'm following along with a tutorial and came across some code like this (item is of class Item): ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName(), id)); Wondering where getRegistryName() came from, I found it in IForgeRegistryEntry (in the class Impl). However, I don't know (even after reading up on generics) what this means: public static class Impl<T extends IForgeRegistryEntry<T>> implements IForgeRegistryEntry<T> I did see that Item itself extends IForgeRegistryEntry.Impl<T>. Does the above class state that anything calling its methods must extend IForgeRegistryEntry?
  6. I feel a bit out of my depth with most of this stuff. Aside from brushing up on Java, is there any place where a newcomer is recommended to start?
  7. I'm following along with a video tutorial on making custom items (it's still a pain for me) and they invoked ModelLoader like this: public class ClientProxy extends CommonProxy { public void registerItemRenderer(Item item, int meta, String id) { ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName(), id)); } } Any reason they're putting it in the proxy classes as opposed to, say, the preInit() method?
  8. I was wondering if there was anything else that needs to be done while making my custom item, as not even a pink-and-black textured item is showing up ingame. So far I have: -Set the localized and registry name for the item. -Created an instance of the item and registered it using the .registerAll(will change in the future to only registering 1 at a time). The instance is created during the preInit() method. ItemBasic.java ModItems.java Main.java Here are the classes. I can post the raw code if that is preferable. EDIT: Here's the raw code. I don't know of any text editors for code, so I'll try making this as palatable as possible: ModItems.java: package com.TorchRunner1.firstutorial.init; import com.TorchRunner1.firstutorial.item.ItemBasic; import net.minecraft.item.Item; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; public class ModItems { static Item tutorialItem; public static void init() { tutorialItem = new ItemBasic("tutorial_item"); } @SubscribeEvent public static void registerItems(RegistryEvent.Register<Item> event)//accesses the Item instance where all items are stored. { event.getRegistry().registerAll(tutorialItem); } } ItemBasic.java: package com.TorchRunner1.firstutorial.init; import com.TorchRunner1.firstutorial.item.ItemBasic; import net.minecraft.item.Item; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; public class ModItems { static Item tutorialItem; public static void init() { tutorialItem = new ItemBasic("tutorial_item"); } @SubscribeEvent public static void registerItems(RegistryEvent.Register<Item> event)//accesses the Item instance where all items are stored. { event.getRegistry().registerAll(tutorialItem); } } Main.java: package com.TorchRunner1.firstutorial; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import com.TorchRunner1.firstutorial.init.ModItems; import com.TorchRunner1.firstutorial.util.Reference; @Mod(modid=Reference.MODID, name=Reference.NAME, version=Reference.VERSION) public class Main { @Instance public static Main instance; @EventHandler public void preInit (FMLPreInitializationEvent e) { ModItems.init(); } @EventHandler public void init(FMLInitializationEvent e) { } @EventHandler public void postInit(FMLPostInitializationEvent e) { } }
  9. Ah, so it's to specify that only items that extend IForgeRegistryEntry can be used in the class. First time I've been exposed to these.
  10. First, let me say I appreciate your help on this topic. Your tutorials are very useful. OK, so I should use .register instead of registerAll. But what exactly is RegistryEvent.Register<Item> event? The class RegistryEvent has an inner class Register, but I don't see an array in that class anywhere.
  11. Oh this is too good! Jabelar, I'm using your tutorials as a supplement to the other tutorial I'm following. From what I understand you're saying, "RegistryEvent.Register<Item> event" is giving a name to the Item instance that's registered, and from there "getRegistry.registerAll(tutorialItem)" is adding/registering tutorialItem with the instance?
  12. So I'm new at modding using Forge, so I'm following a tutorial on how to make a custom item. I typed some code like this (where tutorialItem is my custom item): @SubscribeEvent public static void registerItems(RegistryEvent.Register<Item> event) event.getRegistry().registerAll(tutorialItem) Can somebody tell me what this explicitly does? From my guess, it registers an array of Item objects, then uses the registry key generated to assign a registry key to tutorialItem. But how? I looked at the code further up the tree (RegistryEvent and Register) and they look like Latin to me.
×
×
  • Create New...

Important Information

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