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

Prop Bop #555

Open
wants to merge 9 commits into
base: next
Choose a base branch
from
Open

Prop Bop #555

wants to merge 9 commits into from

Conversation

strubium
Copy link
Contributor

📝 Description

Greatly improves the current props. Also adds the basics of support more than one AABB.

🎯 Goals

  • Port some stuff from Props refresh #341
    • Icons for all props
    • Rotated icon for rotated props (Now its own image that we can layer)
  • Make it easier to work with AABBs
    • Just add withBoundingBox() and CustomTileEntityBlock will rotate it for you

❌ Non Goals

  • Remake models
  • Add new props
  • Remove LootBoxConfiguration

🚦 Testing

Build mod, join world, observe new props

⏮️ Backwards Compatibility

No issues with old saves

📚 Related Issues & Documents

#341

🖼️ Screenshots/Recordings

image

📖 Added to documentation?

  • 📜 README.md
  • 📑 Documentation
  • 📓 Javadoc
  • 🍕 Comments
  • 🙅 No documentation needed

Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces significant updates to the Modern Warfare Cubed project, including a comprehensive rework of tooltips for weapons and attachments, new translations, and sound effects. It modifies existing functionalities such as fire mode hints and ammunition counters, aligns reloading mechanics with vanilla behavior, and overhauls textures and models. The internal structure is refined with updates to dependencies and build scripts. Several unused features are removed, and optimizations are made to enhance performance. Additionally, various fixes are implemented to address issues in crafting mappings and state management.

Changes

File Path Change Summary
Changelog.md Updated to reflect changes in version 0.2, including tooltip reworks, new translations, and sound effects.
src/main/java/com/paneedah/mwc/creativetab/PropsTab.java Updated createIcon method to use dynamic item retrieval from the registry instead of hardcoding.
src/main/java/com/paneedah/mwc/equipment/Backpacks.java Removed static item declarations for backpacks; now instantiated directly in createEquipment.
src/main/java/com/paneedah/mwc/tileentities/TileEntities.java Simplified bounding box definitions for loot boxes by using static AxisAlignedBB values.
src/main/java/com/paneedah/mwc/tileentities/TurretBaseFactory.java Updated bounding box definition in createTileEntity to use AxisAlignedBB.
src/main/java/com/paneedah/weaponlib/tile/CustomTileEntity.java Added Lombok annotations for automatic getter/setter generation for side field.
src/main/java/com/paneedah/weaponlib/tile/CustomTileEntityBlock.java Changed customBoundingBox to a list of bounding boxes; updated methods to handle multiple bounding boxes.
src/main/java/com/paneedah/weaponlib/tile/CustomTileEntityClassFactory.java Added Lombok @Getter annotation for static instance variable.
src/main/java/com/paneedah/weaponlib/tile/CustomTileEntityConfiguration.java Updated bounding box handling to support multiple bounding boxes; improved method signatures.
src/main/java/com/paneedah/weaponlib/tile/LootBoxConfiguration.java Enhanced visibility of fields with @Getter; updated sound event fields and method signatures for safety.
src/main/java/com/paneedah/weaponlib/tile/LootBoxTileEntity.java Modified dropContents method to change how equipment options and sound events are retrieved.
src/main/resources/assets/mwc/lang/en_US.lang Updated localization entries for consistency in naming conventions and added new items.

Possibly related PRs

Suggested labels

Enhancement, Optimization, Productivity

Suggested reviewers

  • Desoroxxx

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. This feature will be included in our Pro Plan when released.


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 2

🧹 Outside diff range and nitpick comments (10)
src/main/java/com/paneedah/weaponlib/tile/CustomTileEntityBlock.java (4)

33-33: Prefer using List over ArrayList in field declaration

It's recommended to use the List interface instead of the concrete implementation ArrayList for the customBoundingBoxes field. This promotes abstraction and allows for flexibility in changing the underlying list implementation without affecting the rest of the code.

Apply this diff to update the field declaration:

-private Function<IBlockState, ArrayList<AxisAlignedBB>> customBoundingBoxes;
+private Function<IBlockState, List<AxisAlignedBB>> customBoundingBoxes;

45-46: Update parameter type to List in setBoundingBoxes method

For consistency and abstraction, consider changing the parameter type of the setBoundingBoxes method to Function<IBlockState, List<AxisAlignedBB>>.

Apply this diff to update the method signature:

