Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Treetap #775

Merged
merged 8 commits into from
Mar 11, 2024
Merged

Conversation

DaFuqs
Copy link
Contributor

@DaFuqs DaFuqs commented Sep 13, 2023

This PR adds a fully functional Treetap block, with block, item, recipe, block entity, renderer & recipe type.

Further Ideas:

  • The visuals are a tad barebones and IMO the tap would benefit from a 2D inventory sprite instead of the 3D-model
  • Add more recipes
  • The recipe type currently only supports only single blocks as criterion, block tags, or a location predicate would be cooler.
  • The recipe type does not make use of the Fabric Fluid API yet

Summary by CodeRabbit

  • New Features

    • Introduced new block types and a block entity for enhanced gameplay.
    • Added a new crafting recipe and its serializer for game interaction.
    • Implemented rendering capabilities for a specific block entity.
  • Refactor

    • Updated method access levels to improve code usability.

…1.19.2/master

# Conflicts:
#	build.gradle.kts
#	src/main/java/net/id/paradiselost/blocks/ParadiseLostBlocks.java
Copy link
Contributor

@MBatt1 MBatt1 left a comment

Choose a reason for hiding this comment

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

The other suggestions are good and I think especially block tags and predicates (like fishing recipes do) are things we should add.

I definitely think there should be a time gap between placing and filling, so that you can't just get infinite fluid super quickly, just a specifier in the recipe for the delay for how long it takes to 'recharge' the block, or how long it takes to fill an item

@DaFuqs
Copy link
Contributor Author

DaFuqs commented Sep 15, 2023

I definitely think there should be a time gap between placing and filling, so that you can't just get infinite fluid super quickly, just a specifier in the recipe for the delay for how long it takes to 'recharge' the block, or how long it takes to fill an item

Currently it's based on random tick to add some natural randomness to the tap. But I could also move it so scheduled ticks, always taking a fixed, predetermined amount of time.

@MBatt1
Copy link
Contributor

MBatt1 commented Sep 15, 2023

I definitely think there should be a time gap between placing and filling, so that you can't just get infinite fluid super quickly, just a specifier in the recipe for the delay for how long it takes to 'recharge' the block, or how long it takes to fill an item

Currently it's based on random tick to add some natural randomness to the tap. But I could also move it so scheduled ticks, always taking a fixed, predetermined amount of time.

I just realized that I loaded a world that I think had random tick speed set to 3000, so nevermind. blocktags and predicates still sound like they'd be cool tho

@MBatt1 MBatt1 self-requested a review March 10, 2024 18:26
MBatt1
MBatt1 previously approved these changes Mar 10, 2024
Copy link

coderabbitai bot commented Mar 11, 2024

Walkthrough

The recent updates to the Paradise Lost mod focus on introducing a new mechanical element with the TreeTap block. This addition brings crafting mechanics, block entity management, and rendering enhancements to provide players with new interactive gameplay features and crafting options within the mod.

Changes

