• 1

    posted a message on IItem Color Isn't Working for Leather Armor Model

    extend recipes is this an IRecipe Class thing or what? Send me the documentation I will take a look at it.



    I was using "extend" in the general sense here, i.e. "add more stuff". I wasn't specifically talking about extending a class.

    There's not much documentation on the JSON recipe system, so I'll briefly explain how to add custom recipe, ingredient and condition types.

    To add a custom recipe type, first create a class that either extends an existing IRecipe implementation (e.g. ShapedRecipes) or implements IRecipe and extends IForgeRegistryEntry.Impl. You then create a class that implements IRecipeFactory and deserialises the custom recipe type from the provided JSON object.

    To add a custom ingredient type, first create a class extends Ingredient or a subclass (skip this step if an existing Ingredient class provides the required functionality). You then create a class that implements IIngredientFactory and deserialises the custom ingredient type from the provided JSON object.

    To add a custom condition type, create a class that implements IConditionFactory and deserialises the condition (a BooleanSupplier) from the provided JSON object. You can implement BooleanSupplier with a class (named or anonymous), lambda or method reference.

    Create a file called _factories.json in assets/<modid>/recipes that specifies your IRecipeFactory, IIngredientFactory and IConditionFactory classes.

    You can see some examples of custom recipe and ingredient implements here and some examples of the JSON files here.
    Posted in: Modification Development
  • 0

    posted a message on IItem Color Isn't Working for Leather Armor Model

    I remember trying add shaped GameRegistry#addrecipe() and it didn't function the same as GameRegistry#ddShapedRecipe(). Is this still the case? .jsons require actual files when I could register thousands of recipes from code at once If I felt like it without actual files. I could never get the GameRegistry#addShapedRecipe working so I always used addrecipe()


    In 1.11.2 and earlier, GameRegistry.addRecipe(ItemStack, Object...) did nothing but call GameRegistry.addShapedRecipe. The two methods did exactly the same thing. GameRegistry.addRecipe(IRecipe) allowed you to add an IRecipe instance that you'd already created yourself.

    In 1.12+, both overloads of GameRegistry.addRecipe have been removed; only GameRegistry.addShapedRecipe and GameRegistry.addShapelessRecipe remain. These perform the same function as they did in 1.11.2 and earlier, i.e. creating and registering an instance of ShapedRecipes/ShapelessRecipes from the specified output and input.

    You should use the JSON recipe system for every recipe unless there's a specific reason that it wouldn't work (not just a hypothetical "I could register thousands of recipes if I wanted to"). Forge allows you to extend it by adding new condition, recipe and ingredient types; so it's not just limited to simple vanilla-style recipes.
    Posted in: Modification Development
  • 0

    posted a message on (Help) Delete/Damage item on right click | Apply/remove potion effects on right click [Forge]

    That's the wrong signature for Item#onItemRightClick, so your method doesn't override the super method and it's never called from anywhere. Always annotate override methods with @Override so you get a compilation error when they don't actually override a super method.


    I suggest using your IDE to auto-generate override methods with the correct signature and annotation. You should be able to start typing a method name in the main body of your class and your IDE will bring up a list of matching methods you can override. Selecting one will generate the override method.


    ItemStack#damageItem is the correct method to damage the item. Use ItemStack#shrink to reduce the stack size by the specified amount. An ItemStack with stack size 0 becomes empty, effectively deleting it from the slot.


    Use EntityLivingBase#addPotionEffect to add a PotionEffect and EntityLivingBase#removePotionEffect to remove one.

    Posted in: Modification Development
  • 0

    posted a message on IItem Color Isn't Working for Leather Armor Model
    What happened to registering blocks with custom itemblocks?

    ItemBlocks are registered in the same way as any other Item, just create an instance, set its registry name and register it with IForgeRegistry#register/registerAll.


    Adding Crafting Recipes in code? This no longer works
    ForgeRegistries.RECIPES.register(new ItemStack(oldMap), new Object[]{"xxx","xyx","xxx",'x',Items.PAPER,'y',Items.COMPASS});//Adds My map to the registry

    Calling IForgeRegistry#register for a recipe requires you to create the IRecipe instance yourself. GameRegistry.addShapedRecipe and GameRegistry.addShapelessRecipe still exist, you can use these to add shaped/shapeless recipes in the old way. This should be done in RegistryEvent.Register<IRecipe>.

    The whole point of vararg methods is that Java automatically creates the array for you, you don't need to create it yourself.

    That said, you should be using the JSON recipe system instead of adding recipes in code.
    Posted in: Modification Development
  • 0

    posted a message on Annotation Based GUI Config, with string and number pair list
    Quote from WolfieWaffle»

    Where do I add default values to the HashMap? You can't initialize with values on a hash map, and I don't think a constructor will work because it's static and never instantiated. And then how will this be written in the file? The other entries have something like "S:" to say that it's a string. Will this also correctly read the values when it runs sync?


    You can use a static initialiser block to populate the Map with default values.

    The Map will be converted to a category with a property for each key-value pair, with the key as the property name and the value as the property value. Forge will preserve the value type, so a Map<String, Double> will be converted to a category containing double properties.

    Posted in: Modification Development
  • 0

    posted a message on Potion Effect, Set Damage Interval? [Forge]

    Java has a tutorial on overriding methods here.


    This is very basic Java knowledge that you should already have before making a mod.

    Posted in: Modification Development
  • 0

    posted a message on How to render a TESR as an item
    Quote from Z_Doctor»

    I have a Tile Entity with Special Render that renders as expected in the world, but I also want it to render like this in the inventory. How would I accomplish this?


    You can use ForgeHooksClient.registerTESRItemStack to register a TESR for an Item, but this is deprecated and marked for removal as soon as possible.

    If possible, you should use the baked model system instead of a TESR.

    What are you using the TESR for?
    Posted in: Modification Development
  • 0

    posted a message on IItem Color Isn't Working for Leather Armor Model

    How does it know where the item block is suppose to be attached to the block resource location stuff unlocalized names?

    When you register an ItemBlock, Forge adds the ItemBlock and the Block it returns from ItemBlock#getBlock to the Map used by Item.getItemFromBlock.

    The Block and ItemBlock should have the same registry name as each other, but this isn't strictly required.
    Posted in: Modification Development
  • 0

    posted a message on Annotation Based GUI Config, with string and number pair list
    Quote from WolfieWaffle»

    It says I can't instantiate Map, even when I used the scala import. Which import should I use? And then do I just include it the same way that it works for integers? I don't know what Object types the GUI has support for.

    Map is an interface, you can't instantiate it. Use an implementation of Map for the value of the field (e.g. HashMap or LinkedHashMap).

    Just create a Map field and initialise it with a value and Forge will convert it to a category. It won't have any properties until you populate the Map with some keys and values.

    The config GUI doesn't support adding new entries to the Map. If you want to do that, you'll need to create your own IConfigEntry implementation and tell Forge to use that instead of the default one.
    Posted in: Modification Development
  • 0

    posted a message on IItem Color Isn't Working for Leather Armor Model

    What happened to registering blocks with custom itemblocks?

    Block and Item both implement IForgeRegistryEntry, you register them both in the same way. This includes ItemBlocks.
    Posted in: Modification Development
  • 0

    posted a message on IItem Color Isn't Working for Leather Armor Model

    "Cannot make a static reference to the non-static method register(IForgeRegistryEntry) from the type IForgeRegistry"

    IForgeRegistry.register(helmet);


    that's the interface where is the object for iforge registry?


    IForgeRegistry#register is an instance method, you need to call it on an instance of IForgeRegistry.

    I explained how to get the IForgeRegistry instance in my previous post:

    Quote from Choonster»
    If you're using the registry events, use RegistryEvent.Register#getRegistry to get the IForgeRegistry. If you're not, get the IForgeRegistry from the ForgeRegistries class.
    Posted in: Modification Development
  • 0

    posted a message on IItem Color Isn't Working for Leather Armor Model

    IForgeRegistry#register Only wants an item no localized name and I need the object not the class so confused right now.


    Create an instance of your Item class, set its registry name with IForgeRegistryEntry#setRegistryName and then register it.

    The localised name has nothing to do with the registration.
    Posted in: Modification Development
  • 0

    posted a message on Potion Effect, Set Damage Interval? [Forge]

    Override Potion#isReady to check if duration (the number of ticks the effect has left) is divisible by X (i.e. duration % X == 0), where X is the interval at which the potion should damage the entity. Override Potion#performEffect to damage the entity.

    Posted in: Modification Development
  • 0

    posted a message on IItem Color Isn't Working for Leather Armor Model

    Using the register method which is asking for something or the event thing?

    You register things with IForgeRegistry#register or IForgeRegistry#registerAll regardless of when you register them.

    If you're using the registry events, use RegistryEvent.Register#getRegistry to get the IForgeRegistry. If you're not, get the IForgeRegistry from the ForgeRegistries class.
    Posted in: Modification Development
  • 0

    posted a message on IItem Color Isn't Working for Leather Armor Model

    I am confused you are saying it's impossible or are you saying it's fine to do it in post init? What method?


    It's possible to register things in postInit, but you should avoid it if possible.

    Posted in: Modification Development
  • To post a comment, please or register a new account.