-public void setBoundingBoxes(Function<IBlockState, ArrayList<AxisAlignedBB>> customBoundingBoxes) {
+public void setBoundingBoxes(Function<IBlockState, List<AxisAlignedBB>> customBoundingBoxes) {
     this.customBoundingBoxes = customBoundingBoxes;
 }

51-76: Refactor getBoundingBox method to reduce nested complexity

The getBoundingBox method has a nested complexity depth of 4, which can impact readability and maintainability. Consider refactoring to reduce nesting by extracting parts of the logic into helper methods or simplifying conditional structures.

One possible refactor is to extract the inner loop into a separate method:

 public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
     if (customBoundingBoxes != null) {
         EnumFacing facing = state.getValue(FACING);
         List<AxisAlignedBB> boundingBoxes = customBoundingBoxes.apply(state);
-        if (!boundingBoxes.isEmpty()) {
-            AxisAlignedBB combinedBoundingBox = null;
-            for (AxisAlignedBB boundingBox : boundingBoxes) {
-                AxisAlignedBB orientedBoundingBox = AABBUtil.orientAABB(facing, boundingBox);
-                if (combinedBoundingBox == null) {
-                    combinedBoundingBox = orientedBoundingBox;
-                } else {
-                    combinedBoundingBox = combinedBoundingBox.union(orientedBoundingBox);
-                }
-            }
-            return combinedBoundingBox != null ? combinedBoundingBox : super.getBoundingBox(state, source, pos);
-        }
+        AxisAlignedBB combinedBoundingBox = getCombinedBoundingBox(boundingBoxes, facing);
+        return combinedBoundingBox != null ? combinedBoundingBox : super.getBoundingBox(state, source, pos);
     }
     return super.getBoundingBox(state, source, pos);
 }
+
+private AxisAlignedBB getCombinedBoundingBox(List<AxisAlignedBB> boundingBoxes, EnumFacing facing) {
+    if (boundingBoxes.isEmpty()) {
+        return null;
+    }
+    AxisAlignedBB combinedBoundingBox = null;
+    for (AxisAlignedBB boundingBox : boundingBoxes) {
+        AxisAlignedBB orientedBoundingBox = AABBUtil.orientAABB(facing, boundingBox);
+        if (combinedBoundingBox == null) {
+            combinedBoundingBox = orientedBoundingBox;
+        } else {
+            combinedBoundingBox = combinedBoundingBox.union(orientedBoundingBox);
+        }
+    }
+    return combinedBoundingBox;
+}
🧰 Tools
🪛 GitHub Check: CodeScene Cloud Delta Analysis (next)

[warning] 51-76: ❌ New issue: Deep, Nested Complexity
getBoundingBox has a nested complexity depth of 4, threshold = 4. This function contains deeply nested logic such as if statements and/or loops. The deeper the nesting, the lower the code health.


153-153: Use TextComponentTranslation for localization support

Consider using TextComponentTranslation instead of TextComponentString to allow the message to be localized, improving internationalization support.

Apply this diff to update the message:

-placer.sendMessage(new TextComponentString("Invalid damage property. Please pick in [0, 1, 2]"));
+placer.sendMessage(new TextComponentTranslation("message.invalid_damage_property"));

Ensure that the key "message.invalid_damage_property" is defined in the localization files with the appropriate translation.

src/main/java/com/paneedah/mwc/equipment/Backpacks.java (2)

53-59: Consider adding inventory positioning for consistency.

Several backpack builders lack inventory positioning configurations that are present in other backpacks. This inconsistency might affect how these backpacks are displayed in the inventory.

Consider adding inventory positioning similar to the combat sustainment backpack:

 new ItemBackpack.Builder()
     .withName("assault_backpack_tan")
     .withSize(16)
     .withModel("AssaultBackpack")
     .withTexture("equipment/carryable/backpacks/assault_backpack_tan")
+    .withInventoryPositioning(() -> new Transform()
+        .withPosition(-0.15F, -4.6F, 0.35F)
+        .withRotation(18, -50, 0)
+        .withScale(3.3F, 3.3F, 3.3F)
+        .applyTransformations())
     .build();

Also applies to: 60-66, 67-73, 74-80, 81-87, 88-94, 95-101


Line range hint 12-101: Document backpack size differences.

Different backpack types have varying sizes (10, 16, 20, 24 slots) which might not be immediately obvious to players or other developers.

Consider adding class-level documentation explaining the size tiers and their purpose:

