-
Notifications
You must be signed in to change notification settings - Fork 205
Improve CraftingComponent API #2813
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
base: master
Are you sure you want to change the base?
Conversation
| ASSEMBLER_RECIPES.recipeBuilder().duration(80).EUt(VA[HV]) | ||
| .inputs(MetaItems.COVER_SCREEN.getStackForm()) | ||
| .inputs((ItemStack) CraftingComponent.HULL.getIngredient(1)) | ||
| .inputs((ItemStack) CraftingComponents.HULL.getIngredient(1)) | ||
| .input(wireFine, AnnealedCopper, 8) | ||
| .fluidInputs(Polyethylene.getFluid(L)) | ||
| .outputs(MetaTileEntities.MONITOR_SCREEN.getStackForm()) | ||
| .buildAndRegister(); | ||
|
|
||
| ASSEMBLER_RECIPES.recipeBuilder().duration(100).EUt(VA[HV]) | ||
| .inputs(MetaItems.COVER_SCREEN.getStackForm()) | ||
| .inputs((ItemStack) CraftingComponent.HULL.getIngredient(3)) | ||
| .inputs((ItemStack) CraftingComponents.HULL.getIngredient(3)) | ||
| .input(circuit, MarkerMaterials.Tier.HV, 2) | ||
| .fluidInputs(Polyethylene.getFluid(L)) | ||
| .outputs(MetaTileEntities.CENTRAL_MONITOR.getStackForm()) |
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.
should the 1 and 3 here for getIngredient() use LV and HV instead?
| * @param tier the tier of the ingredient | ||
| * @return the raw ingredient, which may be either an {@link ItemStack} or {@link String} | ||
| */ | ||
| public @Nullable Object getIngredient(int tier) { |
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.
Should there be a getItemStack(int tier) method to directly get the tier's item stack so there's no need to cast this method? A getString(int tier) would be good too.
What
Moves CraftingComponent to a dedicated API class, and adds a type-safe builder method to create them.
The explicit builder methods restrict the potential ways to represent a crafting ingredient, preventing use of the more esoteric ones allowed in crafting recipes. This paves the way to expand CraftingComponent's use to more than just crafting in the future.
Implementation Details
The only significant behavioral change is that the fallback value is now handled slightly differently. Additionally, specifying a
Blockwithout meta now defaults to the wildcard metadata value instead of0. This aligns better with the expectation that a block without a specific variant specified should accept any variant.Outcome
Improves CraftingComponent code quality and API.