ldtteam / minecolonies-features

This is a repo only to discuss minecolonies features (requested and planned)
10 stars 3 forks source link

Civilian entities should override `canBeLeashed` #713

Closed TheMrMilchmann closed 1 year ago

TheMrMilchmann commented 1 year ago

Prerequisites

Context

Is your feature request related to a problem?

Civilian entities inherit from Mob. Mobs are generally assumed to be "leashable" unless they are enemies. This behavior of the boolean canBeLeashed(Player) method should be overridden for mobs for which this is not the case. Vanialla villages (AbstractVillager) is an example of a type of mob that overrides this behavior. Currently, this check is not overridden for civilian entities. Consequentially, code using the check to determine the behavior of an entity assumes that the civilians can be leashed.

In practice, this is not a problem when running with MineColonies only because the interaction is consumed when a GUI is opened. However, this flag may be used by other mods to determine how an entity should behave. For example, I published a tiny QoL mod a while back that blocks entities that can be leashed from passing through fence gates if are not on a leash. Unless the behavior for an entity type is explicitly configured, the mod tries to interfere the correct behavior using this check. See https://github.com/TheMrMilchmann/TheFenceUnleashed/issues/2 for further context.

Enhancement or Change description

I propose that civilian entities override this check for better interop with other mods. An implementation is provided in https://github.com/ldtteam/minecolonies/pull/8601.


Viewers