+/**
+ * Backpack configurations with different storage capacities:
+ * - Combat Sustainment Backpack: 10 slots (Basic)
+ * - Assault Backpack: 16 slots (Medium)
+ * - TruSpec Cordura Backpack: 20 slots (Large)
+ * - Duffle Bag: 24 slots (Extra Large)
+ */
 public class Backpacks {
src/main/java/com/paneedah/weaponlib/tile/CustomTileEntityConfiguration.java (1)

88-102: Consider adding parameter validation.

While the implementation is good, consider adding validation:

  1. Add null check for the AxisAlignedBB parameter
  2. Validate that dimensions are non-negative
 public T withBoundingBox(double x1, double y1, double z1, double x2, double y2, double z2) {
+    if (x2 < x1 || y2 < y1 || z2 < z1) {
+        throw new IllegalArgumentException("Invalid bounding box dimensions");
+    }
     boundingBoxes.add(new AxisAlignedBB(x1, y1, z1, x2, y2, z2));
     return safeCast(this);
 }

 public T withBoundingBox(AxisAlignedBB axisAlignedBB) {
+    if (axisAlignedBB == null) {
+        throw new IllegalArgumentException("AxisAlignedBB cannot be null");
+    }
     boundingBoxes.add(axisAlignedBB);
     return safeCast(this);
 }
Changelog.md (1)

65-80: Remove duplicate entries in the props list.

The following entries appear to be duplicated:

  • "Gravestone Cross" appears multiple times with different ALT variations
  • "Spooky Ghost" appears multiple times with different ALT variations

Consider consolidating these entries to improve readability:

- Gravestone Cross
- Gravestone Cross (ALT 1)
- Gravestone Cross (ALT 2)
+ Gravestone Cross (including ALT 1 & 2 variants)

- Spooky Ghost
- Spooky Ghost (ALT 1)
- Spooky Ghost (ALT 2)
+ Spooky Ghost (including ALT 1 & 2 variants)
🧰 Tools
🪛 LanguageTool

[duplication] ~66-~66: Possible typo: you repeated a word
Context: ...dded icons for the following props: - Gravestone - Gravestone Skull - Gravestone Cross - Gravesto...

(ENGLISH_WORD_REPEAT_RULE)


[grammar] ~68-~68: This phrase is duplicated. You should probably use “Gravestone Cross” only once.
Context: ... - Gravestone - Gravestone Skull - Gravestone Cross - Gravestone Cross (ALT 1) - Gravestone Cross (ALT 2) ...

(PHRASE_REPETITION)


[duplication] ~71-~71: Possible typo: you repeated a word
Context: ...ALT 1) - Gravestone Cross (ALT 2) - Sandbag - Sandbag Wall - Spooky Ghost - Spooky Ghost ...

(ENGLISH_WORD_REPEAT_RULE)


[grammar] ~73-~73: This phrase is duplicated. You should probably use “Spooky Ghost” only once.
Context: ...ALT 2) - Sandbag - Sandbag Wall - Spooky Ghost - Spooky Ghost (ALT 1) - Spooky Ghost (ALT 2) - To...

(PHRASE_REPETITION)

src/main/java/com/paneedah/mwc/tileentities/TileEntities.java (2)

20-20: Consider extracting common bounding box dimensions into constants.

Many tile entities use similar bounding box dimensions. Consider extracting these into constants for better maintainability:

+private static final AxisAlignedBB FULL_BLOCK_AABB = new AxisAlignedBB(0, 0, 0, 1, 1, 1);
+private static final AxisAlignedBB HALF_HEIGHT_AABB = new AxisAlignedBB(0, 0, 0, 1, 0.5, 1);
+private static final AxisAlignedBB CHAIR_HEIGHT_AABB = new AxisAlignedBB(0, 0, 0, 1, 0.7, 1);

Then use these constants:

-withBoundingBox(new AxisAlignedBB(0, 0, 0, 1, 1, 1))
+withBoundingBox(FULL_BLOCK_AABB)

Also applies to: 34-34, 48-48, 62-62, 90-90, 104-104, 146-146, 160-160, 174-174, 229-229, 312-312, 327-327, 369-369, 384-384, 502-502, 529-529, 581-581, 595-595, 609-609, 624-624, 859-859, 938-938, 991-991, 1109-1109, 1123-1123, 1137-1137, 1150-1150, 1163-1163, 1177-1177, 1190-1190, 1204-1204, 1232-1232, 1325-1325

