Railcraft compat#384
Conversation
Wizzerinus
left a comment
There was a problem hiding this comment.
I'm not a maintainer of this mod, just mentioning some things I noticed ;)
| } | ||
|
|
||
| @MethodDescription(example = @Example("item('railcraft:ingot:1')")) | ||
| public void removeByOutput(ItemStack output) { |
There was a problem hiding this comment.
afaik removeBy... methods usually should return a boolean
| return; | ||
| } | ||
| if (!getRecipes().removeIf(recipe -> { | ||
| if (recipe.getInput().test(input.getMatchingStacks()[0])) { |
There was a problem hiding this comment.
Good idea to either adjust the function to accept an ItemStack, or test against each matching stack
There was a problem hiding this comment.
missing lang files for all compat scripts. they're needed to generate the wiki (you can test this in a dev env by using /gs generateWiki)
| public @Nullable IBlastFurnaceCrafter.IRecipe register() { | ||
| if (!validate()) return null; | ||
| ItemStack outputStack = output.get(0); | ||
| Ingredient inputIngredient = Railcraft.toIngredient(input.get(0)); |
There was a problem hiding this comment.
I'm pretty sure there's already a way in Groovyscript to make Forge ingredients
| IBlastFurnaceCrafter.IRecipe recipe = new IBlastFurnaceCrafter.IRecipe() { | ||
| @Override | ||
| public net.minecraft.util.ResourceLocation getName() { | ||
| return new net.minecraft.util.ResourceLocation("groovyscript", "blastfurnace_" + System.currentTimeMillis()); |
There was a problem hiding this comment.
possibly allow configuring the recipe name similar to crafting table
| public void validate(GroovyLog.Msg msg) { | ||
| validateItems(msg, 1, 1, 1, 1); | ||
| validateFluids(msg); | ||
| if (time < 0) time = 1800; |
There was a problem hiding this comment.
if (time < 0) should emit a error instead
| if (time < 0) time = 1280; | ||
| if (slag < 0) slag = 1; |
There was a problem hiding this comment.
should emit errors on these
| // Restore from backup | ||
| restoreFromBackup().forEach(entry -> { | ||
| try { | ||
| mods.railcraft.api.fuel.FluidFuelManager.addFuel(entry.fluid, entry.heatValue); |
There was a problem hiding this comment.
any reason you're not importing this?
| Crafters.rollingMachine().getRecipes().clear(); | ||
| } | ||
|
|
||
| public static class ShapedRecipeBuilder { |
There was a problem hiding this comment.
could use the AbstractShapedRecipeBuilder to not have to manage matrix/etc manually? (I'm not sure what's the name of it is, but it is used for MC tables, Astral Sorcery tables, etc)
WaitingIdly
left a comment
There was a problem hiding this comment.
a few other things:
- instead of magic numbers as defaults, use the railcraft defaults directly - ie
IRollingMachineCrafter.DEFAULT_PROCESS_TIME. - run
/gs generateWikior enablingdev_generate_wikiingradle.properties- check the log to ensure no warnings/missing lang keys. - wizz also brought up great points, listen to those.
| debug_prodigytech = false | ||
| debug_projecte = false | ||
| debug_pyrotech = false | ||
| debug_railcraft = false |
| 'tinkers_construct-74072:2902483' : [debug_tinkers_construct], | ||
| 'woot-244049:2712670' : [debug_woot], | ||
| 'railcraft-51195:3853491' : [debug_railcraft], | ||
| 'woot-244049:2712670' : [debug_woot], |
There was a problem hiding this comment.
this should only contain the generated script, which is obtained via ie /gs generateExamples or by enabling dev_generate_examples in gradle.properties.
| builder.time = time; | ||
| builder.slag = slag; |
There was a problem hiding this comment.
call builder methods instead. this applies in all places, to all builders. observe how other similar methods do this
| @Property(comp = @Comp(gte = 0)) | ||
| private int time = 1280; | ||
| @Property(comp = @Comp(gte = 0)) | ||
| private int slag = 1; |
There was a problem hiding this comment.
add defaultValue = "whatever" to the annotation whenever a builder field is non-default
|
|
||
| @Property(comp = @Comp(gte = 0)) | ||
| private int time = 200; | ||
| private final List<IOutputEntry> outputs = new ArrayList<>(); |
There was a problem hiding this comment.
annotate this with @Property. i would also suggest renaming this to output
| List<IRollingMachineCrafter.IRollingRecipe> recipes = new ArrayList<>(Crafters.rollingMachine().getRecipes()); | ||
| recipes.removeIf(recipe -> recipe.getRegistryName().equals(r.getKey())); |
There was a problem hiding this comment.
create a new arraylist and then remove from that list? are you sure thats correct
| List<IRollingMachineCrafter.IRollingRecipe> recipes = new ArrayList<>(Crafters.rollingMachine().getRecipes()); | ||
| recipes.removeIf(recipe -> recipe.getRegistryName().equals(r.getKey())); | ||
| }); | ||
| restoreFromBackup().forEach(r -> ModSupport.RAILCRAFT.get().rollingMachine.add(r.getKey(), r.getValue())); |
There was a problem hiding this comment.
cant do this, because RollingMachine#add runs #addScripted
| if (time <= 0) { | ||
| GroovyLog.msg("Error adding Railcraft Blast Furnace recipe") | ||
| .error() | ||
| .add("time must be greater than 0, got: {}", time) | ||
| .post(); | ||
| return null; | ||
| } | ||
| if (slag < 0) { | ||
| GroovyLog.msg("Error adding Railcraft Blast Furnace recipe") | ||
| .error() | ||
| .add("slag must be non-negative, got: {}", slag) | ||
| .post(); | ||
| return null; | ||
| } |
There was a problem hiding this comment.
validate in the builder
| if (time <= 0) { | ||
| msg.add("time must be greater than 0, got: {}", time); | ||
| time = IBlastFurnaceCrafter.SMELT_TIME; | ||
| } | ||
| if (slag < 0) { | ||
| msg.add("slag must be non-negative, got: {}", slag); | ||
| slag = 1; | ||
| } |
There was a problem hiding this comment.
if there are any messages, the validation fails. just do
| if (time <= 0) { | |
| msg.add("time must be greater than 0, got: {}", time); | |
| time = IBlastFurnaceCrafter.SMELT_TIME; | |
| } | |
| if (slag < 0) { | |
| msg.add("slag must be non-negative, got: {}", slag); | |
| slag = 1; | |
| } | |
| msg.add(time <= 0, "time must be greater than 0, got: {}", time); | |
| msg.add(slag < 0, "slag must be non-negative, got: {}", slag); |
| @Property | ||
| private FluidStack fluid; |
There was a problem hiding this comment.
instead of this, use fluidOutput from parent
| @RegistryDescription | ||
| public class FluidFuels extends VirtualizedRegistry<FluidFuels.FuelEntry> { | ||
|
|
||
| private final Map<String, Integer> backupFuels = new HashMap<>(); |
There was a problem hiding this comment.
this is now completely unused
|
|
||
| public boolean remove(IRollingMachineCrafter.IRollingRecipe recipe) { | ||
| return Crafters.rollingMachine().getRecipes().removeIf(r -> { | ||
| if (r == recipe) { |
There was a problem hiding this comment.
if r == recipe well you can just do addBackup(recipe) + Crafters.rollingMachine().getRecipes().remove(recipe) then
| # Version of your mod. | ||
| # This field can be left empty if you want your mod's version to be determined by the latest git tag instead. | ||
| modVersion = 1.4.3 | ||
| modVersion = 1.4.4 |
There was a problem hiding this comment.
undo changing the version
bro Railcraft compat