File Path Change Summary
build.gradle.kts Added "Ladysnake" Maven repository.
gradle.properties Updated version information for loaderVersion, fabricApiVersion, and customportalapiVersion.
.../ParadiseLost.java Initialized ParadiseLostRecipeTypes in onInitialize.
.../blocks/ParadiseLostBlocks.java Added new block declarations and changed unbreakable method to public static.
.../blocks/blockentity/ParadiseLostBlockEntityTypes.java Added TREE_TAP block entity type registration.
.../blocks/blockentity/TreeTapBlockEntity.java Introduced TreeTapBlockEntity managing inventory and crafting.
.../blocks/mechanical/TreeTapBlock.java Added TreeTapBlock for interaction and crafting actions.
.../client/rendering/block/ParadiseLostBlockEntityRenderers.java Updated registration calls to BlockEntityRendererFactories.register.
.../client/rendering/block/TreeTapBlockEntityRenderer.java Added renderer for TreeTapBlockEntity.
.../items/ParadiseLostItems.java Added TREE_TAP block item.
.../recipe/ParadiseLostRecipeTypes.java Introduced custom recipe types and serializers functionality.
.../recipe/TreeTapRecipe.java Introduced TreeTapRecipe for specific crafting actions.
.../recipe/TreeTapRecipeSerializer.java Added TreeTapRecipeSerializer for handling recipe data.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between f6ad972 and b3bbc1d.
Files ignored due to path filters (7)
  • src/main/resources/assets/paradise_lost/blockstates/tree_tap.json is excluded by: !**/*.json
  • src/main/resources/assets/paradise_lost/lang/en_us.json is excluded by: !**/*.json
  • src/main/resources/assets/paradise_lost/models/block/tree_tap.json is excluded by: !**/*.json
  • src/main/resources/assets/paradise_lost/models/item/tree_tap.json is excluded by: !**/*.json
  • src/main/resources/data/paradise_lost/loot_tables/blocks/tree_tap.json is excluded by: !**/*.json
  • src/main/resources/data/paradise_lost/recipes/tree_tap.json is excluded by: !**/*.json
  • src/main/resources/data/paradise_lost/recipes/tree_tap/water.json is excluded by: !**/*.json
Files selected for processing (13)
  • build.gradle.kts (1 hunks)
  • gradle.properties (1 hunks)
  • src/main/java/net/id/paradiselost/ParadiseLost.java (2 hunks)
  • src/main/java/net/id/paradiselost/blocks/ParadiseLostBlocks.java (4 hunks)
  • src/main/java/net/id/paradiselost/blocks/blockentity/ParadiseLostBlockEntityTypes.java (1 hunks)
  • src/main/java/net/id/paradiselost/blocks/blockentity/TreeTapBlockEntity.java (1 hunks)
  • src/main/java/net/id/paradiselost/blocks/mechanical/TreeTapBlock.java (1 hunks)
  • src/main/java/net/id/paradiselost/client/rendering/block/ParadiseLostBlockEntityRenderers.java (1 hunks)
  • src/main/java/net/id/paradiselost/client/rendering/block/TreeTapBlockEntityRenderer.java (1 hunks)
  • src/main/java/net/id/paradiselost/items/ParadiseLostItems.java (1 hunks)
  • src/main/java/net/id/paradiselost/recipe/ParadiseLostRecipeTypes.java (1 hunks)
  • src/main/java/net/id/paradiselost/recipe/TreeTapRecipe.java (1 hunks)
  • src/main/java/net/id/paradiselost/recipe/TreeTapRecipeSerializer.java (1 hunks)
Additional comments: 20
gradle.properties (1)
  • 8-13: The updates to loaderVersion, fabricApiVersion, and customportalapiVersion reflect newer versions of dependencies. Ensure compatibility with the Minecraft version and other dependencies.
src/main/java/net/id/paradiselost/client/rendering/block/ParadiseLostBlockEntityRenderers.java (1)
  • 14-16: Switching to BlockEntityRendererFactories.register for block entity types registration is in line with API updates. Ensure thorough testing to confirm renderers function as expected.
src/main/java/net/id/paradiselost/recipe/ParadiseLostRecipeTypes.java (1)
  • 28-30: The registration of the TREE_TAP_RECIPE_SERIALIZER and TREE_TAP_RECIPE_TYPE is implemented correctly. Ensure that the TREE_TAP_RECIPE_ID is unique and does not conflict with existing recipe IDs.
src/main/java/net/id/paradiselost/blocks/blockentity/ParadiseLostBlockEntityTypes.java (1)
  • 15-22: The addition and registration of the TREE_TAP block entity type are implemented correctly. Ensure that the ParadiseLostBlocks.TREE_TAP block is correctly defined and behaves as expected.
src/main/java/net/id/paradiselost/recipe/TreeTapRecipe.java (2)
  • 30-37: The implementation of the matches method in TreeTapRecipe correctly checks both the ingredient and the tapped block. This ensures that the recipe only matches under the correct conditions.
  • 39-42: The craft method in TreeTapRecipe properly returns a copy of the output item stack, ensuring that the original recipe output is not modified.
src/main/java/net/id/paradiselost/recipe/TreeTapRecipeSerializer.java (1)
  • 20-28: The serialization logic in TreeTapRecipeSerializer correctly handles the recipe's group, ingredient, tapped block, and output. Ensure that serialization and deserialization are thoroughly tested, especially the handling of NBT data in the output item stack.
src/main/java/net/id/paradiselost/blocks/blockentity/TreeTapBlockEntity.java (3)
  • 47-52: The handleUse method correctly implements the logic for swapping items between the player's hand and the block entity's inventory. This interaction is essential for the block's functionality.
  • 81-100: The tryCraft method implements the crafting logic for the TreeTap block entity, checking for a matching recipe and handling the crafting result. Ensure that this logic is tested thoroughly, especially the handling of item scattering when the inventory is not empty.
  • 64-75: NBT read and write methods are correctly implemented for serializing and deserializing the block entity's inventory. This is crucial for preserving the block entity's state across game sessions.
src/main/java/net/id/paradiselost/blocks/mechanical/TreeTapBlock.java (3)
  • 47-54: The interaction handling in TreeTapBlock correctly allows for item swapping with the block entity when the player is not sneaking. This interaction is key to the block's functionality.
  • 61-71: The block placement logic in TreeTapBlock ensures that the block can only be placed with a horizontal facing and on a solid support. This is important for maintaining the block's intended behavior and appearance.
  • 103-110: The random tick behavior in TreeTapBlock triggers the crafting logic, adding a dynamic element to the block's functionality. Ensure that this behavior is tested to confirm it works as intended and does not introduce any unintended effects.
build.gradle.kts (1)
  • 49-52: The addition of the "Ladysnake" Maven repository is correctly configured. Ensure that the repository is trusted and that its dependencies are necessary for the project.
src/main/java/net/id/paradiselost/ParadiseLost.java (2)
  • 29-29: The import statement for ParadiseLostRecipeTypes is correctly added to support the new feature's initialization. Good practice to keep imports organized and relevant to the changes.
  • 93-93: The addition of ParadiseLostRecipeTypes.init(); correctly initializes the new recipe types for the Treetap block. Ensure that all dependencies, especially those related to the Treetap block, are initialized in the correct order to avoid any runtime issues.
src/main/java/net/id/paradiselost/blocks/ParadiseLostBlocks.java (3)
  • 8-25: The addition of import statements for various blocks, including TreeTapBlock, ParadiseLostGrassBlock, ParadiseLostSaplingBlock, and others, indicates the introduction of new block types to the game. This aligns with the PR's objective to enhance the game's mechanics and interactive features.
  • 58-58: The method signature change from protected static to public static for the unbreakable method increases its accessibility. This change could be intended to allow more extensive use across the codebase, potentially by other classes or packages that deal with unbreakable blocks. However, it's essential to ensure that this increased accessibility does not inadvertently expose or allow modification of game mechanics that should remain internal or controlled.

Consider reviewing the usage of the unbreakable method across the project to ensure that its new public access level is appropriately utilized and does not introduce any unintended side effects.

  • 392-392: The addition of the TreeTapBlock with properties such as .strength(2.5f) and .sounds(BlockSoundGroup.WOOD) is consistent with the PR's objective to introduce a new block type that enhances the game's interactive features. The use of .nonOpaque() and .ticksRandomly() suggests that the block has specific behavior regarding visibility and random tick updates, which could be related to the fluid collection mechanism discussed in the PR comments.

Ensure that the TreeTapBlock's behavior, especially regarding the time delay mechanism for fluid collection, is thoroughly tested under various game settings to address the concerns raised in the PR comments.

src/main/java/net/id/paradiselost/items/ParadiseLostItems.java (1)
  • 178-178: The addition of the TREE_TAP block item is consistent with the PR objectives and follows the established pattern for adding new items in this class. The use of the misc settings group and the fuel(300) action suggests that this item is categorized correctly and has a fuel value, which could be relevant for gameplay mechanics involving combustion or crafting.

One thing to consider is whether the TREE_TAP item has any specific interactions or properties that are not covered by the standard BlockItem class. If so, it might be beneficial to create a custom item class for TREE_TAP to encapsulate these behaviors. This would enhance maintainability and clarity, especially if future enhancements to the Treetap functionality are planned.

@DaFuqs
Copy link
Contributor Author

DaFuqs commented Mar 11, 2024 via email

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b3bbc1d and 694e56b.
Files ignored due to path filters (1)
  • config/checkstyle/checkstyle.xml is excluded by: !**/*.xml
Files selected for processing (4)
  • src/main/java/net/id/paradiselost/blocks/blockentity/TreeTapBlockEntity.java (1 hunks)
  • src/main/java/net/id/paradiselost/blocks/mechanical/TreeTapBlock.java (1 hunks)
  • src/main/java/net/id/paradiselost/client/rendering/block/ParadiseLostBlockEntityRenderers.java (1 hunks)
  • src/main/java/net/id/paradiselost/recipe/TreeTapRecipe.java (1 hunks)
Files skipped from review as they are similar to previous changes (4)
  • src/main/java/net/id/paradiselost/blocks/blockentity/TreeTapBlockEntity.java
  • src/main/java/net/id/paradiselost/blocks/mechanical/TreeTapBlock.java
  • src/main/java/net/id/paradiselost/client/rendering/block/ParadiseLostBlockEntityRenderers.java
  • src/main/java/net/id/paradiselost/recipe/TreeTapRecipe.java

@MBatt1 MBatt1 merged commit 533767f into devs-immortal:2.1.0/1.19.2/master Mar 11, 2024
2 checks passed
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.

None yet

2 participants