Better Zombies & Curing

Better Zombies & Curing

622 Downloads

Refactor for less repetitive code

TechernCruz opened this issue ยท 0 comments

commented

Seriously.

Zoglin zoglin = (Zoglin) event.getTarget();
        ServerLevel level = (ServerLevel) event.getLevel();

        if (meetsConversionRequirements(zoglin)) {
            Pig pig = zoglin.convertTo(EntityType.PIG, false);

            pig.finalizeSpawn(level, level.getCurrentDifficultyAt(pig.blockPosition()), MobSpawnType.CONVERSION, (SpawnGroupData)null, (CompoundTag)null);
            pig.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0));
            level.levelEvent((Player)null, 1027, pig.blockPosition(), 0);
            event.getEntity().getItemInHand(event.getHand()).shrink(1);
        }

This could be handled with a generic function... In theory