Better Farming module (crop farming improvements)#6417
Conversation
|
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) |
|
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 = { |
There was a problem hiding this comment.
Can be replaced with Direction.BY_2D_DATA
There was a problem hiding this comment.
That seems to have private access?
| if (foundItem.isMainHand()) { | ||
| blockBreakCooldown = 3; | ||
| return; | ||
| }; |
|
|
||
| private void trampleSuppressionSendEvent(PacketEvent.Send event) { | ||
| if (mc.player == null) return; | ||
| if (!(event.packet instanceof ServerboundMovePlayerPacket) |
There was a problem hiding this comment.
instance of IServerboundMovePlayerPacket p
There was a problem hiding this comment.
I don't really understand the recommended change here? Also the way its written there is copied almost directly from NoFall, so we may want to change it there as well if there's a better way.
|
|
||
| ServerboundMovePlayerPacket packet = (ServerboundMovePlayerPacket) event.packet; | ||
|
|
||
| BlockPos blockPos = new BlockPos( |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
.up() doesn't exist, but I'm guessing you meant .above().
There was a problem hiding this comment.
Oh yeah up is yarn name
There was a problem hiding this comment.
ah ok makes sense
|
|
||
| for (Direction direction : checkDirections) { | ||
| // Check block at blockPos offset by the direction normal vector. | ||
| BlockState bsCheck = mc.level.getBlockState(blockPos.offset(direction.getUnitVec3i())); |
There was a problem hiding this comment.
blockPos.relative(direction)
| } | ||
|
|
||
| private Item placeItem = null; | ||
| private final ArrayList<BlockPos> cropPlacements = new ArrayList<>(); |
There was a problem hiding this comment.
ArrayDeque/ArrayListDeque will be better because you call removeFirst on it
There was a problem hiding this comment.
ArrayList also seems to have removeFirst. I assume ArrayListDeque is better for performance?
There was a problem hiding this comment.
Yes. ArrayList.removeFirst moves all elements after first one
There was a problem hiding this comment.
ok cool yeah i will use that then, thanks
Type of change
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.
How Has This Been Tested?
https://youtu.be/VH0yt58lyZs
Checklist: