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 horse entity and bug fixes #278

Open
wants to merge 277 commits into
base: develop
Choose a base branch
from

Conversation

myiume
Copy link

@myiume myiume commented Dec 6, 2024

  • Fixed horse variant data missing tags and typo
  • Added horse entity

Related to: https://sharing.clickup.com/9015308602/v/6-901502296591-2/t/h/86c18junj/a4c4c9d59ec667d

Summary by CodeRabbit

  • New Features

    • Introduced the HorseDefinition and HorseInstance classes for better representation of horse entities.
    • Added tagging functionality for horse variant data, improving clarity.
  • Bug Fixes

    • Renamed entry identifier for horse variant data to enhance consistency.

Copy link
Contributor

coderabbitai bot commented Dec 6, 2024

Walkthrough

The pull request introduces changes to two primary files related to horse entities in the codebase. The HorseVariantData.kt file has been modified to improve the clarity of the entry identifier by renaming it and adding a tagging annotation. Additionally, the new HorseEntity.kt file introduces three classes: HorseDefinition, HorseInstance, and HorseEntity, which encapsulate the logic for defining and instantiating horse entities, including their properties and behaviors.

Changes

File Change Summary
extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/horse/HorseVariantData.kt - Renamed entry identifier from "horse_variant_dat" to "horse_variant_data" in @Entry annotation.
- Added @Tags("horse_variant_data") annotation.
extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/entity/minecraft/HorseEntity.kt - Added class HorseDefinition for horse entity definition.
- Added class HorseInstance for horse entity instances.
- Added class HorseEntity for entity handling.

Possibly related PRs

Poem

🐰 In the meadow where horses play,
A new name brightens the day.
With tags and definitions so neat,
Horse entities now can’t be beat!
Hops of joy, a leap and a bound,
In our code, new friends are found! 🐴✨


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>, please review it.
    • Generate unit testing code 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 testing code 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/entity/minecraft/HorseEntity.kt (1)

68-74: Consider logging unhandled EntityProperty types in applyProperty

In the when expression within applyProperty, unhandled EntityProperty types are silently ignored in the else branch. To improve maintainability and debugging, consider adding a log statement or handling mechanism to capture unexpected property types. This ensures all properties are appropriately addressed and aids in troubleshooting.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f0ff790 and 36c2635.

📒 Files selected for processing (2)
  • extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/horse/HorseVariantData.kt (2 hunks)
  • extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/entity/minecraft/HorseEntity.kt (1 hunks)
🔇 Additional comments (1)
extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/horse/HorseVariantData.kt (1)

16-17: Annotations updated appropriately for consistency

Renaming the entry identifier to "horse_variant_data" and adding the @Tags("horse_variant_data") annotation enhances clarity and ensures consistent tagging within the codebase.

- Added horse eating data
Copy link
Contributor

@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.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/entity/minecraft/HorseEntity.kt (2)

28-33: Documentation could be more descriptive

The current documentation is quite basic. Consider enhancing it with:

  • Available configuration options
  • Examples of usage
  • Description of each property's purpose

46-52: Fix incomplete documentation section

The "How could this be used?" section is empty. Consider adding:

  • Practical examples of instantiating a horse
  • Common configuration scenarios
  • Interaction with other components
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 36c2635 and 60586b5.

📒 Files selected for processing (1)
  • extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/entity/minecraft/HorseEntity.kt (1 hunks)
🔇 Additional comments (1)
extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/entity/minecraft/HorseEntity.kt (1)

39-40: Verify the completeness of allowed data tags

Let's verify that all necessary data tags are included in the @OnlyTags annotation.

✅ Verification successful

Let me gather more information about the data classes and their relationships.


Based on the gathered information, I can now provide the final response:

The @OnlyTags annotation includes all necessary data tags for the HorseEntity

The current set of tags ("generic_entity_data", "living_entity_data", "mob_data", "ageable_data", "horse_variant_data", "horse_data", "eating_data", "chested_horse_data") is complete and covers all the required data types for a horse entity, as evidenced by:

  • All horse-related data classes (HorseEatingData, HorseVariantData, ChestedHorseChestData) are covered
  • All hierarchical entity data tags (generic, living, mob, ageable) are included
  • All horse-specific behavior tags (variant, eating, chested) are present
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any other potential horse-related data tags in the codebase
rg -t kotlin "Tags\(.*horse.*\)" --no-filename | sort -u

# Search for any EntityData implementations that might be relevant
ast-grep --pattern 'class $_ : EntityData<$_>' 

Length of output: 548


Script:

#!/bin/bash
# Search for all data-related tags in the codebase
rg -t kotlin "@Tags\(.*\)" --no-filename | sort -u

# Look for horse-related entity data classes
rg -t kotlin "class.*Horse.*Data" -A 5

# Search for any EntityData implementations specifically for horses
ast-grep --pattern 'class $name : EntityData<$type> {
  $$$
}'

Length of output: 6825

Comment on lines +67 to +78
override fun applyProperty(property: EntityProperty) {
when (property) {
is AgeableProperty -> applyAgeableData(entity, property)
is HorseVariantProperty -> applyHorseVariantData(entity, property)
is ChestedHorseChestProperty -> applyChestedHorseChestData(entity, property)
is SaddledProperty -> applySaddledData(entity, property)
is EatingProperty -> applyHorseEatingData(entity, property)
else -> {}
}
if (applyGenericEntityData(entity, property)) return
if (applyLivingEntityData(entity, property)) return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve property handling robustness

Several concerns in the property application logic:

  1. Empty else block could silently ignore unknown properties
  2. Early returns after generic/living entity data application might prevent processing of other valid properties
  3. No error handling or logging for invalid properties

Consider this improved implementation:

 override fun applyProperty(property: EntityProperty) {
+    var handled = false
     when (property) {
-        is AgeableProperty -> applyAgeableData(entity, property)
-        is HorseVariantProperty -> applyHorseVariantData(entity, property)
-        is ChestedHorseChestProperty -> applyChestedHorseChestData(entity, property)
-        is SaddledProperty -> applySaddledData(entity, property)
-        is EatingProperty -> applyHorseEatingData(entity, property)
-        else -> {}
+        is AgeableProperty -> {
+            applyAgeableData(entity, property)
+            handled = true
+        }
+        is HorseVariantProperty -> {
+            applyHorseVariantData(entity, property)
+            handled = true
+        }
+        is ChestedHorseChestProperty -> {
+            applyChestedHorseChestData(entity, property)
+            handled = true
+        }
+        is SaddledProperty -> {
+            applySaddledData(entity, property)
+            handled = true
+        }
+        is EatingProperty -> {
+            applyHorseEatingData(entity, property)
+            handled = true
+        }
     }
-    if (applyGenericEntityData(entity, property)) return
-    if (applyLivingEntityData(entity, property)) return
+    handled = handled || applyGenericEntityData(entity, property) || applyLivingEntityData(entity, property)
+    
+    if (!handled) {
+        logger.warn("Unhandled property type: ${property::class.simpleName} for horse entity")
+    }
 }

Committable suggestion skipped: line range outside the PR's diff.

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.

5 participants