-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Processing recipe rework #3232
Processing recipe rework #3232
Conversation
private boolean process( final Path root, final Path file ) | ||
{ | ||
String relative = root.relativize( file ).toString(); | ||
if( !"json".equals( FilenameUtils.getExtension( file.toString() ) ) || relative.startsWith( "_" ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
private void register( JsonObject json ) | ||
{ | ||
if( json == null || json.isJsonNull() ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public class AERecipeLoader | ||
{ | ||
private static final String AERECIPE_BASE = "/aerecipes"; | ||
private static Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return CraftingHelper.findFiles( this.mod, "assets/" + AppEng.MOD_ID + AERECIPE_BASE, this::preprocess, this::process, true, true ); | ||
} | ||
|
||
private boolean preprocess( final Path root ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new JsonSyntaxException( "Json cannot be null" ); | ||
|
||
String type = this.ctx.appendModId( JsonUtils.getString( json, "type" ) ); | ||
if( type.isEmpty() ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
reader = Files.newBufferedReader( file ); | ||
JsonObject json = JsonUtils.fromJson( GSON, reader, JsonObject.class ); | ||
if( json.has( "conditions" ) && !CraftingHelper.processConditions( JsonUtils.getJsonArray( json, "conditions" ), this.ctx ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new JsonSyntaxException( "Recipe type can not be an empty string" ); | ||
|
||
IAERecipeFactory factory = factories.get( new ResourceLocation( type ) ); | ||
if( factory == null ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
Preconditions.checkNotNull( event ); | ||
Preconditions.checkNotNull( recipeDirectory ); | ||
Preconditions.checkArgument( !recipeDirectory.isFile() ); | ||
Preconditions.checkNotNull( customRecipeConfig ); | ||
|
||
final Api api = Api.INSTANCE; | ||
final IPartHelper partHelper = api.partHelper(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Override | ||
public void register( JsonObject json, JsonContext ctx ) | ||
{ | ||
// TODO only primary for now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import net.minecraftforge.common.crafting.JsonContext; | ||
|
||
|
||
public interface IAERecipeFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotate the "IAERecipeFactory" interface with the @FunctionalInterface annotation
@@ -74,696 +31,15 @@ | |||
*/ | |||
public class RecipeHandler implements IRecipeHandler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
return in; | ||
} | ||
|
||
@Override | ||
public void parseRecipes( final IRecipeLoader loader, final String path ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -183,11 +183,12 @@ public boolean isCable() | |||
|
|||
QUARTZ_FIBER( 140, "quartz_fiber", EnumSet.of( AEFeature.QUARTZ_FIBER ), EnumSet.noneOf( IntegrationType.class ), PartQuartzFiber.class ), | |||
|
|||
MONITOR( 160, "monitor", EnumSet.of( AEFeature.PANELS ), EnumSet.noneOf( IntegrationType.class ), PartPanel.class ), | |||
MONITOR( 160, "monitor", EnumSet.of( AEFeature.PANELS ), EnumSet.noneOf( IntegrationType.class ), PartPanel.class, "itemIlluminatedPanel" ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0ce4e38
to
8360ec9
Compare
Rebased (and squashed to make it easier). |
SonarQube analysis reported 79 issues Watch the comments in this conversation to review them. Top 10 extra issuesNote: The following issues were found on lines that were not modified in the pull request. Because these issues can't be reported as line comments, they are summarized here:
|
Work in progress!
Processing recipes based on json recipe parsing.
*) Removed recipes for external mods for now. If we really need it we can add it back easy enough.
*) Removed WebSerializer. This probably has to be reimplemented.
*) The old recipe parser still has some stuff in the API