-
Notifications
You must be signed in to change notification settings - Fork 396
Upon preroll, destroy ranged ingredient. #5051
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: dt/ranged-prerolls
Are you sure you want to change the base?
Changes from all commits
2908304
aec1c65
bf48c2a
5a51f80
52208b5
ec749f2
5221677
a4310ab
f426e5c
bc8e523
d0e14ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -400,7 +400,13 @@ public ActionResult handleTickRecipe(GTRecipe recipe) { | |
| var result = RecipeHelper.matchTickRecipe(getRLMachine(), recipe); | ||
| if (!result.isSuccess()) return result; | ||
|
|
||
| recipe.doTickPrerolls(this.chanceCaches); | ||
| if (lastDisplayedRecipe == null) { | ||
| GTCEu.LOGGER.warn("Last Displayed Recipe is null! Ingredients may roll incorrectly."); | ||
| this.lastDisplayedRecipe = lastRecipe.copy(); | ||
| syncDataHolder.markClientSyncFieldDirty("lastDisplayedRecipe"); | ||
| markLastRecipeDirty(); | ||
| } | ||
| recipe.doTickPrerolls(this.chanceCaches, this.lastDisplayedRecipe); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this taking lastDisplayedRecipe is a bit iffy since the name implies it's used for displaying, but that might have to wait until 9.0.0 recipelogic refactor |
||
|
|
||
| result = handleTickRecipeIO(recipe, IO.IN); | ||
| if (!result.isSuccess()) return result; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -235,18 +235,56 @@ public ChanceLogic getChanceLogicForCapability(RecipeCapability<?> cap, IO io, b | |||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public void doPrerolls(IdentityHashMap<RecipeCapability<?>, Object2IntMap<?>> chanceCaches) { | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO method shouldn't be part of GTRecipe, move it to |
||||||||||||||||||||
| var rangedContents = getFullContents(); | ||||||||||||||||||||
| for (Content item : rangedContents) { | ||||||||||||||||||||
| if (item.content() instanceof IRangedIngredient ranged) | ||||||||||||||||||||
| ranged.rollSampledCount(); | ||||||||||||||||||||
| for (var handler : inputs.values()) { | ||||||||||||||||||||
| for (var iterator = handler.listIterator(); iterator.hasNext();) { | ||||||||||||||||||||
| var content = iterator.next(); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Less
Suggested change
|
||||||||||||||||||||
| if (content.content() instanceof IRangedIngredient ranged) { | ||||||||||||||||||||
| ranged.rollSampledCount(); | ||||||||||||||||||||
| iterator.set(new Content(ranged.collapse(), content.chance(), content.maxChance())); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| for (var handler : outputs.values()) { | ||||||||||||||||||||
| for (var iterator = handler.listIterator(); iterator.hasNext();) { | ||||||||||||||||||||
| var content = iterator.next(); | ||||||||||||||||||||
|
Comment on lines
+247
to
+249
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
| if (content.content() instanceof IRangedIngredient ranged) { | ||||||||||||||||||||
| ranged.rollSampledCount(); | ||||||||||||||||||||
| iterator.set(new Content(ranged.collapse(), content.chance(), content.maxChance())); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public void doTickPrerolls(IdentityHashMap<RecipeCapability<?>, Object2IntMap<?>> chanceCaches) { | ||||||||||||||||||||
| var rangedContents = getFullTickContents(); | ||||||||||||||||||||
| for (Content item : rangedContents) { | ||||||||||||||||||||
| if (item.content() instanceof IRangedIngredient ranged) | ||||||||||||||||||||
| ranged.rollSampledCount(); | ||||||||||||||||||||
| public void doTickPrerolls(IdentityHashMap<RecipeCapability<?>, Object2IntMap<?>> chanceCaches, | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method really shouldn't be part of GTRecipe (especially as it takes in another recipe as a parameter!) |
||||||||||||||||||||
| GTRecipe lastDisplayedRecipe) { | ||||||||||||||||||||
| if (!this.hasTick()) return; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| this.tickInputs.clear(); | ||||||||||||||||||||
| this.tickOutputs.clear(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| for (var capability : lastDisplayedRecipe.tickInputs.keySet()) { | ||||||||||||||||||||
| var handler = lastDisplayedRecipe.tickInputs.get(capability); | ||||||||||||||||||||
| for (var iterator = handler.listIterator(); iterator.hasNext();) { | ||||||||||||||||||||
| var content = iterator.next(); | ||||||||||||||||||||
|
Comment on lines
+265
to
+268
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Less var part 3
Suggested change
|
||||||||||||||||||||
| if (content.content() instanceof IRangedIngredient ranged) { | ||||||||||||||||||||
| ranged.rollSampledCount(); | ||||||||||||||||||||
| content = new Content(ranged.collapse(), content.chance(), content.maxChance()); | ||||||||||||||||||||
| ranged.reset(); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| tickInputs.computeIfAbsent(capability, c -> new ArrayList<>()).add(content); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| for (var capability : lastDisplayedRecipe.tickOutputs.keySet()) { | ||||||||||||||||||||
| var handler = lastDisplayedRecipe.tickOutputs.get(capability); | ||||||||||||||||||||
| for (var iterator = handler.listIterator(); iterator.hasNext();) { | ||||||||||||||||||||
| var content = iterator.next(); | ||||||||||||||||||||
|
Comment on lines
+277
to
+280
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Less var part 4
Suggested change
|
||||||||||||||||||||
| if (content.content() instanceof IRangedIngredient ranged) { | ||||||||||||||||||||
| ranged.rollSampledCount(); | ||||||||||||||||||||
| content = new Content(ranged.collapse(), content.chance(), content.maxChance()); | ||||||||||||||||||||
| ranged.reset(); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| tickOutputs.computeIfAbsent(capability, c -> new ArrayList<>()).add(content); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
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.