PneumaticCraft: Repressurized

PneumaticCraft: Repressurized

43M Downloads

Add support for Aquatic Animal entity filters

HipHopHuman opened this issue ยท 7 comments

commented

Describe the feature

The entity filter does not currently support filtering for mobs which extend WaterAnimal.

Something like @animal(aquatic=true) or perhaps @animal(habitat=water) (I like the latter because it is more future proof should you ever need something like @animal(habitat=lava))

Reasons why it should be considered

It's a gap in functionality

Additional details

Conversation where this was discussed: https://discord.com/channels/380076480241336323/380100722420613121/1109593595176026202

commented

Yeah, why not. Not sure how feasible habitat checking would be; I don't think there's any way checking in code what an entity's preferred habitat is. So probably just a check for entities which extend WaterAnimal.

commented

I don't think there's any way checking in code what an entity's preferred habitat is

I figured this to be the case already. I'm suggesting that habitat is simply faked - aquatic animals all extend WaterAnimal right? If so, that's habitat=water. If Mojang or another popular enough mod adds a LavaAnimal (if such a thing doesn't exist already - not sure what Striders are) then that'd be habitat=lava.

commented

Striders just extend Animal. They don't really live in lava, they walk on top of it.

commented

Found possibly a better way to check for this: if (livingEntity.getMobType() == MobType.WATER). That pretty much matches up with animals which have water as their native habitat. All known mob types:

    public static final MobType UNDEFINED = new MobType();
    public static final MobType UNDEAD = new MobType();
    public static final MobType ARTHROPOD = new MobType();
    public static final MobType ILLAGER = new MobType();
    public static final MobType WATER = new MobType();

I could add a test (mobtype=<t>) where is one of the above. It's interesting Mojang don't use entity type tags for this, but hey. So @animal(mobtype=water) would work for any aquatic animal.

Actually, entity type tags would also be easy enough to filter for...

commented

OK, here's what I've settled on:

  • New yes/no modifiers: aquatic, undead, arthropod & illager, e.g. @living(aquatic=yes) matches all aquatic living entities
  • New type_tag modifier which checks if the entity type has a specific tag, e.g. @mob(type_tag=minecraft:skeletons)
  • New entity_tag modifier which checks if the entity has a specific string tag, added via the vanilla /tag command or possibly other mods like KubeJS, e.g. @player(entity_tag=marked_for_death).
commented

Sorry it took me a while to respond to this, my old eye issues have been resurfacing lately (looks like I may one day need keratoprosthesis if I ever want this situation to be completely behind me, sigh). Good work @desht - this all looks good. Though, seeing how Mojang implemented this makes the software developer in me scream/cry

commented

Added in 4.3.6. And yeah I am not a fan of the way Mojang handles this either :)