athrane / bassebombecraft

Bassebombecraft Minecraft Mod
https://www.curseforge.com/minecraft/mc-mods/bassebombecraft
GNU General Public License v3.0
0 stars 0 forks source link

Refactor ContagionEffect to use operator to resolve potion effect #1266

Open athrane opened 2 years ago

athrane commented 2 years ago

Current implementation:

    public void performEffect(LivingEntity entity, int amplifier) {

        // exit if entity is undefined
        if (entity == null)
            return;

        // exit if entity is player
        if (isTypePlayerEntity(entity))
            return;

        // exit if entity has no effects
        Optional<EffectInstance> optInstance = resolveEffectInstance(entity);
        if (!optInstance.isPresent())
            return;

        // find entities and add effect
        aoePorts.setLivingEntity1(entity);
        aoePorts.setEffectInstance1(optInstance.get());
        run(aoePorts, lazyInitAoeCoreOp);
    }

The resolution of the effect and exit if no effect was found should implemented as operators: