Allow Sentry Turrets and Micromissiles to attack entities not instanceof LivingEntity
bartico6 opened this issue ยท 0 comments
Describe the feature
Currently, Micromissiles & Sentry Turrets can only acquire entities instanceof LivingEntity
as targets. This issue requests that this limitation is lifted under certain conditions.
Additionally, code for Micromissiles suggests this limitation isn't intended, as it checks if the target is a LivingEntity
, a Boat
or an AbstractMinecart
:
https://github.com/TeamPneumatic/pnc-repressurized/blob/1.21/src/main/java/me/desht/pneumaticcraft/common/entity/projectile/MicromissileEntity.java#L208
Reasons why it should be considered
Attacking entities that aren't a LivingEntity
is a niche use-case - however, some useful examples would be:
- Destroy items with micromissiles on demand
- Repel primed TNT via Micromissiles (or Explosive Ammo Sentries)
- Attack vehicles to dismount players/entities
- In general, support for the full entity filter list (
@item
,@boat
,@minecart
etc.)
Additional details
If this feature request was to be accepted, for performance reasons target acquisitions should look for LivingEntity unless given reason to do otherwise:
- EntityMatcher should expose
boolean canTargetNonLiving()
, set to true when using predicate matching for non living entity stuff like boats, minecarts etc., or entity type matching (described as follows in F1 help)
Worth considering a meta character to enable non-living matching for entity type matching - perhaps
*entity_type*
wouldn't enable it, but#*entity_type*
would? This should be considered to avoid users unwittingly increasing the server's workload by accident. Enabling non-living matching should be a deliberate choice by the user.
- Add
boolean canTargetNonLiving()
inEntityFilter
, returning true if any of the matchers it contains havecanTargetNonLiving()
set (basically, bubble up the property) - Add
boolean canTargetNonLiving()
inStringFilterEntitySelector
, returning true if any of itsEntityFilter
s has it set to true (bubble it up as well) - Inside SentryTurretBlockEntity and MicromissileEntity, check their entity selector's
canTargetNonLiving()
property before deciding if it should request a list of allLivingEntity
in their target acquisition range, or instead allEntity
.