Skip to content

adds stripped state pre processor - #330

Open
PoTheMagicDragon wants to merge 3 commits into
lambda-client:1.21.11from
PoTheMagicDragon:stripped-logs-printer
Open

PoTheMagicDragon wants to merge 3 commits into
lambda-client:1.21.11from
PoTheMagicDragon:stripped-logs-printer

Conversation

@PoTheMagicDragon

Copy link
Copy Markdown
Contributor

Description

Adds a pre processor for handling stripped logs

@beanbag44
beanbag44 self-requested a review September 16, 2026 16:56

@beanbag44 beanbag44 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small stuff

interface StateProcessor {
/** Checked before [acceptsState], so a disabled processor still falls back to breaking. */
context(_: AutomatedSafeContext)
fun isEnabled(): Boolean = true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldnt be altered

@beanbag44 beanbag44 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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){

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants