Skip to content

Better Farming module (crop farming improvements)#6417

Open
moxvallix wants to merge 4 commits into
MeteorDevelopment:masterfrom
optipack:better-farming
Open

Better Farming module (crop farming improvements)#6417
moxvallix wants to merge 4 commits into
MeteorDevelopment:masterfrom
optipack:better-farming

Conversation

@moxvallix
Copy link
Copy Markdown
Contributor

Type of change

  • New feature

Description

This adds a new module, named Better Farming, which adds couple of utilities related to crop farming.

Firstly, the module will attempt to replace a harvested crop automatically, granted the player has its seed in their inventory.

Secondly, using the same method as NoFall, but changing it to work only when above farmland, it suppresses crop trampling, allowing the player to jump on the crops without them trampling.

Then, it will also prevent the player from harvesting crops that are not yet ripe.

Lastly, for sugar cane and bamboo, it will prevent the player from breaking the bottom block.

All of these should help players maintain sizable manual crop farms. All listed behaviours can be toggled in the settings.

image

How Has This Been Tested?

https://youtu.be/VH0yt58lyZs

Checklist:

  • My code follows the style guidelines of this project.
  • I have added comments to my code in more complex areas.
  • I have tested the code in both development and production environments.

@crosby-moe
Copy link
Copy Markdown
Collaborator

no break for the bottom block of cactus & the log where cocoa beans is attached could be good too

@moxvallix
Copy link
Copy Markdown
Contributor Author

no break for the bottom block of cactus & the log where cocoa beans is attached could be good too

Oh true, good idea. Maybe budding amethyst too (although that can just be done in No Interact)

@moxvallix
Copy link
Copy Markdown
Contributor Author

I added a new setting: no break supporting blocks. When this is on, blocks that are holding a crop cannot be broken, which also extends to cocoa.

Also cactus is now counted as a cane block.

}

private boolean checkForCocoa(BlockPos blockPos) {
Direction[] checkDirections = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can be replaced with Direction.BY_2D_DATA

if (foundItem.isMainHand()) {
blockBreakCooldown = 3;
return;
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

;


private void trampleSuppressionSendEvent(PacketEvent.Send event) {
if (mc.player == null) return;
if (!(event.packet instanceof ServerboundMovePlayerPacket)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

instance of IServerboundMovePlayerPacket p


ServerboundMovePlayerPacket packet = (ServerboundMovePlayerPacket) event.packet;

BlockPos blockPos = new BlockPos(
Copy link
Copy Markdown
Contributor

@MukjepScarlet MukjepScarlet Jun 2, 2026

Choose a reason for hiding this comment

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

BlockPos.containing?

private void noBreakSupportingBlocksBreakEvent(StartBreakingBlockEvent event) {
BlockPos blockPos = event.blockPos;
BlockState blockState = mc.level.getBlockState(blockPos);
BlockState bsAbove = mc.level.getBlockState(blockPos.offset(0, 1, 0));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

.up()


for (Direction direction : checkDirections) {
// Check block at blockPos offset by the direction normal vector.
BlockState bsCheck = mc.level.getBlockState(blockPos.offset(direction.getUnitVec3i()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

blockPos.relative(direction)

}

private Item placeItem = null;
private final ArrayList<BlockPos> cropPlacements = new ArrayList<>();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ArrayDeque/ArrayListDeque will be better because you call removeFirst on it

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.

3 participants