TerraFirmaCraft

TerraFirmaCraft

2M Downloads

`MealModifier.portions()` is public but `MealModifier.MealPortion` is private

Montessquio opened this issue ยท 2 comments

commented

In MealModifier.java the portions of a meal modifier may be accessed via MealModifier.portions(), however the underlying record-class is private. This makes it impossible for other code to interact with meal portion data in-code.

Referencing the latest 1.18.2 version of TFC available from CurseForge, the following snippet will produce the compiler error MealPortion has private access in MealModifier.

MealModifier = somehowGetAMealModifierInstance();
for(var portion : meal.portions()) {
    doSomethingWith(portion);
}

Since the portions list is already exposed, maybe it would be a good idea to change MealPortion to public?

commented

What on earth for?

commented

I'm trying to make a KubeJS plugin which exposes TerraFirmaCraft crafting to KubeJS scripts. In order to serialize/deserialize recipe modifiers I need to be able to access their data from from my code.
Although, this does stop any mod from dealing with meal portions programmatically in general, not just ones looking to interfere with the data loading process.