Skip to content

feat: abstract stove#1265

Merged
vectorwing merged 26 commits intovectorwing:dev/1.3from
Lordfirespeed:feature/fd1.3-abstract-stove
Apr 14, 2026
Merged

feat: abstract stove#1265
vectorwing merged 26 commits intovectorwing:dev/1.3from
Lordfirespeed:feature/fd1.3-abstract-stove

Conversation

@Lordfirespeed
Copy link
Copy Markdown

No description provided.

@Lordfirespeed
Copy link
Copy Markdown
Author

Lordfirespeed commented Mar 28, 2026

If you'd prefer I can rebase onto the 1.21 branch and target that. Let me know.

Edit: I have also rebased onto 1.21, I can cherry-pick any revisions from here onto there and it should be ready to go.

@Lordfirespeed
Copy link
Copy Markdown
Author

I've only just noticed that indentation is buggered.

Copy link
Copy Markdown
Owner

@vectorwing vectorwing left a comment

Choose a reason for hiding this comment

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

Alright, I did a first pass over the code, and found a few inconsistencies.

The code works when testing locally, and I can see you fixed the issue where the Stove won't spill its contents when blocked while unlit, which is good.

I can do a second pass after the current comments are addressed. 👍

Comment thread src/main/java/vectorwing/farmersdelight/common/block/AbstractStoveBlock.java Outdated
super.stepOn(level, pos, state, entity);
}

protected void burnEntitySteppingOnStove(Level level, BlockPos pos, BlockState state, Entity entity) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Not sure if this method needs to be separate, as it contains almost all of the code that would go into stepOn.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

In the original version of the code, the base.stepOn() was invoked at the end of the method, but I wanted to use early-return pattern to make this method easier to read.

To keep the order of invocation the same and use early return pattern, I had to extract this method

Comment thread src/main/java/vectorwing/farmersdelight/common/block/StoveBlock.java Outdated
Comment thread src/main/java/vectorwing/farmersdelight/common/block/entity/StoveBlockEntity.java Outdated
inventoryChanged();
return true;
private void addSmokeParticles() {
assert this.level != null;
Copy link
Copy Markdown
Owner

@vectorwing vectorwing Mar 30, 2026

Choose a reason for hiding this comment

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

particleTick has access to the client level, so passing it to this method would eliminate the need for this assert. Also, IIRC, assert actually throws an exception when it's null; perhaps just returning early would be best in such cases.

Copy link
Copy Markdown
Author

@Lordfirespeed Lordfirespeed Mar 31, 2026

Choose a reason for hiding this comment

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

assertions are not enabled by default

the assertion is here to make it clear to developers reading the code that the method must only be invoked in contexts where the level is definitely not null

}

private void cookAndOutputItems() {
assert this.level != null;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

assert should be avoided in production code, as it throws exceptions on fail.
Here, it may be better to just return when null instead.

Copy link
Copy Markdown
Author

@Lordfirespeed Lordfirespeed Mar 31, 2026

Choose a reason for hiding this comment

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

Assertions are not enabled by default
Edit: I verified this, assert false didn't throw any exception at runtime
of course, passing a null value to the level parameter of whatever function needs it would probably cause an exception, but the point of the assertion is to ensure that this.level is actually never null because developers know they must only call the function when this.level is definitely not null

As previous: this is primarily to signal to developers reading the code that the method must be invoked only when the level is definitely not null

@vectorwing
Copy link
Copy Markdown
Owner

I added a tiny change to the Stove, where it makes a sound when placing items on the grill. That might cause a small conflict, sorry about that. 😅

@Lordfirespeed Lordfirespeed force-pushed the feature/fd1.3-abstract-stove branch from cd04864 to b71082d Compare April 7, 2026 18:01
@Lordfirespeed
Copy link
Copy Markdown
Author

Ready for second pass

Copy link
Copy Markdown
Owner

@vectorwing vectorwing left a comment

Choose a reason for hiding this comment

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

Second pass done. Aside from a comment and a quick question, everything here seems in order. You managed to organize one of the oldest bits of code in FD, it's looking pretty tidy! 👍

I think we're ready for a merge. I can address the comment below on my own later, unless you'd like to.


if (heldStack.canPerformAction(ToolActions.SHOVEL_DIG)) {
if (!level.isClientSide()) {
level.levelEvent(null, 1009, pos, 0);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

For level events, it would be more readable if we used the LevelEvent static fields directly, so that others reading the code know that 1009 is SOUND_EXTINGUISH_FIRE.


var newState = state.setValue(LIT, false);
level.setBlock(pos, newState, 11);
level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(entity, newState));
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Question: why is this game event being sent twice?

return tryToPlaceFoodItem(state, level, pos, player, hand, hit);
}

protected InteractionResult tryToIgnite(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Igniting currently lacks the gameEvent call, so it doesn't trigger sculk sensors. Might be worth adding here too.

@vectorwing vectorwing merged commit 2f49288 into vectorwing:dev/1.3 Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants