Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Choonster

Moderators
  • Joined

  • Last visited

Everything posted by Choonster

  1. I'm not going to write your code for you. I've told you exactly which methods to override and call and in what order, you just need to translate that into code. If there's a specific part of my post that you didn't understand, I can try to explain it further.
  2. You'll need to be more specific. Which part didn't you understand?
  3. That should work, yes. You can also use ConfigCategory#getValues to get an immutable copy of the category's property names and properties (and use Map#getValues to get a collection of the Map's values) or ConfigCategory#getOrderedValues to get an ordered immutable copy of the category's properties.
  4. Use the container item system for this, not ItemCraftedEvent. If the sandpaper is returned to the player without change, call Item#setContainerItem with this as the argument in the sandpaper Item's constructor to set it as its own container item. If the sandpaper is changed (e.g. damaged) by the crafting, override Item#getContainerItem(ItemStack) to copy its argument (ItemStack#copy), damage the copy (ItemStack#attemptDamageItem) and return the copy.
  5. You'll need to call Property#setConfigEntryClass on each of those Property objects, yes.
  6. Call Property#setConfigEntryClass with NumberSliderEntry.class as the argument.
  7. That looks correct, yes.
  8. Yes. Forge uses your category names in a regular expression (for String#replaceFirst), so they can't contain any characters that have a special meaning in regular expressions (e.g parentheses).
  9. The actual ore dictionary matching has moved to OreIngredient (forge:ore_dict in JSON), which you can use as an Ingredient in any Vanilla or Forge recipe class. You can create and register recipes in code if you want, but moving to the JSON system is recommended.
  10. Because there's no class with that name. Use World Capabilities or World Saved Data. If you want more help with this, create a new thread. The Item.ToolMaterial and ItemArmor.ArmorMaterial enums control the stats of tools and armour, respectively.
  11. To open a class by name, use Navigate > Class (Ctrl-N) in IDEA or Navigate > Go To > Type... in Eclipse. This will avoid manually searching or asking for the fully qualified name.
  12. There's no method in Item called useItemRightClick, so your method doesn't override anything and is never called. You shouldn't be storing an ItemStack in your Item class, the ItemStack will be provided to most Item methods you override. Always annotate override methods with @Override so you get a compilation error if they don't actually override a super methods. You should use your IDE to auto-generate override methods with the correct signature and annotation. In this case, you'll want to override Item#onItemRightClick and use ICommandManager#executeCommand to execute the command. Use MinecraftServer#getCommandManager to get the server's ICommandManager instance and use World#getMinecraftServer to get the MinecraftServer instance. You should only do all of this on the logical server (when World#isRemote is false).
  13. The full path of the category, not the full path of the field that was used to create it. The default top-level category is general and the frame category is in that, so use "general.frame".
  14. The FML log is the logs/fml-client-latest.log file in the Minecraft game directory.
  15. The Configuration object contains the properties and categories created by Forge from your @Config class. You need it to get the Property so you can set NumberSliderEntry as its config GUI entry type (i.e. use a slider for that property in the config GUI). You get the Property by calling these methods:
  16. That looks correct. There's no need to have the variable declaration and assignment on separate lines, though.
  17. It will return a value of type Configuration, but the compiler doesn't know that. You need to cast the return value to Configuration yourself.
  18. There is no net.minecraft.player package (or rather there's no classes in it to import), only net.minecraft.player.inventory.
  19. That will work because the method checks if name is either null or empty, though Forge never calls it with null as the name argument (like I said in my previous post, the default value is the empty string). Method#invoke returns whatever the method returned. In this case it's the Configuration object, so store it in a local variable.
  20. It's a local variable rather than a field, so it can't be private or static. It can be final to prevent its value from being changed, but this isn't required. If you were calling an instance method of ConfigManager (and ConfigManager actually had any instance methods), you'd pass an instance of ConfigManager as the obj argument. Since the method you're calling is static, just pass null. The two parameters of ConfigManager.getConfiguration are modid and name, which should match the values you specified in the @Config annotation. Use an empty string for name if you didn't specify it in the annotation, since that's the annotation property's default value.
  21. If you want to call a method multiple times, you should look up the Method object once and store it in a private static final field; yes. You then call Method#invoke on it when you want to call the method (which is usually at a different time to when the field is initialised, i.e. in a method rather than a field initialiser). I've just realised that ConfigManager.getConfiguration only needs to be called once, so there's no need to store the Method object in a field. I forgot about this in my earlier posts. When I say "call Class#method", I mean "call the method named method on an instance of Class". In this case, call the invoke method on the Method object.
  22. NumberSliderEntry isn't involved here. You want to access the getConfiguration method in the ConfigManager class, so use ConfigManager.class as the clazz argument and "getConfiguration" as the methodName argument. The method doesn't have an obfuscated name (since it's not added by vanilla), so use null as the methodObfName argument. The method takes has two String parameters, so use String.class, String.class as the parameterTypes argument.
  23. I just added two more enum properties to my mod, both of which are in a subcategory/nested class rather than the top-level category/class. One uses an enum defined in the top-level class, the other uses an enum defined in the nested class. Both save without issue.
  24. I then explained how to call it with reflection in more detail here: When you use reflection to call a method, you don't call it directly like you would normally. You need to get the Method object for the method and then use that to call it.
  25. I've told you which methods you need to call, was there a particular part of my instructions that you didn't understand? Class.forName requires the fully qualified name of the class, e.g. "java.lang.Thread" rather than just "Thread". You only need to call Class.forName to get a Class object for a class that isn't known at compile-time. If you do know the class at compile-time, use a class literal instead.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.