🧰 Tools
🪛 GitHub Check: CodeScene Cloud Delta Analysis (next)

[notice] 20-1325: ✅ Getting better: Large Method
createTileEntity decreases from 1412 to 1269 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.


581-586: Adjust body bag positioning for better alignment.

The body bag's bounding box and positioning seem slightly misaligned:

  • Bounding box is full width (0 to 1)
  • But scale is 0.9 and translation is offset
    Consider adjusting the bounding box to match the visual model more precisely.
-withBoundingBox(new AxisAlignedBB(0, 0, 0, 1, 0.4, 1))
+withBoundingBox(new AxisAlignedBB(0.1, 0, 0.1, 0.9, 0.4, 0.9))
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 891ff57 and c42a734.

⛔ Files ignored due to path filters (39)
  • src/main/resources/assets/mwc/models/item/barrier_rotated.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/crossgravestone.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/crossgravestone2.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/crossgravestone3.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/gravestone.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/gravestoneskull.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/home_chair_rotated.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/outdoor_chair_rotated.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/propanetank.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/radio_rotated.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/sandbag.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/sandbagwall.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/scarecrow.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/serverrackleftalt3.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/spookyghost.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/spookyghost2.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/spookyghost3.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/swat_truck.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/models/item/towablefloodlight.json is excluded by !**/*.json
  • src/main/resources/assets/mwc/textures/items/barrier_rotated.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/gravestone.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/gravestone_cross.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/gravestone_cross_2.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/gravestone_cross_3.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/gravestone_skull.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/home_chair_rotated.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/outdoor_chair_rotated.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/prop_rotated.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/propane_tank.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/radio_rotated.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/sandbag.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/sandbag_wall.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/scarecrow.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/server_rack_left_alt_3.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/spooky_ghost.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/spooky_ghost_2.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/spooky_ghost_3.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/swat_truck.png is excluded by !**/*.png, !**/*.png
  • src/main/resources/assets/mwc/textures/items/towable_floodlight.png is excluded by !**/*.png, !**/*.png
📒 Files selected for processing (12)
  • Changelog.md (2 hunks)
  • src/main/java/com/paneedah/mwc/creativetab/PropsTab.java (2 hunks)
  • src/main/java/com/paneedah/mwc/equipment/Backpacks.java (4 hunks)
  • src/main/java/com/paneedah/mwc/tileentities/TileEntities.java (33 hunks)
  • src/main/java/com/paneedah/mwc/tileentities/TurretBaseFactory.java (2 hunks)
  • src/main/java/com/paneedah/weaponlib/tile/CustomTileEntity.java (2 hunks)
  • src/main/java/com/paneedah/weaponlib/tile/CustomTileEntityBlock.java (4 hunks)
  • src/main/java/com/paneedah/weaponlib/tile/CustomTileEntityClassFactory.java (2 hunks)
  • src/main/java/com/paneedah/weaponlib/tile/CustomTileEntityConfiguration.java (6 hunks)
  • src/main/java/com/paneedah/weaponlib/tile/LootBoxConfiguration.java (5 hunks)
  • src/main/java/com/paneedah/weaponlib/tile/LootBoxTileEntity.java (2 hunks)
  • src/main/resources/assets/mwc/lang/en_US.lang (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/main/resources/assets/mwc/lang/en_US.lang
🧰 Additional context used
🪛 GitHub Check: CodeScene Cloud Delta Analysis (next)
src/main/java/com/paneedah/mwc/tileentities/TileEntities.java

[notice] 20-1325: ✅ Getting better: Large Method
createTileEntity decreases from 1412 to 1269 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.


[notice] 20-1325: ✅ Getting better: Large Method
createTileEntity decreases from 1412 to 1269 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.

src/main/java/com/paneedah/weaponlib/tile/CustomTileEntityBlock.java

[warning] 51-76: ❌ New issue: Deep, Nested Complexity
getBoundingBox has a nested complexity depth of 4, threshold = 4. This function contains deeply nested logic such as if statements and/or loops. The deeper the nesting, the lower the code health.

🪛 LanguageTool
Changelog.md

[duplication] ~66-~66: Possible typo: you repeated a word
Context: ...dded icons for the following props: - Gravestone - Gravestone Skull - Gravestone Cross - Gravesto...

(ENGLISH_WORD_REPEAT_RULE)


[grammar] ~68-~68: This phrase is duplicated. You should probably use “Gravestone Cross” only once.
Context: ... - Gravestone - Gravestone Skull - Gravestone Cross - Gravestone Cross (ALT 1) - Gravestone Cross (ALT 2) ...

(PHRASE_REPETITION)


[duplication] ~71-~71: Possible typo: you repeated a word
Context: ...ALT 1) - Gravestone Cross (ALT 2) - Sandbag - Sandbag Wall - Spooky Ghost - Spooky Ghost ...

(ENGLISH_WORD_REPEAT_RULE)


[grammar] ~73-~73: This phrase is duplicated. You should probably use “Spooky Ghost” only once.
Context: ...ALT 2) - Sandbag - Sandbag Wall - Spooky Ghost - Spooky Ghost (ALT 1) - Spooky Ghost (ALT 2) - To...

(PHRASE_REPETITION)

🔇 Additional comments (11)
src/main/java/com/paneedah/mwc/tileentities/TurretBaseFactory.java (3)

7-7: LGTM! Import addition is appropriate.

The explicit import of AxisAlignedBB aligns with the PR's goal of improving AABB support.


Line range hint 21-23: Verify if the commented GL transformations are still needed.

There are commented-out GL transformations for scaling and rotation. Given that the PR mentions support for rotated props, we should verify if these transformations are still relevant.

Let's check for similar patterns in other prop configurations:


19-19: Verify collision behavior with the 0.2 height bounding box.

The change to use AxisAlignedBB is good and aligns with the PR objectives. However, the low height (0.2) of the bounding box might affect player interaction or collision detection.

Let's check if other turret bases use similar dimensions:

✅ Verification successful

Bounding box height of 0.2 is consistent with other base entities

The height of 0.2 for the turret base's bounding box is appropriate and consistent with similar entities in the codebase:

  • Other flat/base entities use similar low heights:
    • Another turret base uses exactly 0.2 height: new AxisAlignedBB(0, 0, 0, 1, 0.2, 1)
    • Ammo press base uses 0.2 height: COLLISION_BOX_BOTTOM = new AxisAlignedBB(0.1D, 0.0D, 0.1D, 0.9D, 0.2D, 0.9D)
    • Various other base entities use heights between 0.2-0.5 for their collision boxes

The low height is intentional for base components and won't negatively impact collision detection.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other turret-related bounding box definitions
rg -A 2 "withBoundingBox.*turret" 

Length of output: 35


Script:

#!/bin/bash
# Let's search for all bounding box definitions to understand the common patterns
rg -A 2 "withBoundingBox\(" 

# Also search for any AxisAlignedBB usage
rg -A 2 "AxisAlignedBB\("

Length of output: 43624

src/main/java/com/paneedah/weaponlib/tile/CustomTileEntity.java (1)

20-20: Use of Lombok annotations for getter and setter

The application of @Getter and @Setter annotations on the side field effectively reduces boilerplate code and improves readability. Ensure that Lombok is properly configured in the project's build process.

src/main/java/com/paneedah/weaponlib/tile/CustomTileEntityClassFactory.java (1)

35-35: Adding Lombok @Getter for the instance field

Using @Getter on the instance field simplifies access to the singleton instance of CustomTileEntityClassFactory. Ensure that Lombok is properly set up in the project to generate the necessary methods.

src/main/java/com/paneedah/weaponlib/tile/LootBoxTileEntity.java (2)

45-45: Sound handling improvements look good.

The changes to use dedicated sound event getters improve code clarity and maintain consistency with the configuration class.

Also applies to: 69-69


41-43: Verify logging level change impact.

The change from info to debug logging level might affect troubleshooting in production environments.

✅ Verification successful

Let me gather more context about the logging patterns in this codebase.


Based on the analysis of the logging patterns in the codebase:

Logging level change is appropriate

The change from info to debug for item dropping is consistent with the codebase's logging patterns:

  • Debug level is used throughout the codebase for similar operational events (state changes, transitions, etc.)
  • Info level is primarily used for registration and initialization events
  • Error/warn levels are properly used for actual issues and warnings

The change aligns with standard logging practices where:

  • Debug = Detailed information for debugging
  • Info = Notable but normal operations
  • Warn/Error = Issues requiring attention
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if debug logging is used elsewhere for similar operations
rg "LOGGER\.(debug|info)\s*\(\s*\"Dropping" -A 2

Length of output: 416


Script:

#!/bin/bash
# Check overall logging patterns in the codebase
rg "LOGGER\.(debug|info|warn|error)" -A 1

# Also check if this logger is a static field
ast-grep --pattern 'private static final Logger LOGGER'

Length of output: 110042

src/main/java/com/paneedah/weaponlib/tile/LootBoxConfiguration.java (2)

6-7: Good use of Lombok for reducing boilerplate.

The addition of Lombok annotations improves code maintainability by reducing boilerplate getter methods.

Also applies to: 97-97, 99-99, 104-105


173-174: Verify sound registration across the mod.

Ensure that the sound registration is consistent with other sound events in the mod.

✅ Verification successful

Sound registration is consistent across the mod

The sound registration pattern in LootBoxConfiguration.java follows the same consistent pattern used throughout the codebase:

  • All sound registrations use modContext.registerSound() or context.registerSound()
  • Sound events are properly stored in private SoundEvent fields
  • Registration happens during initialization/configuration phase

The implementation aligns with other sound registrations found in:

  • Weapons (Weapon.java)
  • Vehicles (EntityVehicleConfiguration.java, GeneralVehicleSounds.java)
  • Grenades (ItemGrenade.java)
  • Armor (CustomArmor.java)
  • Melee weapons (ItemMelee.java)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check sound registration patterns across the codebase
rg "registerSound\(" -A 1

# Check sound event field declarations
ast-grep --pattern 'private SoundEvent $name;'

Length of output: 24966

src/main/java/com/paneedah/weaponlib/tile/CustomTileEntityConfiguration.java (1)

18-19: LGTM! Good initialization of the bounding boxes collection.

The changes properly introduce support for multiple bounding boxes with appropriate imports and field initialization.

Also applies to: 38-38

src/main/java/com/paneedah/mwc/tileentities/TileEntities.java (1)

Line range hint 1325-1330: Verify the tall bounding box for the scarecrow.

The scarecrow's bounding box height of 3.5 blocks seems unusually tall and might cause issues with player interaction or collision detection. Consider verifying if this height is intentional and necessary.

✅ Verification successful

These commands will help us understand:

  1. Other bounding box dimensions in the codebase for comparison
  2. Locate scarecrow-related files for context
  3. Find any explicit height configurations for the scarecrow

The scarecrow's height of 3.5 blocks is intentionally tall and consistent with its purpose.

Looking at the bounding boxes across the codebase:

  • Most decorative objects have heights between 0.2 to 1.0 blocks
  • Only two entities have notably tall bounding boxes:
    • Impaled body at 2.8 blocks
    • Scarecrow at 3.5 blocks

The scarecrow's height is appropriate because:

  1. Scarecrows are traditionally tall structures meant to be visible from a distance
  2. The narrow width (0.3 to 0.7) balances the height, creating a pole-like structure
  3. The model's texture height of 150 pixels supports the tall design
  4. The 1:1 scale factor in positioning (glScalef(1f, 1f, 1f)) confirms the intended size
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for other tall entities in the codebase for comparison
ast-grep --pattern 'withBoundingBox($$$new AxisAlignedBB($_, $_, $_, $_, $height, $_)$$$)' | grep -B 2 -A 2 'height.*[2-9]'

Length of output: 125


Script:

#!/bin/bash
# Search for bounding box definitions with specific focus on height values
rg -B 2 -A 2 "AxisAlignedBB.*\d+\.\d+" src/

Length of output: 19353


Script:

#!/bin/bash
# Look for scarecrow-related files and configurations
fd scarecrow -t f

Length of output: 248


Script:

#!/bin/bash
# Search for any model or entity height configurations
rg -i "height|tall" src/ | grep -i "scarecrow"

Length of output: 128

Copy link

github-actions bot commented Dec 10, 2024

Qodana for JVM

6 new problems were found

Inspection name Severity Problems
Auto-boxing 🔶 Warning 1
Nullability and data flow problems 🔶 Warning 1
Field may be 'final' 🔶 Warning 1
Unchecked warning 🔶 Warning 1
Unused import 🔶 Warning 1
Non-constant string concatenation as argument to logging call ◽️ Notice 1

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

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 comments (2)
src/main/java/com/paneedah/mwc/tileentities/TileEntities.java (2)

Line range hint 859-864: Fix incorrect bounding box offset for white_desk_middle

The bounding box starts at Y=0.5, which creates a floating collision box. This could cause gameplay issues where items fall through the top half of the desk.

-.withBoundingBox(new AxisAlignedBB(0, 0.5, 0, 1, 1, 1))
+.withBoundingBox(new AxisAlignedBB(0, 0, 0, 1, 0.8, 1))

Line range hint 624-629: Fix asymmetric bounding box for dumpster

The bounding box extends into negative X coordinates (-1 to 1) while maintaining standard Z coordinates (0 to 1). This asymmetry could cause:

  1. Collision detection issues
  2. Unexpected behavior when placing the dumpster
  3. Problems with adjacent block interactions
-.withBoundingBox(new AxisAlignedBB(-1, 0, 0, 1, 1, 1))
+.withBoundingBox(new AxisAlignedBB(0, 0, 0, 1, 1, 1))
🧹 Nitpick comments (3)
src/main/java/com/paneedah/mwc/tileentities/TileEntities.java (3)

1133-1136: Inconsistent naming convention for flood light variants

The naming convention is inconsistent between flood light variants:

  • "duelfloodlight" uses lowercase and no spacing
  • "floodLight" uses camelCase

Standardize the naming convention. Suggest using camelCase for all variants:

-.withName("duelfloodlight")
+.withName("dualFloodLight")

Also applies to: 1146-1149


Line range hint 1-1400: Consider implementing support for multiple AABBs

The PR objectives mention adding support for multiple Axis-Aligned Bounding Boxes (AABBs), but the current implementation only uses single AABB instances. This could limit the accuracy of collision detection for complex props.

Consider:

  1. Extending LootBoxConfiguration to support multiple bounding boxes
  2. Adding a method like withBoundingBoxes(List<AxisAlignedBB>)
  3. Implementing compound collision detection for props with complex shapes

This would improve collision accuracy for props like:

  • The forklift (which has a mast and forks)
  • The server racks (which have protruding components)
  • The vending machine (which has a dispensing area)

Line range hint 1-1400: Reduce code duplication in prop configurations

There's significant duplication in the prop configurations, particularly in:

  • Material definitions
  • Creative tab assignments
  • Scale and rotation transformations

Consider introducing factory methods or builder patterns to reduce duplication:

public class PropConfigurationFactory {
    public static LootBoxConfiguration createStandardProp(String name, String modelClass) {
        return new LootBoxConfiguration()
            .withMaterial(Material.IRON)
            .withCreativeTab(MWC.PROPS_TAB)
            .withName(name)
            .withModelClassName(modelClass);
    }
    
    public static LootBoxConfiguration createRotatedProp(String name, String modelClass) {
        return createStandardProp(name, modelClass)
            .withPositioning(tileEntity -> {
                GL11.glScalef(1f, 1f, 1f);
                GL11.glTranslatef(0.5f, 0f, 0.5f);
                GL11.glRotatef(-90F, 0f, 1f, 0f);
            });
    }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c42a734 and 9fd7891.

📒 Files selected for processing (1)
  • src/main/java/com/paneedah/mwc/tileentities/TileEntities.java (34 hunks)

Comment on lines +581 to +584
.withBoundingBox(new AxisAlignedBB(0, 0, 0, 1, 0.4, 1))
.withPositioning(tileEntity -> {
GL11.glScalef(0.9f, 0.9f, 0.9f);
GL11.glTranslatef(0.5f, -0.9f, 0.55f);
GL11.glTranslatef(0.5f, 0.1f, 0.55f);
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

Adjust bounding box height for body_bag

The current bounding box height of 0.4 blocks seems too high for a body bag that should be relatively flat on the ground. Consider reducing the height to improve realism and prevent floating effects.

-.withBoundingBox(new AxisAlignedBB(0, 0, 0, 1, 0.4, 1))
+.withBoundingBox(new AxisAlignedBB(0, 0, 0, 1, 0.2, 1))
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.withBoundingBox(new AxisAlignedBB(0, 0, 0, 1, 0.4, 1))
.withPositioning(tileEntity -> {
GL11.glScalef(0.9f, 0.9f, 0.9f);
GL11.glTranslatef(0.5f, -0.9f, 0.55f);
GL11.glTranslatef(0.5f, 0.1f, 0.55f);
.withBoundingBox(new AxisAlignedBB(0, 0, 0, 1, 0.2, 1))
.withPositioning(tileEntity -> {
GL11.glScalef(0.9f, 0.9f, 0.9f);
GL11.glTranslatef(0.5f, 0.1f, 0.55f);

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.

1 participant