adds stripped state pre processor - #330
PoTheMagicDragon wants to merge 3 commits into
Conversation
| interface StateProcessor { | ||
| /** Checked before [acceptsState], so a disabled processor still falls back to breaking. */ | ||
| context(_: AutomatedSafeContext) | ||
| fun isEnabled(): Boolean = true |
There was a problem hiding this comment.
the isEnabled check is only overridden by StrippedStateProcessor so the check should probably be moved into the acceptsState for StrippedStateProcessor and the function removed.
| override fun isEnabled() = automatedSafeContext.buildConfig.stripLogs | ||
|
|
||
| override fun acceptsState(state: BlockState, targetState: BlockState): Boolean { | ||
| val unstrippedVariant = unstrippedToStripped[targetState.block] ?: return false |
There was a problem hiding this comment.
this function as a whole can probably be simplified to an = function without a full block
| if (processor.acceptsState(state, targetState)) { | ||
| with(processor) { preProcess(state, targetState, pos) } | ||
| stateProcessing = true | ||
| if (!processor.acceptsState(state, targetState)) return@forEach |
beanbag44
left a comment
There was a problem hiding this comment.
yeah, i was mistaken, sorry. Added a few other small things but theyre not important (aside from the missing space before the opening bracket)
| // Every branch below depends on the current inventory, so this must never be cached. | ||
| noCaching() | ||
|
|
||
| if (state.isReplaceable){ |
There was a problem hiding this comment.
missing space before the {
Also, if you want the logic to mirror FlowerPotStateProcessor for parity, you could change this to state.block != unstrippedVariant and add a return in the block so you can handle the stripping logic after without indentation. The isReplaceable check is already handled in the acceptsState function
| context(safeContext: SafeContext) | ||
| override fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState, pos: BlockPos) { | ||
| val unstrippedVariant = unstrippedToStripped[targetState.block] ?: return | ||
| val player = safeContext.player |
There was a problem hiding this comment.
for something like this, i try to avoid value sets and call with(safeContext) { }, wrapping the function in the safe context. If you change it to use that, i would change the function to = without the {} and then put the with on the next line
Description
Adds a pre processor for handling stripped logs