Skip to content

Refactor JEI description, add support for fluids#382

Open
Wizzerinus wants to merge 1 commit intoCleanroomMC:masterfrom
TeamDimensional:fix/jei-description
Open

Refactor JEI description, add support for fluids#382
Wizzerinus wants to merge 1 commit intoCleanroomMC:masterfrom
TeamDimensional:fix/jei-description

Conversation

@Wizzerinus
Copy link
Copy Markdown
Contributor

Allows using fluid(...) in mods.jei.description, which also fixes a startup crash when the code does that

This should support adding more types fairly easily

lmk if this is a bad approach, I was kinda very focused on keeping it a VirtualizedRegistry, and its probably not the cleanest way

VanillaTypes.ITEM,
entry.getRight().toArray(new String[0]));
for (DescriptionEntry<?> entry : this.getScriptedRecipes()) {
System.out.println("adding entry: " + entry);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

println

for (Pair<List<IIngredient>, List<String>> entry : this.getBackupRecipes()) {
if (entry.getKey()
for (DescriptionEntry<?> entry : this.getBackupRecipes()) {
System.out.println("removing entry: " + entry);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

println

@MethodDescription(type = MethodDescription.Type.ADDITION)
public void add(List<IIngredient> target, List<String> description) {
addScripted(Pair.of(target, description));
public void add(IIngredient[] target, String... description) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe do Object[] target + get the IIngredientRegistry#getIngredientType later on + check that everything has the same ingredient type. wouldnt use IIngredient or FluidStack anymore

}

private boolean compareObjects(Object inEntry, Object inRegistry) {
if (inEntry instanceof ItemStack ieStack) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this happens only in applyRemovals, we can compare using IIngredientHelper#getUniqueId - perhaps IngredientUtil#equal? although i think that might be intended for internal logic.

entry.getRight().toArray(new String[0]));
for (DescriptionEntry<?> entry : this.getScriptedRecipes()) {
System.out.println("adding entry: " + entry);
if (entry.representative instanceof ItemStack) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would suggest ensuring everything is the same IIngredientRegistry#getIngredientType + registering via that (casting as needed. shouldnt need an instanceof then

public class Description extends VirtualizedRegistry<Pair<List<IIngredient>, List<String>>> {
public class Description extends VirtualizedRegistry<Description.DescriptionEntry<?>> {

static class DescriptionEntry<T> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think this needs public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants