Jump to content

Splashsky

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by Splashsky

  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...
  16. Which log file? I checked all through eclipse/logs/fml-client-latest.log and it doesn't show anything that I'd take as an error or a failure. Here's a screenshot of the problem Here is a pastebin of fml-client-latest.log
  17. So, I'm like, minding my own business right? I go ahead and add two food items to my mod, and I'm registering the renders like all the tutorials tell me to. Suddenly, this hideous error appears and a bunch of Minecraft's vanilla textures are replaced by blank white squares! Anyone have experience with this sort of thing? [06:49:11] [pool-2-thread-1/WARN]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@5b82e090[id=d978d670-4b07-3a90-bfb6-b4e7c70fe7fc,name=Player412,properties={},legacy=false] com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:65) ~[YggdrasilAuthenticationService.class:?] at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:158) [YggdrasilMinecraftSessionService.class:?] at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:53) [YggdrasilMinecraftSessionService$1.class:?] at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:50) [YggdrasilMinecraftSessionService$1.class:?] at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) [guava-17.0.jar:?] at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) [guava-17.0.jar:?] at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) [guava-17.0.jar:?] at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) [guava-17.0.jar:?] at com.google.common.cache.LocalCache.get(LocalCache.java:3934) [guava-17.0.jar:?] at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) [guava-17.0.jar:?] at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) [guava-17.0.jar:?] at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) [guava-17.0.jar:?] at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:148) [YggdrasilMinecraftSessionService.class:?] at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:138) [skinManager$3.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_60] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_60] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_60] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_60] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_60] EDIT After commenting out the following line of code (which was in a separate class file) I was able to get rid of the above error, the textures still do not show up, however. private static ItemStack cookedPork = new ItemStack(Items.cooked_porkchop);
  18. The point was to create a class that added localized names via a simple regex process so that I could add items and tabs and the like and not have to manually enter new localizations. It partially works, except my bugged version had been putting en_US.lang in the root directory and made multiple copies of the same line (an issue I am trying to debug ) Though, I tested a couple things out while writing this reply, and it seems that manually adding entries is my best bet until I learn some more about Java and Forge. Changed the path that was being passed to LangRegistry to match up with that format; can't find the file that is - to me - clearly there. Not a problem for the time being, but something I want to fix. RegistryFile.class (sorry for lack of brevity) public abstract class RegistryFile { protected String filePath; protected BufferedWriter writer; protected File file; protected StringBuilder builder = new StringBuilder(); public RegistryFile(String filePath) { this.filePath = filePath; this.file = new File(filePath); } public abstract void addNames(); public void localizeName(String prefixOfLine, String unlocalizedName) { String name = unlocalizedName.substring(5); char firstLetter = name.charAt(0); if(Character.isLowerCase(firstLetter)) { firstLetter = Character.toUpperCase(firstLetter); } String inGame = name.substring(1); String temp = inGame; for(int p = 1; p < temp.length(); p++) { char c = inGame.charAt(p); int code = c; if(inGame.charAt(p - 1) != ' ') { for(int n = 65; n < 90; n++) { if(code == n) { inGame = new StringBuffer(inGame).insert(p, "").toString(); } } } inGame = inGame.replaceAll(" Of ", " of ").replaceAll(" The ", " the "); String finalName = firstLetter + inGame; addToFile(prefixOfLine + "." + name + ".name=" + finalName, name); } } public static String getLocalizedMobName(String str) { int l = str.length(); if(str.length() > 1) { for(int i = 1; i < l; i++) { if((Character.isUpperCase(str.charAt(i))) && (str.charAt(i - 1) != ' ')) { str = new StringBuffer(str).insert(i, " ").toString(); } } } return str.replace("HRPG", ""); } public String readFile(String path) { StringBuilder source = new StringBuilder(); BufferedReader reader = null; File file = new File(path); try { reader = new BufferedReader(new FileReader(file)); String line; while((line = reader.readLine()) != null) { source.append(line); } reader.close(); } catch(Exception e) { e.printStackTrace(); } return source.toString(); } public void addName(String prefix, String keyName, String inGameName) { addToFile(prefix + "." + keyName + "=" + inGameName, keyName); } public void addToFile(String inGame, String oldName) { String temp = inGame; Log.dev("Registered new name, " + oldName + " became " + temp.substring(temp.indexOf('=') + 1)); this.builder.append(inGame + "\n"); } public void addToFile(String text) { this.builder.append(text + "\n"); } public void write() { try { if(!this.file.exists()) { this.file.createNewFile(); } this.writer = new BufferedWriter(new FileWriter(this.file)); this.writer.write(this.builder.toString()); this.writer.close(); } catch(IOException e) { e.printStackTrace(); } } } LangRegistry.class (extends RegistryFile) public class LangRegistry extends RegistryFile { private static ArrayList<HexTabs> tabs = new ArrayList(); private static ArrayList<Item> items = new ArrayList(); public static final RegistryFile instance = new LangRegistry(); public LangRegistry() { super("src/main/resources/assets/cshex/lang/en_US.lang"); } public static void registerNames() { instance.addNames(); } public void addNames() { for(Item item : items) { localizeName("item", item.getUnlocalizedName()); } instance.write(); } public static void addTab(HexTabs tab) { tabs.add(tab); } public static void addItem(Item item) { items.add(item); } }
  19. One more quick question; in the event that I'm creating a class to automagically add lines to my en_US.lang file, how would I navigate to said file? Currently, I've got a LangRegistry class that extends a custom RegistryFile class, with a constructor as such; RegistryFile Constructor (LangRegistry uses super()) public RegistryFile(String filePath) { this.filePath = filePath; this.file = new File(filePath); } I've got "resources/assets/cshex/lang/en_US.lang" passed to my LangRegistry class at the moment, but it doesn't seem to read it, let alone write to it. NOTE I'm only learning; I'm reverse engineering a well-established mod, so my questions are pretty noobish for the stuff I'm trying to do. However, I've had previous programming experience, only Java itself is new for me
  20. Awesome, thanks! Though, if it requires a folder labelled with your_mod_id, then how's it work that it allows item and block textures to be in folders in assets? Wouldn't it be logical to put such things into the same folder as the lang files?
  21. I've been trying to work with some pre-1.8 tutorials and examples, but I can't figure out how to get my single item's name localized. Does anyone have a guide or something on localization in 1.8? I've got a manually-made en_US.lang under src/main/resources/assets/lang in my Eclipse Package Explorer, but when I grab the item in-game it reads item.bacon.name
  22. I'm reverse-engineering a mod that was apparently designed for Minecraft 1.7.10, and in their custom food classes I'm seeing methods like "func_77637_a" and "func_111206_d", the former of which I guessed was the old-school setCreativeTab() method from the Minecraft Item class. Is there a dictionary that shows the function changes? I'm having difficulty translating the old code.
×
×
  • Create New...

Important Information

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