devs-immortal / Paradise-Lost

Paradise awaits...
https://immortaldevs.net/paradise-lost/
MIT License
199 stars 43 forks source link

Added Treetap #775

Closed DaFuqs closed 6 months ago

DaFuqs commented 1 year ago

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

Further Ideas:

Summary by CodeRabbit

DaFuqs commented 1 year ago

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 commented 1 year ago

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

coderabbitai[bot] commented 6 months ago

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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

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 .` - `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](https://coderabbit.ai/integrations/coderabbit-overrides.v2.json). - 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](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback.
DaFuqs commented 6 months ago

Dafuq

coderabbitai[bot] @.***> schrieb am Mo., 11. März 2024, 18:55:

@.**[bot] requested changes on this pull request. Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI Commits Files that changed from the base of the PR and between f6ad972 https://github.com/devs-immortal/Paradise-Lost/commit/f6ad972211fcedbe651a3d241bdef20e36fe8288 and b3bbc1d https://github.com/devs-immortal/Paradise-Lost/commit/b3bbc1dd21d69bc485bb776b6c2411a850016b5b. 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.


In src/main/java/net/id/paradiselost/client/rendering/block/TreeTapBlockEntityRenderer.java https://github.com/devs-immortal/Paradise-Lost/pull/775#discussion_r1520182943 :

  • @Override
  • public void render(TreeTapBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
  • if (!entity.isEmpty()) {
  • matrices.push();
  • // todo: rotate along facing axis
  • matrices.translate(0.5, 0.4, 0.5);
  • matrices.scale(0.75F, 0.75F, 0.75F);
  • MinecraftClient.getInstance().getItemRenderer().renderItem(entity.getStack(0), ModelTransformation.Mode.FIXED, light, overlay, matrices, vertexConsumers, 0);
  • matrices.pop();
  • }
  • }

The rendering logic for the TreeTap block entity is implemented correctly. However, there's a TODO comment about rotating along the facing axis, which should be addressed to ensure the rendered item aligns properly with the block's orientation.

Would you like assistance in implementing the rotation logic?

— Reply to this email directly, view it on GitHub https://github.com/devs-immortal/Paradise-Lost/pull/775#pullrequestreview-1928645537, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGJUQSQYKGDQRKSNUWGTMMTYXXVZTAVCNFSM6AAAAAA4WVD6D6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTSMRYGY2DKNJTG4 . You are receiving this because you authored the thread.Message ID: @.***>