#How to make a recipekey with a custom type

44 messages · Page 1 of 1 (latest)

lunar viper
knotty coyoteBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

clever sleet
#

Your situation is very similar to what @candid cedar did with TFC FluidIngredient
https://github.com/Notenoughmail/KubeJS-TFC/blob/1.20.1/src/main/java/com/notenoughmail/kubejs_tfc/recipe/component/FluidIngredientComponent.java

Your FluidIngredient that you need to implement a new RecipeComponent
https://github.com/TeamPneumatic/pnc-repressurized/blob/7955c46330cf1ff105472da80d7c85e1dd0d9bfc/src/api/java/me/desht/pneumaticcraft/api/crafting/ingredient/FluidIngredient.java#L329

You will also need to create a typeWrapper/bindings for FluidIngredient

#

delegating the parsing stuff is better than reinventing the wheel

clever sleet
restive etherBOT
#

Please close your ticket (with </ticket close:1054771505520717835> or the button atop this thread) once you resolved your issue! This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.

Do you have any other questions regarding your issue? Feel free to ask!
Note: You generally should create a new post for unrelated issues.

lunar viper
#

Sorry haven’t finished working on it, just haven’t had any problems to report

lunar viper
clever sleet
#

@lunar viper hmm, protected prevents from what? isn't it just from extending the class?

#

anyway, it prob have helper functions inside the class

#

let me see

lunar viper
#

Don't I have to do this?

#
    public static final FluidIngredient INGREDIENT = new FluidIngredient();
#

Yes I know I'm using the wrong class for this

#

Just focusing on the protection atm

clever sleet
#

new FluidIngredient() this is wrong arguments of initialization of the class

lunar viper
#

Ah

clever sleet
#

but why do you want to initialize it? 🤔

lunar viper
#

Was just seeing how it was done in the class you linked

clever sleet
#

this is from Mail right?

lunar viper
#

Yeah

clever sleet
#

yes, you need to create an exclusive component just like he did

lunar viper
#

Thats what I did

#

Now I'm trying to do this

clever sleet
#

show you custom component

lunar viper
#
public class PNCRComponents implements RecipeComponent<FluidIngredient> {
    public static final PNCRComponents INGREDIENT = new FluidIngredient();

    @Override
    public Class<?> componentClass() {
        return FluidIngredient.class;
    }

    @Override
    public JsonElement write(RecipeJS recipe, FluidIngredient value) {
        return value.toJson();
    }

    @Override
    public FluidIngredient read(RecipeJS recipe, Object from) {
        return null;
    }
}
clever sleet
#

yeah this public static final stuff I don't get, did Mail do something like that?

lunar viper
#

You're the one who linked Mail's component despair

clever sleet
#

he did component, he initialized itself

lunar viper
#

oh

clever sleet
#

not the ingredient

lunar viper
#

I'm blind as hell

#

okay, so is that all I need or do I need to figure out the custom type as well?

clever sleet
#

type of what?

lunar viper
#

their custom json type for the fluids

#
  "fluid_input": {
    "type": "pneumaticcraft:fluid",
    "tag": "pneumaticcraft:diesel",
    "amount": 1000
  },```
lunar viper
#

oh man this is gonna be a hell of a task

clever sleet
#

and this was the easiest way because you don't need to parse all the shit inside the type