Skip to content

Conversation

@lcy0x1
Copy link

@lcy0x1 lcy0x1 commented Feb 26, 2025

  • BowAmmoModifierHook: Change input parameter type from Player to LivingEntity

Restructure arrow shoot logic:

  • User information (For player with bow: speed = 3, inaccuracy = 1, no infinity, do weapon durability cost)
  • Shoot logic supporting multishot (common code)
    • Arrow creation logic. Use inheritance to allow crossbow to support rocket and mark arrow as shot from crossbow
    • Arrow modifier logic. Same for bow and crossbow.
    • Firing logic. This part bow differs from crossbow.
    • Shooting sound. Use inheritance to allow bow and crossbow to customize.
    • Durability cost. Same for bow and crossbow
  • Individual code for weapon data manipulation

@lcy0x1
Copy link
Author

lcy0x1 commented Feb 26, 2025

This PR is the first step toward allowing mob to use TConstruct bows and arrows. They can call ModifiableLauncherWeapon.shootProjectiles to simulate shooting.

@KnightMiner KnightMiner added Technical Pull requests making changes to workspace or targeted versions 1.20 Issue affects 1.20 labels Feb 26, 2025
Comment on lines 187 to 189
if (user instanceof Player player) {
player.getInventory().removeItem(standardAmmo);
}
Copy link
Member

Choose a reason for hiding this comment

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

I want to discuss this more; how is a non-player expected to remove the ammo from their inventory? Or are we just assuming they don't care about cleaning up empty stacks?

I know most mobs do infinite ammo, but imagine a dispenser like shooter.

Copy link
Author

Choose a reason for hiding this comment

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

I would say the mob needs to be able to clean up empty stacks themselves. What harm will it do to not remove empty stacks? They are empty and isEmpty() returns true

Copy link
Member

Choose a reason for hiding this comment

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

Mostly just memory waste, which is why vanilla typically does it.

Copy link
Author

Choose a reason for hiding this comment

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

I don't think there is a realistic method to clear mob inventory, as each mob would have different implementations. Sounds like it doesn't matter that much.

Though if you think this part should be part of the API, then maybe LauncherUserInfo would be a place to add it.

# Conflicts:
#	src/main/java/slimeknights/tconstruct/library/tools/item/ranged/ModifiableLauncherItem.java
@lcy0x1 lcy0x1 marked this pull request as ready for review March 2, 2025 10:30
@lcy0x1
Copy link
Author

lcy0x1 commented Mar 5, 2025

Any remaining items to discuss?

@KnightMiner
Copy link
Member

I need to do a more in depth code review when I get a chance. I might have something after that.

@lcy0x1
Copy link
Author

lcy0x1 commented Mar 6, 2025

Thanks

KnightMiner added a commit that referenced this pull request May 26, 2025
Simplifies an upcoming change.
Related issue: #5351
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.20 Issue affects 1.20 Technical Pull requests making changes to workspace or targeted versions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants