Minecraft Version
1.20.1
Forge Version
47.1.3+
Mantle Version
1.11.36
Tinkers' Construct Version
3.9.1.19
Problem description
Currently, ModifiableBowItem and ModifiableCrossbowItem are both restricted to player use only, while the underlying logic actually allow non-player to trigger most of the mechanics.
The current vanilla stack trace for mobs using projectile weapon is quite obscure and inflexible:
RangedAttackMob::performRangedAttack
ProjectileUtil::getMobArrow
ArrowItem::createArrow
AbstractArrow::setEnchantmentEffectsFromEntity
BowItem::customArrow
Since TConstruct does not follow the vanilla logic for arrow entity creation, could there be an interface for mobs to use TConstruct bows and crossbows?
I have already implemented mob using TConstruct bows and crossbows, but in a way that copied and modified a large chunk of respective TConstruct code. It's not clean and could break in the future if TConstruct modified this part of the code. Is it possible to extract an API for this, so that I can keep minimal repetition of TConstruct code?
This is my implementation: https://github.com/Minecraft-LightLand/ModularGolems/tree/lcy0x1/1.20/src/main/java/dev/xkmc/modulargolems/compat/materials/tinker/behavior
Suggested solution
Here is something I would propose:
class ModifiableBowItem {void shootArrows(LivingEntity user, ItemStack bow, ProjectileStrategy strategy)}
interface ProjectileStrategy {void shootArrow(Projectile arrowEntity, float arrowVelocity, float arrowGravity, float angleInDegree, float inaccuracy);}
Where ProjectileStrategy is an interface that allows mobs to control the initial velocity of the arrow.
This implementation would be very similar to respective Bow / Crossbow code, where there could b a ProjectileStrategy for player. It's the easiest fix
Alternatives considered
The alternative would be to follow the vanilla logic, where the major logic and hook moves to customArrow, and call that part in item usage.
Additional context
No response
Searched for existing enhancement?
Used the search bar, Checked the FAQ, Checked the in game books
Minecraft Version
1.20.1
Forge Version
47.1.3+
Mantle Version
1.11.36
Tinkers' Construct Version
3.9.1.19
Problem description
Currently,
ModifiableBowItemandModifiableCrossbowItemare both restricted to player use only, while the underlying logic actually allow non-player to trigger most of the mechanics.The current vanilla stack trace for mobs using projectile weapon is quite obscure and inflexible:
RangedAttackMob::performRangedAttackProjectileUtil::getMobArrowArrowItem::createArrowAbstractArrow::setEnchantmentEffectsFromEntityBowItem::customArrowSince TConstruct does not follow the vanilla logic for arrow entity creation, could there be an interface for mobs to use TConstruct bows and crossbows?
I have already implemented mob using TConstruct bows and crossbows, but in a way that copied and modified a large chunk of respective TConstruct code. It's not clean and could break in the future if TConstruct modified this part of the code. Is it possible to extract an API for this, so that I can keep minimal repetition of TConstruct code?
This is my implementation: https://github.com/Minecraft-LightLand/ModularGolems/tree/lcy0x1/1.20/src/main/java/dev/xkmc/modulargolems/compat/materials/tinker/behavior
Suggested solution
Here is something I would propose:
class ModifiableBowItem {void shootArrows(LivingEntity user, ItemStack bow, ProjectileStrategy strategy)}interface ProjectileStrategy {void shootArrow(Projectile arrowEntity, float arrowVelocity, float arrowGravity, float angleInDegree, float inaccuracy);}Where
ProjectileStrategyis an interface that allows mobs to control the initial velocity of the arrow.This implementation would be very similar to respective Bow / Crossbow code, where there could b a
ProjectileStrategyfor player. It's the easiest fixAlternatives considered
The alternative would be to follow the vanilla logic, where the major logic and hook moves to
customArrow, and call that part in item usage.Additional context
No response
Searched for existing enhancement?
Used the search bar, Checked the FAQ, Checked the in game books